129
votes
Accepted
Readability versus maintainability, special case of writing nested function calls
If you felt compelled to expand a one liner like
a = F(G1(H1(b1), H2(b2)), G2(c1));
I wouldn't blame you. That's not only hard to read, it's hard to debug.
Why?
It's dense
Some debuggers will ...
96
votes
Accepted
Does splitting a potentially monolithic application into several smaller ones help prevent bugs?
Yes. Generally two smaller less complex applications are much easier to maintain than a single large one.
However, you get a new type of bug when the applications all work together to achieve a goal. ...
57
votes
Dry running a function
You're doing multiple different things in that function. Start off by splitting it into separate functions. Here's an example using a closure for the "dry run" function.
function ...
52
votes
Readability versus maintainability, special case of writing nested function calls
On the other hand, the more processing you put on a line, the more logic you get on one page, which enhances readability.
I utterly disagree with this. Just looking at your two code examples calls ...
52
votes
Does splitting a potentially monolithic application into several smaller ones help prevent bugs?
Does splitting a potentially monolithic application into several smaller ones help prevent bugs
Things are seldom that simple in reality.
Splitting up does definitely not help to prevent those bugs ...
40
votes
Does splitting a potentially monolithic application into several smaller ones help prevent bugs?
I'll have to disagree with the majority on this one. Splitting up an application into two separate ones does not in itself make the code any easier to maintain or reason about.
Separating code into ...
38
votes
Dry running a function
There are two solutions that seem reasonable:
You can use a dependency injection approach that lets you swap out the action with a different one. This is what 8bittree suggests in their answer.
You ...
25
votes
Readability versus maintainability, special case of writing nested function calls
Your first example, the single-assignment-form, is unreadable because the chosen names are utterly meaningless. That might be an artifact of trying not to disclose internal information on your part, ...
22
votes
Readability versus maintainability, special case of writing nested function calls
As always, when it comes to readability, failure is in the extremes. You can take any good programming advice, turn it into a religious rule, and use it to produce utterly unreadable code. (If you don'...
18
votes
Accepted
Are vague variable names more maintainable?
Short answer: No
Long answer:
No, vague names are far less maintainable than precise names. You won't rename things on a weekly basis (and if you do, you should ask yourself "What is the reason for ...
15
votes
Does splitting a potentially monolithic application into several smaller ones help prevent bugs?
Easier to maintain once you've finished splitting them, yes. But splitting them is not always easy. Trying to split off a piece of a program into a reusable library reveals where the original ...
14
votes
Readability versus maintainability, special case of writing nested function calls
@Dominique, I think in your question's analysis, you're making the mistake that "readability" and "maintainability" are two separate things.
Is it possible to have code that is maintainable but ...
14
votes
Does splitting a potentially monolithic application into several smaller ones help prevent bugs?
It's important to remember that correlation is not causation.
Building a large monolith and then splitting it up into several small parts may or may not lead to a good design. (It can improve the ...
12
votes
Accepted
What are the techniques for keeping the code quality high when requirements change?
What are the techniques for keeping the code quality high when requirements change?
Have you tried Test-Driven Development? It's exactly for this purpose.
When you're done with a feature with TDD, ...
12
votes
What are the techniques for keeping the code quality high when requirements change?
Whenever I write a piece of functionality from scratch, it's a good and robust code.
We all think that at this point. We're seldom right.
But often times my assumptions about how the code should ...
12
votes
Are vague variable names more maintainable?
IMHO most of your "pro" arguments are flawed, but let us discuss them one-by-one:
If the query needs to change and return a different type, we don't have to remember to rename the result variable.
...
9
votes
What time horizon and level of abstraction is the right for the maintainable and evolvable software?
My rules of thumb are:
I drive my code with Unit tests to keep it focused on the actual requirement, it also means as I evolve the code through each of these following steps I can be confident it ...
8
votes
When is a rewrite appropriate?
Do you have complete, detailed, and comprehensive set of requirements, preferably as executable tests?
I'm going to guess: No as the writer probably hasn't discovered those yet...
In such a case, ...
8
votes
Dry running a function
I would break the operation into two. As long as it's a single operation, regardless of how you program it, there is a chance you run it live instead of dry by mistake.
Conceptually with your coupon ...
7
votes
Accepted
Guidelines about fields of classes in maintainable software?
You haven't cited the actual content of those guidelines, so the question is hard to answer for people who do not have the book available. I'll try to answer more generally.
The important part with "...
7
votes
Console application for developer interviews
You're on the right track, but your test could use some improvement. Don't test people to understand code, test them to understand algorithms. The majority of the analysis you're asking for can be ...
7
votes
When should a method depend on a data source and NOT have it declared as a parameter?
Between being right and wrong, there is a third possibility, that you're both right.
You are correct at one level, and your colleague is correct that we should bundle things together so that we don't ...
6
votes
Working with "external" object identifiers
Is there a general way to overcome this problem? (Or am I fussing over nothing?)
Yes, you are too concerned about this.
So you are duplicating data. As long as you have enough RAM available, this ...
6
votes
Does splitting a potentially monolithic application into several smaller ones help prevent bugs?
This is not a question with a yes or no answer. The question is not just ease of maintenance, it is also a question efficient use of skills.
Generally, a well-written monolithic application is ...
6
votes
What could be a good pattern for a code base that does a lot of A/B testing?
Dependency injection and the decorator pattern are your best friends for doing A/B testing. My team has several experiments running at any given time and we maintain a single codebase for all of them.
...
6
votes
Use local or nested function for readability?
I always thought that local functions were created to avoid writing
multiple times the same code
No. That's a misconception, outdated since the 1970s, and I'm happy that we have since learned a few ...
6
votes
How to deal with an actively developed 20 year old legacy codebase
My manager says that the code simply is too big and old to change for the better
Managers don’t care about better code. Don’t ask them to give you credit for making it better. They wouldn’t know ...
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
Does splitting a potentially monolithic application into several smaller ones help prevent bugs?
No. it does not make it easier to maintain. If anything welcome to more problems.
Why?
The programs are not orthogonal they need to preserve each others work in so far as is reasonable, which ...
5
votes
What could be a good pattern for a code base that does a lot of A/B testing?
Four things helped me a lot when deploying many features per release, and testing them in production:
Feature flags.
Whitelists.
Routing control.
Detailed logging.
A feature flag allowed us to ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
maintainability × 143design × 18
refactoring × 16
readability × 15
architecture × 14
code-quality × 12
java × 10
clean-code × 10
maintenance × 9
c# × 8
programming-practices × 8
performance × 8
object-oriented × 7
c++ × 7
coding-style × 7
design-patterns × 6
source-code × 6
project-management × 5
language-agnostic × 5
coding-standards × 5
agile × 4
optimization × 4
abstraction × 4
technical-debt × 4
javascript × 3