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.
After many delays due to a virus on my Windows XP computer and wasting time trying to fix it, then installing Ubuntu then trying to figure out why Eclipse kept crashing on Ubuntu (problem got fixed after running the update manager), I am very pleased to say that I have finally finished “Big Fingers Keyboard” – as you may have guessed it, it is a soft keyboard for people with big fingers…
I’ve learnt a lot developing this one – I have experimented with threads (though the feature using threads has been kept off v1.0 as too unstable at the moment), I have learnt how to develop a service instead of an application, and I have applied object oriented programming concepts. This is the first time I developed an app “thinking like an object” and while I am sure I have strayed back into the “thinking like a computer” territory from time to time, I am overall very happy with my experience.
On to my next Google Android app now, which will be a RSS reader… hopefully released sometime in May!
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…)