4 ms·
Yes, especially where he goes completely overboard creating extremely small functions. Most of them are, like, 2 lines.... The general point that code should b
by cjfd 6y ago
Yes, especially where he goes completely overboard creating extremely small functions. Most of them are, like, 2 lines....
The general point that code should be clean is a good point to make. Writing a whole book about it seems a bit much.
- nojito 6y ago>Yes, especially where he goes completely overboard creating extremely small functions. Most of them are, like, 2 lines.... Yup which is why we have millions of npm packages that do literally one thing.
- capableweb 6y agoTwo completely different things. A npm package is a module of code. A function is... A function. Having a lot of small functions is helpful as it builds up a vocabulary in the codebase, so instead of having to understand every single line each time you come across it, you can extract the meaning into a name. What the npm ecosystem is doing is a completely different thing.
- nojito 6y agoExcept the vast majority of npm modules are literally one function. There’s no difference between module and function when you see that.
- dunefox 6y agoYes, those are completely different because I do not release small functions that I compose to bigger functions as separate libraries to be pulled in by the hundreds.
- gmfawcett 6y agoThe parent's claiming a near 1:1 ratio of modules to functions in NPM. What does that have to do with your release process?
- inertiatic 6y ago>so instead of having to understand every single line each time you come across it, you can extract the meaning into a name. Until you really have to understand what is going on, like when you need to fix a bug or refactor. Then suddenly you to deal with the overhead of holding the branches of 20 levels of indirection in your working memory. Also, this assumes the people you're working with are great at naming things. Which, from my experience, is almost no one.
- capableweb 6y agoIn general, we have higher-level programming languages so we can do just this, hide the complexity under indirection. It's basically the purpose of the languages we tend to use today, otherwise we would all be still using assembly. Your job as a programmer is being able to walk this ladder of indirection up and down until you find what you seek and fix/add/remove whatever. You'll always be dealing with way more than 20 levels of indirection when programming, even with a "hello world" program. If adding two more levels of indirection makes your mental model break down, you might consider upgrading your environment/workflow a bit to support this. Regarding naming I agree with you. Good names are really, really, really hard to come up with. Entire books have been written on how to name things. Doesn't excuse us from trying though, the only way we can get better is by doing.
- tchaffee 6y agoThat claim doesn't even pass a simple common sense test: why would Node.js developers be so much more influenced by Bob Martin (of object oriented and Java fame) than developers in other languages? And it's not even entirely true. You can see that the top ten depended upon packages [1] in npm are the opposite of "literally do one thing". They are either full blown libraries like React or collections of related functions. I'm not claiming npm does not have a problem with too many one liner functions. But the most popular packages do avoid this practice, which is encouraging, and sets the bar for what you should do if you want to be at the top. What other motivations could there be for being the author of many very small and popular npm packages when it comes to interviews and internet fame? There are probably a lot more reasonable answers than "influenced by Bob Martin". [1] https://www.npmjs.com/browse/depended https://www.npmjs.com/browse/depended
- nojito 6y ago> But the most popular packages do avoid this practice, which is encouraging, and sets the bar for what you should do if you want to be at the top. https://www.npmjs.com/package/is-promise https://www.npmjs.com/package/is-promise 7 million downloads a week is not "popular" to you? npm is riddled with packages like these.
- tchaffee 6y ago> I'm not claiming npm does not have a problem with too many one liner functions. But the most popular packages do avoid this practice, which is encouraging, and sets the bar for what you should do if you want to be at the top. Just put my claim back in context, with an emphasis on the first sentence and you've got your answer.