Wednesday, March 21, 2012
Time and time again, when I'm reviewing code of pretty experienced programmers, I'm still shocked how they're using Copy & Paste programming extensively instead of extracting common code to shared methods and classes. Visual Studio and many 3rd party add-ons tools make it very easy to make these refactoring that allows to avoid any duplication. But still – Copy & Paste is easier and that's what many programmers use by default. Frankly, I chose the title for this post just to tease. Clearly there's nothing wrong with the Copy & Paste feature of Visual Studio. The problem is...
Tuesday, November 1, 2011
This is the 6th post in the series about TDD and its relationships with the SOLID principles. Here’s the table of content for the series: Pat 1 – introduction Part 2 – SRP Part 3 – OCP Part 4 – LSP Part 5 - ISP Part 6 – DIP (this post) Part 7 – Conclusion DIP – Dependency Inversion Principle Depend on abstractions, not on concretions. This principle states that: A. HIGH LEVEL MODULES SHOULD NOT DEPEND UPON LOW LEVEL MODULES. BOTH SHOULD DEPEND UPON ABSTRACTIONS. ...
Saturday, October 1, 2011
This is the 5th post in the series about TDD and its relationships with the SOLID principles. Here are the links to the previous parts: Pat 1 – introduction Part 2 – SRP Part 3 – OCP Part 4 – LSP Part 5 - ISP (this post) Part 6 – DIP Part 7 – Conclusion ISP – Interface Segregation Principle “Make fine grained interfaces that are client specific” This principle speaks for itself… but anyway I’ll “translate” it… : It is better to create many small interfaces than...
Thursday, September 22, 2011
This is the 4th post in the series about TDD and its relationships with the SOLID principles. Here are the links to the other parts: Pat 1 – introduction Part 2 – SRP Part 3 – OCP Part 4 – LSP (this post) Part 5 – ISP Part 6 – DIP Part 7 – Conclusion The LSP (Liskov Substitution Principle) The principle (originally stated by Barbara Liskov in a more academic fashion), states that: FUNCTIONS THAT USE REFERENCES TO BASE CLASSES MUST BE ABLE TO USE OBJECTS OF DERIVED...
Wednesday, September 7, 2011
Table of contents:
Part1 – Indrocution
Part 2 – SRP
Part 3 – OCP (this post)
Part 4 – LSP
Part 5 – ISP
Part 6 – DIP
Part 7 – Conclusion
The Open/Close Principle
The Open/Close Principle states that:
SOFTWARE ENTITIES (CLASSES, MODULES, FUNCTIONS, ETC.) SHOULD BE OPEN FOR EXTENSION, BUT CLOSED FOR MODIFICTION.
This statement pretty much says it all, and naturally extends the Single-Responsibility principle: Classes (and functions, etc.) should be kept as simple as possible (having a single responsibility) and therefore should never have to change. Therefore, if you want to add functionality to your system you should add new code instead of changing existing one....
Friday, August 26, 2011
Table of contents: Part1 – Indrocution Part 2 – SRP (this post) Part 3 – OCP Part 4 – LSP Part 5 – ISP Part 6 – DIP Part 7 – Conclusion In the previous post I introduced the SOLID principles and their relation to TDD in general. And as promised, I’m diving into each of these principles and explain their relationships with TDD. The first principle, which I’ll be talking about in this post, is the Single Responsibility Principle or SRP in short. SRP is the...
Table of contents: Part1 – Indrocution (this post) Part 2 – SRP Part 3 – OCP Part 4 – LSP Part 5 – ISP Part 6 – DIP Part 7 – Conclusion Mastering TDD is a process that takes time. There are many pitfalls that “newbie’s” fall into. IMHO the following 2 reasons are the main ones: Thinking about the implementation before writing a test. That is, writing tests that are coupled with the implementation instead of with the problem...
Wednesday, March 30, 2011
Recently I listened to show #640 of .Net rocks on which Carl and Richard talk with Gael Fraiteur about PostSharp and AOP in general. In the past I heard about AOP (Aspect Oriented Programming), but it was in the context of AspectJ which is for Java, and in general it appeared to me more of an academic or esoteric thing rather than something I really like to try and even actually use it. But that show raised my interest in that subject a lot and so I took a look at the PostSharp website which contains very clear explanations...
Tuesday, December 28, 2010
Did it ever happen to you that you hit a problem that you couldn’t solve, and even you’re convinced that it’s impossible, but then just by telling about it to someone you find the solution? I’m sure you did, it happens a lot. A boss I once had used to call this phenomenon “talking to a glass of water”: it would as well be a glass of water that you’re talking to for finding the answerJ
Anyway, the reason I’m talking about this phenomenon is that I started to write this post with the following title:
Frustrating limitations of C# with...