Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Novice Programmer: "Putting all this code in one function would be easier to write."

> Master Programmer: "You fool! You can't just stuff all your code into one function because it's easier to write!"

So the Novice Programmer separated all the code out into different functions and showed the results to the Master Programmer.

> Master Programmer: "You fool! Why have you broken this out into different functions when it all belongs together in the same function?"

And in that moment the Novice Programmer achieved enlightenment.



> achieved enlightenment

I haven't. What are you saying?


"And at that moment the novice achieved enlightenment" is the usual punchline for this story setup.

The message is that neither of the alternatives is correct all the time.


I believe that it means that some things aren't always very clear cut, and one could make a reasonable argument to do it either way.


The best I could interpret it is to have it both ways; break it down into small private functions, then nest (edit: encapsulate) these in a larger one where they can't be seen by anyone else.


Both and neither.

It depends on you and your team, the project requirements, the rest of the codebase, and so many other things. The choice you make is less important than _why_ you make it.


Maybe the western approach of actually giving useful information beats the zen approach of confusing the fuck out of people.


You’re going to hate reading this: https://www.mit.edu/~xela/tao.html


One should group functionality into a single function, not because it's "easier to write", but instead because "it belongs together"


Maybe that, no matter what you do, there will be always somebody telling you there's a better implementation for it.


I always took it to mean, "Don't put all the code into one function because it's easy, do it because it's logical."




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

Search: