Linked Questions

57
votes
9answers
8k views

Readability versus maintainability, special case of writing nested function calls

My coding style for nested function calls is the following: var result_h1 = H1(b1); var result_h2 = H2(b2); var result_g1 = G1(result_h1, result_h2); var result_g2 = G2(c1); var a = F(result_g1, ...
40
votes
18answers
27k views

What should be the maximum length of a function? [closed]

What should be the maximum length of a function? And are there cases which are an exception to this?
41
votes
13answers
28k views

What does it mean to write “good code”? [closed]

In this question I asked whether being a bad writer hinders you from writing good code. Many of the answers started of with "it depends on what you mean by good code". It appears that the term "good ...
38
votes
14answers
7k views

How important is it to clean up someone else's code when faced with a tight deadline? [closed]

(I'm talking about HTML / CSS code (not programming languages) but I think we also face the same issue as with programmers.) I am the senior front-end designer in a team and I often have to re-work ...
42
votes
8answers
6k views

Beginning a sentence with a function name? [closed]

Occasionally while typing something up that relates to a case-sensitive programming language I end up starting a sentence with a function name. Now the rules of English state that the first word in a ...
76
votes
4answers
16k views

What is the purpose of a Code Review

I am in the process of trying to sell my organisation on the value of code reviews. I have worked at several places where they were employed. I have seen them used to nitpick styling choices, and ...
53
votes
9answers
10k views

What's the right balance between code consistency and code improvement?

Recently I had a discussion with a colleague regarding code style. He was arguing that your usage of APIs and the general patterns you are using should be as similar as possible with the surrounding ...
29
votes
11answers
6k views

How many design patterns and levels of abstraction are necessary? [closed]

How can I tell my software has too much abstraction and too many design patterns, or the other way round, how do I know if it should have more of them? Developers I work with are programming ...
38
votes
7answers
7k views

Does it make sense to create blocks just to reduce a variable's scope?

I'm writing a program in Java where at one point I need to load a password for my keystore. Just for fun, I tried to keep my password in Java as short as possible by doing this: //Some code .... ...
29
votes
6answers
39k views

Create new object or reset every property?

public class MyClass { public object Prop1 { get; set; } public object Prop2 { get; set; } public object Prop3 { get; set; } } Suppose I have an object myObject of ...
33
votes
5answers
20k views

At what point/range is a code file too big?

I'm finding lots of 2-3k line files, and it doesn't really feel like they should be that big. What is a good criteria to objectively call a source code file "too big"?, is there such thing as a ...
21
votes
12answers
3k views

When does the “Do One Thing” paradigm become harmful?

For the sake of argument here's a sample function that prints contents of a given file line-by-line. Version 1: void printFile(const string & filePath) { fstream file(filePath, ios::in); ...
15
votes
6answers
3k views

When to use else in conditions? [duplicate]

When to use else in conditions? 1) a) long int multiplyNumbers(int n) { if (n >= 1) { return n*multiplyNumbers(n-1); } else { return 1; } } or b) long int ...
33
votes
5answers
19k views

Should I initialize C structs via parameter, or by return value? [closed]

The company I work at is initializing all of their data structures through an initialize function like so: //the structure typedef struct{ int a,b,c; } Foo; //the initialize function ...
27
votes
6answers
2k views

Method extraction vs underlying assumptions

When I split big methods (or procedures, or functions — this question is not specific to OOP, but since I work in OOP languages 99% of the time, it's the terminology that I'm most comfortable with) ...

15 30 50 per page