For those following along, the next installment of my DimeCasts.net contribution, Refactoring to a SOLID Foundation, has just been posted to the Dimecasts.net site.
In this installment we investigate the Liskov Substitution Principle of S.O.L.I.D. as it applies to improving the flexibility and extensibility of our code sample.
The code sample for this installment can be downloaded here.
Happy viewing~!
Once again, a good work, very instructive and clear.
Thanks,
Steve,
can you post the source code for all the series “S” “O” “L” “I” “D”
i knwo you have done so far L but it will benefit if you have source code attach to it.
thanks a lot.
@Kris-I:
Thanks for the feedback; glad you are enjoying them.
@Nisar:
In response to your request, I have updated the posts on my blog (including this one, see above) for each of the now-released installments to include links to a ZIP file containing the code used in each of the screencasts.
For convenience, here are the links to each of the two other posts (in addition to this one) that also now contain links to their related code downloads…
http://unhandled-exceptions.com/blog/index.php/2009/02/26/solid-screencasts-gimme-an-s/
http://unhandled-exceptions.com/blog/index.php/2009/03/05/solid-screencasts-gimme-an-o/
Hope this helps,
-Steve B.
thanks Steve 🙂
Steve:
i have a question
what is the purpose of creating a Abstract class and expose a Print() method?
please bare with me here, you could have done something with the interface correct?
so if have a another method say PrintAs() (just assume) so i go back to abstract class and add
abstract void PrintAs() ?
thanks.
@Nisar:
I think its safe to say that there are several (at least) ways to evolve that (very) simple codebase used in these screencasts. The intent of using abstract base classes intermixed with interface declarations was to give people who favor either a good understanding of how the three all can cooperate together in a relationship between effectively decoupled classes.
In my experience, some devs favor interfaces and other favor (abstract) base classes, but its important to understand that ALL of these are in your OO design arsenal for good reasons. The entire design used in the screencasts could easily have been done using *either* interfaces *or* abstract base classes with the same net-effect.
In my mind, the point was at least partially about showing how you can introduce some of these patterns and practices into a code-base without making hugely-breaking changes at any one point. By evolving the solution from tightly-coupled classes to shared base classes and eventually to interfaces, the hope was that people would see the evolution of the code base away from its beginnings and into its eventual form in a manner that didn’t all at once render the code completely uncompilable/unusable but instead allowed the viewer to follow along with the whole process, seeing how any one of these changes really represented just a minor ‘tweak’ to the code that let it all continue to build (and pass most unit tests if they had been written alongside this code).
Clearly, with such an incredibly simple code base as is true of this sample, it would have been very easy to really rip the whole solution into pieces all at once in order to recompose it into a better final form all at once instead of showing how this can be done incrementally, but the hope is that if you imagine this same process on a more complex/larger code base, then approaching it in an evolutionary rather than revolutionary manner becomes understandable as an approach.
Hope this clears things up a bit in re: my focus while recording these.
-Steve B.
Steve,
Thanks for putting together the great videos. They’re a really great asset.
However, the “L” video is no longer working. Would you be able to re-upload this video? A lot of people, myself included, would really appreciate it.
@Makoto:
Interesting — no idea what might be wrong there with the Dimecasts link. I will take a look when I get home this evening and see if I can drum up the original screen-cap. I’m sure I’ve got it somewhere (safe)!
-Steve B.
@Makoto:
Just to let you know: although its taken some time to get this fixed, the link on the Dimecasts.net site is now fixed and should be working again (for all the screencasts in the series).
-Steve B.