writing less code and going with the grain

Periodically we need to remind ourselves of good common sense coding practices. Two simple but very powerful are:

1. write less code

Sometimes the best solution is just to write less code. We need to think before implementing: how can I write less code? I may come up with an acceptable solution, but there may be a better solution with less code. Its possible my first solution is not the best.

A good time to do this thinking is before you get too far into an implementation. At a certain point you're too deep, too far along to easily change or reverse course. But even if you are, don't be afraid to change course, even if you may lose some time. Its still typically more efficient to change when building a feature than after its been released to production.


2. "go with the grain"

Systems are often built in a certain way and when we change those systems we should try to follow that way. Build on the existing architecture, on the current algorithm on existing conventions on how things are done.

"The phrase originally comes from woodworking, where "going with the grain" means working in the same direction as the wood's natural fibers for a smoother, more efficient result."

Now, obviously, sometimes we need to go against the grain and refactor because of various reasons (e.g. new requirements, wrong approach) and then we go against the grain. Part of our role is known when to "go with the grain" and when to "go against the grain". And also when it should happen versus all your other priorities.

 

Comments

Popular posts from this blog

angularjs ui-router query string parameter support

react-select stacking order bug, z-index, layers and stacking

typescript notes (typeof, keyof, ReturnType, Parameters, Extract)