Skip to main content

On Purposeful "Laziness" - Best Practice

Being a software engineer, some purposeful "laziness" actions are considered best practice techniques - no joke.

Let me ask you a few questions to bring this topic into clarity:
  • Do you like writing the same code in different places, and having to remember to change the code at each location if some workflow/data changes?
  • Do you like to add the same fields/methods across all similar java classes, and every time you need to create a new similar java class? Then change each one if workflows/data requires it (e.g. data type)?
  • Do you like to download lots of different 3rd party jar files, from multiple sites, to add to your project(s) capabilities and standardizations? Or better yet, maybe you like to reinvent the wheel and create custom classes other than use well-tested, peer-reviewed classes.
If you said yes to any of those, please research reasons for code refactoring, best practices for polymorphism, interface and abstract class use, and use of dependency management/build management tools (e.g. maven, gradle), respectively.

Purposeful "Laziness", in regards to software engineering (and my love - java), is basically the best practice execution of not writing thousands of lines of unnecessary code, so that I can completely my tasks in a more efficient way. I quote "laziness" because its not really being lazy - its being smart about coding in an efficient manner. For example, if I find that a certain group of code is required in more than one location, I'm not going to copy-and-paste. Nooo....Can you imagine the maintenance nightmare a few years down the line?? Instead, I'll pop that code in a central helper/utility class so that it can be used anywhere it's needed.

Superclasses, Interfaces, and Abstract classes are a great way to help set expectations on other classes that extend or implement them. If all subclasses of Aircraft needs to have wheels, be able to fly, a way to accelerate, land, and takeoff, why create individual Aircraft-type classes, with no hierarchical contract, when you can create an interface Aircraft and expect certain methods to be overriden, based on the types of aircrafts that is being created - e.g. single-propeller, double-propeller, jet, helicopter, etc. This saves time in creating new aircrafts since expectations are known from the get-go.

Taking a peek in the library of external dependencies in one of my projects, I counted about 80 jars, before I lost interested in counting further. Yikes! I cannot imagine having to manually download each one of those, from different sites, and also maintain them if we ever have to go through updates. It would take hours, if not days, to do this. Technologies such as Maven and Gradle make this task purposeful "laziness" to the MAX. They also help with build automation on top of that! Go check them both out if you're looking for help with gathering external dependencies, testing project code, and packaging code for server deployment or distribution.

Other than the examples stated above, you can take purposeful "laziness" to other parts of your development environment, such as the right IDE, a package manager for your system (e.g. homebrew), a helpful terminal (e.g. iTerm2), spring boot (helps with creating standalone applications "that you can just run"), and a version control system (e.g. svn, git). Anything that helps promote your ability to code efficiently and create quality applications in less time, that purposeful "laziness" is a requirement in my opinion.



Comments

Popular Posts

On Working On A Passion through Sourdough - It's All In The Details

"Working hard at something you don't believe in is called stress. Working hard at something you do believe in is called passion" - Simon Sinek Java programming is one of my passions, and has been for the last 15+ years. I have a few other passions - like gardening, baking, crocheting, and knitting - but Java has been a solid feature in my life, one way or another. In April of this year, as a pandemic started to rear its ugly head, I was offered an opportunity to grow another passion - a sourdough starter. My past credentials for bread-making have been dabbling in yeast breads, with the active dry variety, and quick breads; I have never worked with wild yeast. I realized an ember of passion was lit in me at the very beginning when I spent hours researching about sourdough starters the day before I was going to pick it up - what is it? how do I keep it alive? how do I make bread out of it? Will it attack me at night? By the time I had the starter in my hands, I had a recipe...