DEV Community

What is your single most important rule for good software design?

Hagai Luger on December 10, 2018

If you had to choose just one rule that you think is the most important rule for good software design, what would it be?

Collapse
 
ali_soow profile image
Alioune Sow

This is a hard one, but if I have to choose it would be : Seperation of Concerns. It would void spaghetti code effect, improve readability, navigability and hopefully testability. And these, I believe, are at the core of clean code/design.

Collapse
 
ben profile image
Ben Halpern

Always leave the campsite cleaner than you found it.

When you pop in to fix a bug or plop in some code, take it as a chance to improve the code, add tests, etc.

I think ongoing habits matter more than rote architecture ideals.

Collapse
 
anortef profile image
Adrián Norte

Listen to the unit tests.

A unit test should be very easy to write in no more than 3 or 4 lines. If more, you probably have coupling but don't go overboard or your classes will lack cohesion!

Basically: a unit test should be easy to write on a couple of lines but be on the lookout to ensure that your class have meaning.

Collapse
 
jamesmh profile image
James Hickey

Be explicit.

I've seen too many times things abstracted to the point where things just get too generic and you have no idea what's happening.

Honestly, I'd rather see the "same" non-business critical code duplicated then have to dig down through 5 levels of inheritance why dynamically generated methods on a class (yes, I had to refactor this kind of monstrosity in the last year! 😂)

For example, if your business has a rule that blog posts shouldn't have more than 10000 words per article, then a class called ArticleHasLessThan10000Words would be very explicit and easy to understand what it does.

I find this happens when we focus on the business aspect of what we are trying to solution vs. the technical "how"

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

Less is More.

This can be applied to any aspect of software design. Reducing complexity in code makes it easier to understand; cutting out unnecessary features can make the program easier to use for customers, even removing useful features, and putting them in their own project can often improve the user experience for more advanced users who might only need one aspect of your product (While you can still provide a wrapped up version for those users who just want a monolith that gets every job done).

This principle can also be applied to many other aspects of life, from the way we think about material wealth to how much salt we put in our food.

Collapse
 
sublimemarch profile image
Fen Slattery

People come first. The code you write should always ultimately serve the people who will use the product. If you can't think of how your work will help the end-user, take a step back and think about it.

Collapse
 
yaser profile image
Yaser Al-Najjar

Three rules: SRP, SRP, and more of SRP 😁

Collapse
 
buphmin profile image
buphmin

Can you explain it? If you can't explain it then don't do it.

Collapse
 
idanarye profile image
Idan Arye

Be aware of the drawbacks of what you choose, the benefits of what you didn't choose, and the meaning of all these in your specific project.

Collapse
 
schreiber_chris profile image
SCHREIBER Christophe

Write it like if you were the one who's going to read it in 10 years.

Collapse
 
fpuffer profile image
Frank Puffer

KISS

Collapse
 
maestromac profile image
Mac Siri

^ This. Try to keep thing simple THEN work from there.