Skip to main content
187 votes

Why do library developers deliberately break existing code?

A major version upgrade literally means they intend to break things. You shouldn't upgrade to a new major version unless you're prepared to deal with it. Most build systems have a way to specify you'...
Karl Bielefeldt's user avatar
179 votes

What is a "shaded" Java dependency?

Shading dependencies is the process of including and renaming dependencies (thus relocating the classes & rewriting affected bytecode & resources) to create a private copy that you bundle ...
Hugues M.'s user avatar
  • 1,902
158 votes

How do huge open source libraries get maintained while having code far from "clean code" practices?

The principles stated in "Clean Code" are not always generally agreed upon. Most of it is common sense, but some of the author's opinions are rather controversial and not shared by everybody. In ...
JacquesB's user avatar
  • 59.9k
144 votes
Accepted

Exception vs empty result set when the inputs are technically valid, but unsatisfiable

Return an Empty Set I would expect an empty set because: There are 0 combinations of 4 numbers from the set of 3 when i can only use each number once
Ewan's user avatar
  • 77.5k
105 votes
Accepted

What is the difference between a library and a dependency?

Libraries and dependencies are like persons and relatives: One is just an entity (something), the other is a relational entity. I am a person. My niece is also a person. But to her, I'm a relative. ...
Kilian Foth's user avatar
83 votes
Accepted

How do huge open source libraries get maintained while having code far from "clean code" practices?

Good answer here already, but let me say a word about your butterknife example: though I have no idea what the code does, at a first glance, it does not look really unmaintainable to me. Variables and ...
Doc Brown's user avatar
  • 210k
81 votes

Exception vs empty result set when the inputs are technically valid, but unsatisfiable

When in doubt, ask someone else. Your example function has a very similar one in Python: itertools.combinations. Let's see how it works: >>> import itertools >>> input = [1, 2, 3, ...
301_Moved_Permanently's user avatar
78 votes
Accepted

Is it considered an anti-pattern to read from STDIN from within a library?

As a general guideline, libraries should be totally disconnected from the environment. That means that they shouldn't perform operations on standard streams, on specific files, or have any expectation ...
Paul92's user avatar
  • 2,601
71 votes

Exception vs empty result set when the inputs are technically valid, but unsatisfiable

In layman's terms: If there is an error, you should raise an exception. That may involve doing things in steps instead of in a single chained call in order to know exactly where the error happened. ...
Tulains Córdova's user avatar
55 votes
Accepted

Should you use a library when you can do the task without it?

As an engineer, perhaps it is suitable to think of this as an optimization problem. Naturally we must have an optimization goal. A common one in this sort of situation would be to minimize Total Cost ...
John Wu's user avatar
  • 26.6k
55 votes

Why do library developers deliberately break existing code?

My point, and question, is: Why do library developers knowingly break existing code like this? Why not at least have it default to either true or false, whichever is the most reasonable? Because ...
Flater's user avatar
  • 52.7k
53 votes

Exception vs empty result set when the inputs are technically valid, but unsatisfiable

I agree with Ewan's answer but want to add a specific reasoning. You are dealing with mathematical operations, so it might be a good advice to stick with the same mathematical definitions. From a ...
sigy's user avatar
  • 716
41 votes

What is the difference between a library and a dependency?

If an application uses a library, the application has a dependency on that library. Libraries are not the only type of dependency an application can have. Software can also depend on: configuration ...
Rik D's user avatar
  • 4,800
36 votes

Should you use a library when you can do the task without it?

Bill Gates once famously said: "Measuring programming progress by lines of code is like measuring aircraft building progress by weight." This quote comes to mind because the same could ...
Neil's user avatar
  • 22.8k
34 votes

How do huge open source libraries get maintained while having code far from "clean code" practices?

Summary As JacquesB writes, not everybody agrees with Robert C. Martin's "Clean Code". The open source projects that you found to be "violating" the principles you expected are likely to simply have ...
Jens Bannmann's user avatar
32 votes

