My department is about to make some new hires. They are likely to be a) junior or b) more experienced that myself.
This year I have helped some C engineers transition to C# and observed some interesting code structure being written. I wish to learn more about why they are doing it, if I should encourage 'my way' and what the pros and cons of each are.
The problem
Lets assume Some Process with 4 steps, A > B > C > D.
The C engineers have been writing it like this;
SomeProcess()
{
A();
}
A()
{
// do A
B(parameters);
}
B()
{
// do B
C(parameters);
}
C()
{
// do C
D(parameters);
}
I write it like this
SomeProcess()
{
A();
B();
C();
D();
}
The reinforcement I have for 'my way' is this:
- It is clearer what is happening as the code reflects the documentation
- The stack is smaller
- The top level composition allows the functions to be used in other processes, e.g A > C > B
- If the process has a return value, I can change the return type in only a few lines (this is pretty minor)
Question
I wish to present some objective learning in this area.
Why would the other engineers be writing this structure? Are there any downsides to 'my way'?
B
). Perhaps that is that an omission or maybe you are suggesting something. Also, what does the error handling / error path look like in the two different approaches? These are some reasons more content/context is needed for a quality answer.