DEV Community

Discussion on: How do you order your functions?

Collapse
konstantinklima profile image
Konstantin Klima

Uncle Bob says we should order our functions by abstraction level and I've found that I like that approach best, as the code reads like a book.


function doSomething() {
    readInput()
    writeOutput()
}

function readInput() { 
   lowLevelImplementation()
}

function writeOutput() {}

function lowLevelImplementation() {
    ...
}
Enter fullscreen mode Exit fullscreen mode
Collapse
aralroca profile image
Aral Roca Author

Yep! I like it. This is clear to read

Collapse
ben profile image
Ben Halpern

This is how I do things

Collapse
deebeast profile image
Deepak Vishwakarma

I really like what is suggested . It's one of the key concepts of functional programming too.

Collapse
patarapolw profile image
Pacharapol Withayasakpunt • Edited on

About Uncle Bob, it seems that he is quite famous -- duckduckgo.com/?q=Uncle+Bob (the search engine suggested it correctly, without any programming-related keywords)

Collapse
konstantinklima profile image
Konstantin Klima

He is considered THE authority on clean code and best practices by a lot of developers and computer scientists and his books constantly appear on must-read lists for developers.
AFAIK, he is the one who originally put together the SOLID principle rules and is one of the creators of agile development.
I also love his writing style, very enjoyable to read ^^

Collapse
darkwiiplayer profile image
DarkWiiPlayer

Yes, he even wrote one of the things in "97 Things Every Programmer Should KNow", which is probably the book title I throw around by far the most (It really is a gold mine though)

Collapse
etienneburdet profile image
Etienne Burdet

This is what suits the most to. It's much easier to read lower-order functions once you know where they will be called, while most of the time it's fairly easy to infer what they do by their name.

Collapse
nilia1972 profile image
nilia1972

Yes, it is clear and simple.