Programming tips

My rules, practices, tips

Please note, these are rules I use and apply. You may want to adopt them in your way. Only you rule your rules, not me :)

Simplicity
Simplicity is the key. Make things simple.
DRY
Don't repeat yourself.
Optimisation
  1. Do not optimise.
  2. Do not optimise, yet. (Cite from "Pragmatic programmer")
  3. Think and be pragmatic
Object Oriented
Use objects
Databases
Use real object oriented system, so don't use relational databases. The correct database choice is object database. The very correct choice is Prevayler
Use whatever fits your needs

AOP

JBossAOP
My favourite of AOP implementations. I've developed annotated AOP framework for persistence with Prevayler in background: http://patsystem.sourceforge.net

Good practices (XP)

Pair programming
Programming in pairs is just the best that can be done to IT project.
Two persons sitting in front of one PC are doing the same job. One of them writes the code, second thinks about the code.

Is this waste of money, is this waste of time? No. Quality is priceless.

Programmers keep an eye each other, they work faster, quality of their work is higher, the software written is just better than software written by two separate programmers.
..

XP vs RUP
  1. XP is about a client and his needs first
  2. second: it is still about the client and his needs
  3. XP is ready for changes
  4. XP takes smaller steps
  5. XP brings the system faster
  6. people are more important than the tools
  7. production cost is smaller
  8. XP is not "UML v99..", but it uses it
  9. ..
Tests
Unit testing
Simple said: "write tests to each single unit of code". Every separate piece of code should have the tests that test it. Everybody changing the code, should invoke the tests with every change. When implementing new function, run the tests before and after work, and make the tests always work.
Test-first programming
Just try to write test first, then code it. Impossible? It was my first thought also, but think about it again..
The test (without a code) mustn't compile! It just has to exist.

So, write the test as you would be somebody else using your code. Think what you need to use your code for, how do you expect the code will work, what will be results of using the code?
Write the code from higher level, take a little further look at the code.
Then write as many tests as you can. Check as many possibilities of using your code. Compare results of your code to expected values.
Then write the code. And step by step make more tests working.

Of course do it in pairs

Regressive tests
With help of Ant one would test his project with one "click". Then one could make some changes and then "click" again to check if everything works.

With Cruise Control one can do this automatically!

Tools
Almost all most popular computer languages have some software to maintain test processes. Framework for Java is called: JUnit

There are some steps made by IDE authors to help with test-first programming. Some modern programming environments, like: IntelliJ IDEA or Eclipse support test-first. It is for real and you can use it now. Just write code which uses non existing classes, methods, parameters and IDE will make skeletons for you.

Designed with CSS| Get Firefox!| | Opel Omega Forum|

Copyright © Tomasz Nazar 2007
Revision: $Id: rules.gtml 3768 2005-07-25 23:47:33Z nthx $