Skip to main content
Tweeted twitter.com/StackSoftEng/status/968339607128592384

My coding style offor 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, result_g2); 

I have recently changed to a department, where the following coding style is very much in use:

var a = F(G1(H1(b1), H2(b2)), G2(c1)); 

The result of my way of coding is that, in case of a crashing function, Visual Studio can open the corresponding dump and indicate the line, where the problem occurs (I'm especially concerned about access violations).

I fear that, in case of a crash, due to the same problem, programmed in the first way, I won't be able to know which function has caused the crash.

On the other hand, the more processing you put on a line, the more logic you get on one page, which enhances readability.

Is my fear correct or am I missing something, and in general, which is preferred in a commercial environment? Readability or maintainability?

I don't know if it's relevant, but we are working in C++ (STL) /C# C#.

My coding style of 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, result_g2); 

I have recently changed to a department, where the following coding style is very much in use:

var a = F(G1(H1(b1), H2(b2)), G2(c1)); 

The result of my way of coding is that, in case of a crashing function, Visual Studio can open the corresponding dump and indicate the line, where the problem occurs (I'm especially concerned about access violations).

I fear that, in case of a crash, due to the same problem, programmed in the first way, I won't be able to know which function has caused the crash.

On the other hand, the more processing you put on a line, the more logic you get on one page, which enhances readability.

Is my fear correct or am I missing something, and in general, which is preferred in a commercial environment? Readability or maintainability?

I don't know if it's relevant, but we are working in C++ (STL) /C#.

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, result_g2); 

I have recently changed to a department where the following coding style is very much in use:

var a = F(G1(H1(b1), H2(b2)), G2(c1)); 

The result of my way of coding is that, in case of a crashing function, Visual Studio can open the corresponding dump and indicate the line where the problem occurs (I'm especially concerned about access violations).

I fear that, in case of a crash due to the same problem programmed in the first way, I won't be able to know which function has caused the crash.

On the other hand, the more processing you put on a line, the more logic you get on one page, which enhances readability.

Is my fear correct or am I missing something, and in general, which is preferred in a commercial environment? Readability or maintainability?

I don't know if it's relevant, but we are working in C++ (STL) / C#.

Edited title in order to emphasize the special case
Link
Dominique
  • 1.8k
  • 2
  • 20
  • 29

Readability versus maintainability, how to writespecial case of writing nested function calls

deleted 83 characters in body
Source Link
David Arno
  • 39.6k
  • 9
  • 95
  • 129

My coding style of nested function calls is the following: (the numbers in the tags are the line numbers)

<100> var result_h1 = H1(b1); <101> var result_h2 = H2(b2); <102> var result_g1 = G1(result_h1, result_h2); <103> var result_g2 = G2(c1); <104> var a = F(result_g1, result_g2); 

I have recently changed to a department, where the following coding style is very much in use:

<100> var a = F(G1(H1(b1), H2(b2)), G2(c1)); 

The result of my way of coding is that, in case of a crashing function, Visual Studio can open the corresponding dump and indicate the line, where the problem occurs (I'm especially concerned about access violations).

I fear that, in case of a crash, due to the same problem, programmed in the first way, I won't be able to know which function has caused the crash.

On the other hand, the more processing you put on a line, the more logic you get on one page, which enhances readability.

Is my fear correct or am I missing something, and in general, which is preferred in a commercial environment? Readability or maintainability?

I don't know if it's relevant, but we are working in C++ (STL) /C#.

My coding style of nested function calls is the following: (the numbers in the tags are the line numbers)

<100> var result_h1 = H1(b1); <101> var result_h2 = H2(b2); <102> var result_g1 = G1(result_h1, result_h2); <103> var result_g2 = G2(c1); <104> var a = F(result_g1, result_g2); 

I have recently changed to a department, where the following coding style is very much in use:

<100> var a = F(G1(H1(b1), H2(b2)), G2(c1)); 

The result of my way of coding is that, in case of a crashing function, Visual Studio can open the corresponding dump and indicate the line, where the problem occurs (I'm especially concerned about access violations).

I fear that, in case of a crash, due to the same problem, programmed in the first way, I won't be able to know which function has caused the crash.

On the other hand, the more processing you put on a line, the more logic you get on one page, which enhances readability.

Is my fear correct or am I missing something, and in general, which is preferred in a commercial environment? Readability or maintainability?

I don't know if it's relevant, but we are working in C++ (STL) /C#.

My coding style of 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, result_g2); 

I have recently changed to a department, where the following coding style is very much in use:

var a = F(G1(H1(b1), H2(b2)), G2(c1)); 

The result of my way of coding is that, in case of a crashing function, Visual Studio can open the corresponding dump and indicate the line, where the problem occurs (I'm especially concerned about access violations).

I fear that, in case of a crash, due to the same problem, programmed in the first way, I won't be able to know which function has caused the crash.

On the other hand, the more processing you put on a line, the more logic you get on one page, which enhances readability.

Is my fear correct or am I missing something, and in general, which is preferred in a commercial environment? Readability or maintainability?

I don't know if it's relevant, but we are working in C++ (STL) /C#.

Source Link
Dominique
  • 1.8k
  • 2
  • 20
  • 29
Loading