Hacker News new | ask | show | jobs
by ctulek 2748 days ago
Hooks are interesting. We are reading about it and evaluating it.

However, I have a hard time in understanding why I should use all these tiny ‘use’ libraries? Hooks are already simple to implement such small snippets yourself in your codebase.

1 comments

Because it's reusable, you can apply it in more projects than one.

In another way, if a Hooks includes business logic, then it should be put in your project.

I disagree. That something is reusable is not enough for it to become a library. There should be other benefits, because, using an external library has its own drawbacks.
As someone who works for a popular consultancy that helps out developers at big companies and reviews their code: ANY library you can point people to and say "do it this way" is an absolute godsend.

You really do not want large numbers of developers, with varying levels of experience, trying to figure out how to do something that has already been solved, and making the same avoidable mistakes in the process – unless you are deliberately trying to teach them something at that moment (whereas most of the time they are just trying to get things done on a tight schedule).

The job of a developer is only secondarily to write code. The primary job is to fulfill the actual real-world needs of their business or organization. Customers don't want code, they just want their needs met. Unfortunately sometimes this involves barfing out a lot of code – which is more likely a liability, not an asset to the company. The more new code we can avoid bringing into the world, the better.

I agree that “do it this way” can be godsend. However, suggesting a library is only one of the ways. By suggesting all these tiny libraries, I don’t think we will mentor the less experienced community in the right direction.