Programming is something you do with LOVE, or better not do it at all!


The picture was taken by a friend during a few weeks of travelling in south America.

Programming is something you do with LOVE, or better not do it at all!

Today’s a good day to start!

I’m still not sure what I’m going to do with this space, probably share my thoughts about programming stuff, maybe add some cool code examples such as the following code to quick-sort in Erland:

qsort([]) -> [];
qsort([Pivot|Rest]) ->
qsort([Front || Front <- Rest, Front < Pivot])
++ [Pivot] ++
qsort([Back || Back <- Rest, Back >= Pivot]).

Now, here’s a small example of how NOT to write code, the example is in PHP:

public function pdf_read_root(){
   $this->root = $this->pdf_resolve_object( $this->c, $this->pdf_find_root());

This line of code is wrong. very wrong. Let’s see why:

    • Even if we don’t know why, the fact that $this-> appears 4 times in the same line should raise a red-flag!
    • Since pdf_resolve_object() is a class method, it has direct access to all the members so we shouldn’t pass class-members in the signature: pdf_resolve_object( $this->c, $this->pdf_find_root()).
  • From the same reason, this method does NOT require a return value, it can update$this->root inside the method and just return.
  • $this->c ? what about a more meaningful name ?
  • And last, why should we wrap this one line that calls to a method with another method that does nothing: pdf_read_root()?

To sum up, we can easily change this line to something much nicer, such as:


Ta-ta till next time.

Today’s a good day to start!