Live Long and Prosper: Apply Four Simple Programming Principles
Mar 17, 2015
Any application that is critical to running the mainstream operation of a business can be considered a mission critical application. These applications should be sustainable, maintainable, flexible and adaptable to keep up with the pace of today’s evolving nature of business. “Change is the essential process of all existence.” — As aptly stated by Mr. Spock in Star Trek: The Original Series.
As architects or developers involved in these types of software projects, it’s important to realize that software design and development often ends up following one of these two extremes: over-engineering or under-engineering.
Over the years, I’ve designed, developed and reviewed many software projects and have always found areas or specific pieces where the software was either too complex or such, where simplicity, bad habits, business rush or developer turnover had led to a messy situation.
If you can’t explain your code to someone else in a minute or two, then you have made the code too complex.
So, how can we avoid such problems? Here are four principles that can help address these issues:
KISS
The Keep It Simple Stupid (KISS) principle states that most systems work best if they are kept simple.
Unnecessary complexity should be avoided.
You should try to solve the problem in the simplest way you can. Ask yourself or your team: Do we really need to build the USS Enterprise or can a helicopter do the job?
DRY
Don’t Repeat Yourself (DRY) is a software development principle, aimed at reducing repetition of information of all kinds.
Many of the projects I review, have repeated codes throughout the program. When a bug fix, update or new feature is needed, developers are forced to search the entire code base to find any occurrence and make the required changes.
Therefore, a software, designed without the principle of DRY in mind, is harder to maintain and less flexible; which in turn increases the time to market.
YAGNI
You Aren’t Going To Need It (YAGNI) is a principle of extreme programming (XP), which states that a programmer should not add functionality until deemed necessary.
Write the minimum code necessary to solve the problem.
Start out by developing software that does just what is needed and nothing more; but make sure that the code is extensible, so that adding onto it does not become a problem.
SOLID
SOLID is a mnemonic acronym for the following five basic principles of object-oriented programming and design: Single responsibility, Open-closed, Liskov substitution, Interface segregation and Dependency inversion.
A software designed and developed with these five principles, applied together, should be easier to maintain and sustain over time.
Depend upon Abstractions. Do not depend upon concretions.
To wrap up, keep your code DRY, design and develop only what is needed (YAGNI), embrace a KISS state of mind, work with rock SOLID principles and your mission-critical business applications will Live Long and Prosper.
“Live Long and Prosper.” — Spock, Star Trek: The Original Series
Blog contributed by Carlos Mendible ( Ex-SogetiLabs Member & Sogeti Employee)