Monday, February 3, 2014

Did a presentation on SOLID

This week I did a presentation on the SOLID principles with my colleague Ivar. For all that don't know the SOLID principles: it's 5 basic principles for Object Oriented Programming that make code more maintainable. Every letter within SOLID stands for a principle, so we have:

S for Single Responsibility
O for the open-closed principle
L for the Liskov Substitution principle
I for the Interface Segregation principle
D for Dependency Inversion principle

Go read up on this if you haven't done so: http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)

My idea of the demo was to take a piece of code - this piece of code - taken from CodeCrap.com and refactor it according to SOLID.



I wanted to do live coding on stage, but I was affraid that that might be a bit too ambitious since then I would have to talk, and code, and keep things interesting at the same time. So what I did was create a GitHub repo and separate branches for each of the stages of the refactoring.

Github for windows allows me to switch branches very quickly so what I did was do the whole refactoring, making sure everything worked at every step. Branched off whenever I had reached one of the principles and during my presentation, just switch between branches.


So I could DEMO live code, work with it a little, but then moving on without having to worry about weather the next step would build or not.

My lessons on the other hand for next time are: think even better about what you want to demo and come up with clearer and better examples.

Here's a link to the repo - and like I said, it's all in the branches: https://github.com/jochenvanwylick/201401_solid_demo

No comments:

Post a Comment