Cogitas Blog:
Google Android,
Common Lisp,
programming
and web design.

Top 5 object programming commandments

Filed under: programming — Tags: , , , — May 16, 2010

This is my list of coding & design principles I remind myself of whenever I feel coding my app is getting too complicated. Essentially, this list helps me apply the principle of orthogonality.

1. Stop repeating yourself – reorganise your object(s) so that you don’t find yourself copying/pasting chunks of code.

2. What does your method do? If it does 2 things, it should be 2 methods.

3. Private is good – you wouldn’t show your underwear to anybody in the street, don’t show your variables and methods unless you have to.

4. Isolate your constraints – keep them all in a method called “initialise()”, which you can call from your constructor (or from onCreate() if you’re programming from Android).

5. Isolate your input & output methods – do not add any logical app code to them, only input/output processing code specific to the input/output media you have chosen. This way, you can easily add that “save to file” functionality later on.

Object thinking

No book has had as much impact on my programming as Object Thinking (by David West) (aff.).  I still like to refer to it and I often read the notes I have made from it, I almost think of it as a Philosophy book, that’s how much it has affected me.

Over the coming weeks, I will explore why I am convinced that “thinking like an object” will help your programming, with both practical and more philosophical posts. For this first post, I will write a quick introduction to the subject.
(more…)