Think Before Coding

To content | To menu | To search

Tag - Books

Entries feed - Comments feed

Wednesday, December 24, 2008

Data Structures and Algorithms

I had a peek through Jon Skeet’s blog this morning at a free eBook called Data Structures and Algorithms by Granville Barnett and Luca Del Tongo.

The book is clear and presents the usual linked lists, trees, sets structures in a concise yet precise way.

There’s something new I had not seen in other algorithm books before. The algorithms are written in pseudo code, but there is a chapter about unit testing your implementation.

If the writers read this, I just would like to share a little tricks that make linked list algorithms easier to write..

Linked list algorithms are always bloated with tests like this :

        if (head == null)

            head = ...;

        else

            node->Next = ...;

Actually the content of head and then content of node->Next are both pointers on next node. But the way to reference those two locations is different, ending in a lot of if statements.

If the language supports reference variables or pointer, you can use a double pointer to hold the current position :

Node** next = &head;

This way there is no more difference between the head (*next) and nodes Next pointers. The little tricky thing is to move to next location :

next = &((*next)->Next);

With this you can consider every ‘Next’ pointer including head as equivalent. No more if statement !

By the way, I was trying to find out how to do this on C#, but is it possible without going unsafe ?

Wednesday, December 10, 2008

Wow - Book review - Domain Driven Design!

Ok, I finished Domain Driven Design yesterday. I think I had no such Aha moment since I read Design Patterns eleven years ago...

I thought I was prepared for it, I had read many things to get maximum info...

I had :

I had practiced knowledge crunching on my own for long.

But the book go far beyond all that. It has a deep vision of programming on large scale projects, and give really good insight on difficulties that arise when working on complex systems with several teams. These are really precious pieces of advice.

The pattern presentation of the different chapters, even when those patterns are not implementation patterns but team organization patterns is really helpful and clear.

There is not much about implementation details, but it is not a problem. The principles are not tied to a specific technology or framework. Actually this is even a good point, it leaves the book clean from a specific implementation. Implementation books are aging faster.

You definitely should have this book on your shelf.