Hacker News new | past | comments | ask | show | jobs | submit login

If you open code every function that is used once, you lose functional decomposition, which can hurt readability.

If we have a linear process with a large number of steps, it can help to group them hierarchically via functions, just as a play is divided into acts and scenes.

Functional decomposition was once taught as an important technique in program design (related to the "top down" approach). I believe it still remains important.

Here is an example of a function called only once: a module initialization function. If we take the advice literally, we shouldn't have an init function that calls numerous other init functions one by one. Since they are called once, we should pull them all into that init function. Well, what is that going to do to the cohesion and coupling.




Imagine a program that only needs to calculate a single square root and inlines newtons method.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: