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

The types in your code are just as designed just like any other aspect of it. It's not a matter of restraint, it's a matter of doing things on the correct way.


I don't believe in "correct" when it comes to software dev. There's 1000 solutions to any given problem.

It's a matter of choosing a solution that is clear, easy to understand, and easy to maintain. There are nearly limitless solutions that can fit that definition.

Restraint comes into play because devs tend to "treat every problem like a nail when they have a hammer". When devs learn new concepts, they often look for places to use that concept even when it's a bad fit.

An example of this is excessive use of inheritance when simpler types fit better. Many of us have dealt with the greenhorn that creates a giant inheritance tree or generic mess after they first learn that "neat" concept.


So less can be more but more can also be more, more or less?


Exactly. "More" and "less" are pretty much wrong ways to measure it.


I definitely know what you mean. There is usually a type that is "just right" in terms of rigidity and flexibility.

The reasons OP encourage restraint might be the mental overhead of understanding what's "correct", as well as needing to rely on not only yourself but other people to be correct.

Sometimes simple is faster and harder to screw up.


What's 'correct' from your point of view (as library implementer) may be 'overly complex and a hassle to use' from the library user's pov though.




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

Search: