types of coders – clean code

On all these years (about 20) working with many developers, with different styles of coding and different languages, I saw people doing some strange and funny things, also some bad and good practices.

beyhond-comprehension

After a lot of time dealing with these kind of developers I had the chance to read a very nice book called Clean Code which have many suggestions about how to write a clean and readable code with contribution of some great names of the development history like: Bjarne Stroustrup, inventor of C++, Kent Beck’s author of Implementation Patterns, Grady Booch, author of Object Oriented Analysis and Design with Applications, Dave Thomas, founder of OTI, godfather of the Eclipse strategy, and others.

clean-code

After reading that book I always keep an eye on my code to keep it as clean as possible, and also, I remember all that weird codes from the past that I would like to list below:

  • The never grows developer:
    • When we start learning how to develop, we always have some sample code like x = y + 1 or i++, but these are only samples for the beginers and does not mean that the developer should continue to use x, y and i as constant and variable names.
    • Also, the never grows developer, always try to use the same functions and procedures to solve modern problems which probably already have a function or some kind of library to do that;
  • The no indent developer:
    • This comer from the newbies developer which does not have indentation on code, believe it still happens, specially these days with script languages where everyone tries to put everything in just one line;
  • The no comments developer:
    • This one never puts a comment in the code, even if the code looks like:
      function calculate (p, y, v) {
      return ((p+y*v)^3 ? true : 0);
      }
  • The comment all developer:
    • This one is also so bad as the no comments developer:
      function save (userName) { // functionsave the user name
      var name = userName; // get the user name paramenter
      saveToDatabaseFunction(name); // save the name on database
      result true; // always return true after saving
      }
  • The no-name vars:
    • This kind of developer likes to solve the problem without worrying about who will come after him/her:
      test = array();
      x = (s>0 ? s : 1);
      for (i=0; i++; i<=x){
      test[i] = x*2;
      }
      test ? x ? i?
  • The all-in-one file developer:
    • This one does not worry about the classes names or the structure of the project, this developer only creates a file called functions or util and add code and functions and classes there.
  • The economic developer:
    • This one still thinks that our computers have only just 640K of memory or that our internet bandwidth is about 9600bps. This developer usually tries to do all in just one line:

      if (getContentFromForm() + (X[j]+X[i]) * (Y[j]-Y[i]) > 0 ? (Xj Yj - Xi Yi) + (Xi Yj - Xj Yi) : Xj Yj - Xj Yi + Xi Yj - Xi Yi)){ result (Y[j]-Y[i]); }

Many strange things came and I believe that many more will come. Until there I keep reading and practicing to do the best that I can.

Do your best also, maybe we will read our code.

Advertisements