You Need to Have an Outstanding Design to Write Awesome Code
Originally published by Ravi Shankar Rajan on August 28th 2018 If you design it right, it will last forever. Broadly speaking there can be six phases in every project · Enthusiasm · Disillusionment · Panic · Search for the root cause · Punishment of the innocent · Praise and honors for the non-participants The “search for the root cause” phase is very tiring and demanding especially when a project is doomed to fail. Here, we look back on projects gone horribly wrong and ask ourselves, “What happened?” We do a post-mortem and try to put together the broken pieces that will explain how we failed. And then we come up with valid reasons like. · Poor requirements (Client does not know what he wants!!!) · Poor Planning (our project manager screwed it up!!!) · Poor Management (Wish the CEO had shown more balls!!!) And the reasons go on……. Finally, we toss up a nice PPT, give “big assurances” for future projects, “shuffle” two or three resources out of the project and then majestically close that one painfully long fucking project to everybody’s “satisfaction.” But in the whole process of cover-up, we conveniently ignore the single most important factor that resulted in failure Managing Complexity. The software became so complex that it reached a stage where no one knew what it does. When any project reaches a point where no one completely understands how the impact of code changes in one area will impact any other area, we can rest assured that the project is doomed to failure. Sooner or later the project comes to a grinding halt. And a complex project gets created due to a stinking design. As Irene Au has rightly said. “Good design is like a refrigerator — when it works, no one notices, but when it doesn’t, it sure stinks.” And here are some of the wonderful design principles that helped me throughout my programming career. Create Consistent Abstractions Josef Albers rightly said. “Abstraction is real, probably more real than nature. “ Abstraction is the ability to engage with a concept while safely ignoring the finer details existing at different levels. We find and use abstraction everywhere in the real world. For example, when we refer to any object as a car, we automatically refer to it as a whole rather than breaking it into its individual parts like chassis, engine, brakes etc. In software terms, the need of the hour is to create powerful base classes that allow you to focus on a set of common attributes of a set of derived classes while ignoring the details of specific classes. Thus a good class interface is an abstraction that allows you to focus on the interface without worrying about the inner workings of the class. This creates a design which is simple and then easily decoupled. A great software design means abstractions created at the routine-interface level, class-interface level and package-interface level and this results in faster and safer programming. Hide the Implementation Details Len Wein hits the nail on the head when he says. “In general, shorter is better. If you can encapsulate your idea into a single captivating sentence, » Read More
Like to keep reading?
This article first appeared on hackernoon.com. If you'd like to keep reading, follow the white rabbit.