Friday, April 01, 2005

pmutils update

Did some minor changes to pmutils today.

The previous version used to duplicate entries in the xml database when
‘pmsync’ was run multiple times. I had been lazy of fixing this since I
knew the obvious solution wasn’t the true solution. The obvious solution
was to make pmsync clobber all the xml databases and create them anew.
The unobvious and basically better solution, was to make it imposible to
enter an item with a duplicate id into any of the xml databases.

I had to do some refactoring, since I discovered I had the functionality
I needed already in db_core.py, just it was scattered around the place.
So I decided to once more put refactoring and test driven development to
test. I introduced get_info(), and get_all_info(), wrote the test
sections for them. I then modified list_info() and list_sub_info(), to
use the new get_info() and get_all_info().

Now, this is were I got tickled. All I had to do was make sure that the
TEST I had written for the old implementation worked properly for the
new implmentation, and boom. I didn’t even have to change anything in
any of the code that uses those guys… they just worked J

Ok nothing special, yeah I know, but if you’re not been using TDD and
Refactoring properly, and you actually start using it, coding becomes
soooo easy, it becomes fun once again.

If asked to summarize three important skills for a budding code slinger,
I’ll say:

1. learn advanced features of any language you’re using.

2. learn to hate unrefactored code, and refactor immidietly you see
such (point 1 above will help you with this)

3. learn to write and integrate Testing as a core part of your
coding. (This will make point 2 above easier to leave with)

ok… gtg.

2 Comments:

At Friday, April 01, 2005 9:18:00 AM, Blogger Mfoniso said...

Could you please explain what "refactoring" means and what it entails? Please be as detailed as you can.

 
At Friday, April 01, 2005 3:59:00 PM, Blogger Essien Ita Essien said...

ok.

i'll post a blog article on Refactoring as i understand and use it in my daily coding.

 

Post a Comment

<< Home