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'...
159
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 ...
157
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 ...
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
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. ...
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 ...
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, ...
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 ...
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.
...
57
votes
Accepted
Are header-only libraries more efficient?
One of the advantages of header-only libraries for C++ is that they do not need to be compiled separately
No, that is not an advantage, quite the opposite - the main part of the library has to be ...
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 ...
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 ...
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 ...
42
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 ...
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 ...
34
votes
Why use an opaque "handle" that requires casting in a public API rather than a typesafe struct pointer?
The "simple is better" mantra has become too much dogmatic. Simple is not always better if it complicates other things. Assembly is simple - each command is much simpler than higher-level languages ...
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 ...
28
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 ...
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 ...
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 ...
23
votes
Accepted
What to keep in mind when releasing an app which uses libraries licensed under the Apache 2.0 License?
There are well-established patterns for attributing the libraries you use. In general, you put this attribution in the same place where you'd put your copyright notice.
In a desktop application: ...
17
votes
Are header-only libraries more efficient?
Well, let's first demolish some of your assumptions:
One of the advantages of header-only libraries for C++ is that they do not need to be compiled separately.
Compiling things separately ...
16
votes
Why use an opaque "handle" that requires casting in a public API rather than a typesafe struct pointer?
There seems to be a confusion on both sides here:
using a handle approach does not requiring using a single handle type for all handles
exposing the struct name does not expose its details (only its ...
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 ...
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.
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 ...
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 ...
12
votes
Accepted
When creating a library, is there a way to make certain classes entirely internal to the library, and not exposed to the user of the library?
Use package-private, which is what you get when you specify no access modifier at all. It limits a class or method to only be visible to the package it's in.
package animals;
public class Animal { .....
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
libraries × 372c++ × 55
design × 28
java × 28
c# × 28
c × 27
javascript × 22
api × 21
licensing × 19
code-reuse × 18
programming-practices × 17
api-design × 17
third-party-libraries × 17
open-source × 16
dependencies × 15
architecture × 13
python × 11
.net × 11
frameworks × 10
design-patterns × 9
programming-languages × 9
interfaces × 9
php × 8
android × 8
gpl × 8