DEV Community

6 Principles For Better, Cleaner Code

Thomas De Moor on October 01, 2019

Bad code works until it's the year 2,000. Bad code is difficult to understand, more complex than it should be, not easy to test, and it makes other...
Collapse
 
catalinradoi profile image
CatalinRadoi

I am a huuuge fan of Uncle Bob and I believe that everyone should watch his course or read his book on Clean Code.

Just to give you a taste:

  • Names - always reveal your intent, write honest methods
  • Functions - a function should do one thing and it should do it well. They should be kept small.
  • Law of Demeter - avoid.Train.Wrecks.Like.These()
  • Aim for high Cohesion
  • Unit Tests ........................... I could talk for hours about clean code. Unfortunatelly, not everyone has "time" to listen.
Collapse
 
attkinsonjakob profile image
Jakob Attkinson

Where can one watch his course?

Collapse
 
tdmoor profile image
Thomas De Moor

Great list!

Collapse
 
attkinsonjakob profile image
Jakob Attkinson

Doesn't KISS stand for "keep it short and simple"?!

Collapse
 
oscarehrling profile image
Oscar Ehrling

I think "Keep it simple stupid" works better - since, sometimes - keeping it simple warrants more code.

Collapse
 
tdmoor profile image
Thomas De Moor

There are a few variations

Collapse
 
raxetul profile image
Emrah URHAN

This article tells us to leave Java.

Collapse
 
tdmoor profile image
Thomas De Moor

The hidden message

Collapse
 
metalmikester profile image
Michel Renaud

I love the cartoon in the article. The right side is basically me talking to myself the day after I write some code and then read it again. :D