What is actually the difference between the GNU C Library and the C standard Library?

The C standard library is part of the C programming language, so it is a specification (written in English in some technical report). For example, the n1570 document is explaining what is malloc and ...
Basile Starynkevitch's user avatar
25 votes

Why develop internal libraries for internal applications?

There are numerous reasons to create libraries & shared libraries, (in .dll or .so files) even for internal usage: Re-Use across projects is much cleaner Separation of responsibility - part of ...
Steve Barnes's user avatar
  • 5,320
24 votes

Exception vs empty result set when the inputs are technically valid, but unsatisfiable

I find a good way of determining whether to use an exception, is to imagine people being involved in the transaction. Taking fetching the contents of a file as an example: Please fetch me the ...
David Arno's user avatar
  • 39.4k
24 votes
Accepted

Writing public libraries: Should I let the consumer of the library enforce thread safety?

You should make your library thread-safe, but that does not mean that you should be sprinkling synchronization primitives around your code base. For the average library, which is not explicitly ...
Bart van Ingen Schenau's user avatar
21 votes

What side-effects, if any, are okay when importing a python module?

logging # Creates a logfile logging.basicConfig(filename="module.log") No, don't do it! Now git status is dirty, it shows an untracked file. Protect this with a __main__ guard, or let ...
J_H's user avatar
  • 7,600
16 votes

Is it considered an anti-pattern to read from STDIN from within a library?

I would consider this not necessarily an anti-pattern, just a poorly designed library. It should be trivial to ask for a string as a method parameter, where the input could be passed directly in. If ...
Bryan Boettcher's user avatar
16 votes
Accepted

Why are developers still using proprietary third-party libraries?

Three obvious reasons: There's no open source equivalent, The company wants paid-for support that they can rely on. They are a bit behind the times and do not yet trust open source libraries.
David Arno's user avatar
  • 39.4k
15 votes
Accepted

Designing a Python string validation library

Keep it simple. Either offer functions that check or assert the format, or create a type that represents a validated string. These approaches have different tradeoffs. The most generic approach may be ...
amon's user avatar
  • 135k
15 votes

Designing a Python string validation library

I am under the impression you are looking too much from the implementation side at your lib. Try to look at it from the calling side and ask yourself "How would you like to use your library?"...
Doc Brown's user avatar
  • 210k
14 votes

Should you use a library when you can do the task without it?

(Note: The original question was: Does the number of libraries improve code quality?) You can probably answer that one for yourself: No, of course the mere fact of using libraries doesn't improve ...
Kilian Foth's user avatar
13 votes

How do huge open source libraries get maintained while having code far from "clean code" practices?

Many open source libraries do in fact suffer from objectively poor coding practices and are maintained with difficulty by a small group of long-term contributors who can deal with the poor readability ...
Kafein's user avatar
  • 436
13 votes

What side-effects, if any, are okay when importing a python module?

However, in a lot of cases, the side-effects are hard to avoid or may be desirable. They are never hard to avoid, and they are never desirable. Or maybe they somewhat are hard to avoid, because it ...
freakish's user avatar
  • 1,916
12 votes
Accepted

Should code be written to stay consistent with the unidiomatic API style of a library?

In general, I think the answer to this one is "it depends". Looking more closely at your specific example: If you're subclassing something, then it's probably best to stay with the style of the code ...
Philip Kendall's user avatar
12 votes

What is the difference between a library and a dependency?

Dependency In Docker image you have dependencies on different types and versions of: underlying OS (CentOS, Debian, Windows, ...) database (Mongo, Postgresql, ElasticSearch, ...) tools, and ...
RenatoIvancic's user avatar
12 votes

Why do library developers deliberately break existing code?

Some good answers already, however, let me add my two cents from some real-world experience. More than often, though usually acting in good faith, some API designers are pretty ignorant what kind of ...
Doc Brown's user avatar
  • 210k

Only top scored, non community-wiki answers of a minimum length are eligible