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 ...
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 ...
44
votes
Why should we reuse code as binary modules instead of copy/pasting?
Copying code (causing duplication) and sharing code (de-duplicating it via shared modules, classes, libraries, whatever) each have their benefits and drawbacks.
In my opinion, the key difference is in ...
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
Too much abstraction making code hard to extend
If I try to make a new method to handle B differently, it gets called out for code duplication.
Not all code duplication is created equal.
Say you have a method that takes two parameters and adds ...
20
votes
Why should we reuse code as binary modules instead of copy/pasting?
You can copy and paste code.
There are times when it is the right thing to do. We are taught not to do it because, more often than when it is the right thing to do, it is the lazy thing to do.
It is ...
14
votes
Accepted
Proper design for a class with one method that can vary between customers
I have a class used to process customer payments. All but one of the methods of this class are the same for every customer, except for one that calculates (for example) how much the customer's user ...
14
votes
Why should we reuse code as binary modules instead of copy/pasting?
You can talk about untested code, brittleness, etc. That's just going to fly over their head. The simplest way to describe it is to explain that if you need to make a change to the behavior of that ...
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 ...
13
votes
Why should we reuse code as binary modules instead of copy/pasting?
You can share source code files between projects without copy & paste, so sharing binary modules vs. copy & paste is a false dichotomy / false dilemma.
Copy & paste offers no built-in ...
12
votes
Accepted
How to avoid duplication of data structures when parts of an app are written in different languages?
You do not. Or really, you should not.
If you think of app, your server and your website as separate contexts, then it makes sense there to be duplicate structures. Reasons why it might be a good ...
10
votes
Proper design for a class with one method that can vary between customers
You might want to look into writing the custom calculations as "plug-ins" for your application. Then, you'd use a configuration file to tell you program which calculation plugin should be used for ...
10
votes
Should we put small, potentially often-used pieces of code into tool methods in a shared library?
Save me from published junk drawers.
If you want to put small, potentially often used piece of code in a shared library then that library needs a good organizing principle. That is, it needs a good ...
9
votes
Accepted
Is 'Keep it looks similar to sample code' a valid reason to prefer WET over DRY principle?
No.
Indeed, following the DRY principle can sometimes make very simple code look a little bit more complex (which might be here the case, with emphasis on "a little bit").
However, this is a small ...
9
votes
Why should we reuse code as binary modules instead of copy/pasting?
Every line of code is future maintenance cost. Make three copies of your library as source code and you just tripled your maintenance cost.
Now what’s really bad is to have the same code three times ...
8
votes
How to provide Java libraries internally?
Setup a Maven repository and manage your dependencies with Maven or Ivy.
Maven seems to have more market and is a more complete tool for builds. Its main downside is that it relies in convention, ...
8
votes
In which programming paradigm can't code reuse be (easily) achieved?
For my own sanity, I've shortened "paradigms that promote code reuse" to "paradigms". In scope of this answer, all mentioned paradigms are paradigms that promote code reuse.
What ...
8
votes
How do huge open source libraries get maintained while having code far from "clean code" practices?
Most open source projects are badly managed. There are obviously exceptions to that, but you will find a lot of junk in the open-source world.
This is not a critique of all the project owners/...
8
votes
Too much abstraction making code hard to extend
The usual saying that we all read here and there is:
All problems can be solved by adding another layer of abstraction.
Well, this is not true ! Your example shows it. I’d therefore propose the ...
8
votes
Accepted
Does a programming language with ML-style modules need packages?
Modules and packages solve different problems, though they certainly overlap, and can be made nearly synonymous.
Packages provide a critical source of namespacing. Modules aren't guaranteed unique ...
7
votes
Refactoring Atrocious Java Code
If the code base was in perfect shape you wouldn't have a job there. I've seen enough developer turn over to notice the usual trend is to rewrite everything because it is a mess and rewriting it would ...
6
votes
Accepted
Reusing a top-level DTO as a child in another DTO
Re-use existing DTO, Create new parent DTO and Flatten class structure
Choosing between reusable code (sometimes it makes us feel like squaring the circle) or customization (sometimes it makes us ...
6
votes
Best practices on sharing code between open source libraries
The obvious and correct solution is (2): make B a client of A.
Sure, B will import more than it needs, but that is the case for 99% of library clients. You're just misled because you know the ...
6
votes
Accepted
How to avoid code duplication in two similar projects?
Best practice is to put your common code in a library, compile it and distribute the binary to both projects via a package manager.
However, If the first website is end of life, you probably dont ...
6
votes
Code design: introduce new method vs add optional parameter to existing method
There is no right answer to this. In a general sense, you actually have three options:
Add an optional parameter,
Add a second function with a different name,
Add a second function with the same ...
6
votes
Too much abstraction making code hard to extend
Whenever I see a method where the behavior switches on the type of its parameter, I immediately consider first if that method actually belongs on the method parameter. For example, instead of having a ...
6
votes
Accepted
How to maintain well structured code and latency optimized code together?
I would not try to abuse a version control system like git for this.
For complex optimization as described here, which can only be done manually, it is probably best to keep both versions of a ...
6
votes
Best thing to do by private developers in case of impending death or plans to cease development on a personal private project
This is really two questions that are very related, but require different approaches.
Before Reading Further
If the developer has legal, financial, or contractual obligations or implications related ...
5
votes
Accepted
How useful is line-by-line code re-use?
Code reuse and Lines of Code (LoC) counting are different obsessions.
Both are things to be sensitive to. Neither should be the primary concern.
Good names, readability, semantics, organization, ...
5
votes
How to avoid duplication of data structures when parts of an app are written in different languages?
I think @Euphoric listed a couple of good reasons not to duplicate your code. However, if you must do so I'd recommend using code generation.
Find the canonical form of the data
To do so effectively ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
code-reuse × 186code-quality × 20
libraries × 20
design × 16
design-patterns × 16
architecture × 15
object-oriented × 15
clean-code × 13
c# × 12
programming-practices × 11
java × 10
dry × 9
refactoring × 8
interfaces × 8
javascript × 7
project-management × 7
php × 6
version-control × 6
code-reviews × 6
source-code × 6
c++ × 5
object-oriented-design × 5
git × 5
inheritance × 5
legal × 5