128 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 ...
candied_orange's user avatar
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. ...
Ewan's user avatar
  • 75k
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 ...
8bittree's user avatar
  • 5,656
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 ...
David Arno's user avatar
  • 39.3k
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 ...
Doc Brown's user avatar
  • 207k
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 ...
Voo's user avatar
  • 764
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 ...
amon's user avatar
  • 134k
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, ...
Deduplicator's user avatar
  • 9,031
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'...
cmaster - reinstate monica's user avatar
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 ...
CharonX's user avatar
  • 1,643
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 ...
StackOverthrow's user avatar
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 ...
Steve's user avatar
  • 8,661
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 ...
Daniel Pryden's user avatar
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, ...
MichelHenrich's user avatar
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 ...
candied_orange's user avatar
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. ...
Doc Brown's user avatar
  • 207k
10 votes
Accepted

How to handle defects from production (older version) in SCRUM

I don't know if there's an officially Scrummy was of handling that, but what I've done in previous teams is the following: Set some time aside Production issues are a reality whether or not we want ...
MetaFight's user avatar
  • 11.6k
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 these following steps I can be confident it will ...
Martin Spamer's user avatar
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, ...
Kain0_0's user avatar
  • 16.2k
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 ...
Ewan's user avatar
  • 75k
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 "...
Michael Borgwardt's user avatar
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 ...
whatsisname's user avatar
  • 27.7k
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 ...
Erik Eidt's user avatar
  • 33.7k
6 votes

When software rots, what property of the system changes?

Some large software are rotting quite slowly, because a significant part of them becomes redesigned/reimplemented/refactored from time to time. Take for example the GCC compiler. It is 28 years old, ...
Basile Starynkevitch's user avatar
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 ...
Greg Burghardt's user avatar
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 ...
MarvW's user avatar
  • 89
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. ...
casablanca's user avatar
  • 4,964
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 ...
Ralf Kleberhoff's user avatar
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 ...
candied_orange's user avatar
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 ...
Kain0_0's user avatar
  • 16.2k

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