DEV Community

Discussion on: How did you break the habit of writing procedural code?

Collapse
etienneburdet profile image
Etienne Burdet • Edited on

I try more and more to start writing the higher level functions and/or top-level call first. So you force yourself into writing what your code should look like in the end, rather than where to start. And then you write the functions you would need in reverse order, writing the simplest, low level-utilities last rather than starting with state variable and mutating them little by little.

It's actually not that hard and I find myself writing much cleaner code from the start. If you want to test your higher level functions, just fake the lower level one to return basic string/fake object etc. before implementing real logic there. You might need to design stat beforehand too: pen and paper is still great for that :).

Collapse
jasterix profile image
Jasterix Author

thanks for the reply! Think I understand what you mean in terms of code challenges. But how would this work with a larger codebase with a language like c#?