<pedrocorreia.net ⁄>
 

<Object Oriented Design Principles ⁄ >




clicks: 269 269 2009-01-27 2009-01-27 goto programacao myNews programacao  Bookmark This Bookmark This


Recently, I was asked which patterns and principles I would use in an OO-project.

As I started summing them up, I noticed the person who asked getting a StackOverflowException :) . Obviously, I had a lot to tell about the subject...
I'll add a description (I'll try to keep it short) to each one of them, but if you don't know the meaning, just read the papers, blogs, or books. I'll link to them (also check the titles, they may be links).

Feel free to add anything I forgot!


Single Responsibility principle (The S in SOLID principles)

This principle states an object should only have one responsibility. Why? So a class only has one reason to change. Why? Because when a class has several responsibilities, they become coupled. So? If you change one responsibility of the class, it could have consequences in the other responsibilities, so you have to retest all responsibilities.
It's a bit confusing in the beginning to recognize a responsibility. Uncle Bob says a responsibility within SRP can be defined as a reason to change. That should get you started!

Open Closed principle (The O in SOLID principles)

The OCP states that software entities, should be open for extension, but closed for modification. What? You should be able to extend a SE without changing it. Why? If you don't change it, you won't break it. You will only have to test what you extended. How? Abstract away the functionality that could be implemented in different ways. If you have calculations, create an interface ICalculation, and add an implementation per calculationtype. The consequence is, that your calculation is closed for modification (a calculation calculates something and that's it) but open for extension (if you have an addition, but also need a substraction, just add a class that implements ICalculation and you're done). This is also a perfect example of the Strategy pattern.



este é só um excerto do artigo, para aceder ao artigo completo, clique no link em baixo:
this is just a small excerpt from the article, to access the full article please click in the link below:

http://www.dotnetkicks.com/other/Object_Oriented_Design_Principles




Subscribe News RSS  Subscribe News Updates by E-mail





myNews <myNews show="rand" cat="programacao" ⁄>

Caching in ASP.NET (Part I)

The ability to store data in the main memory and then allow for retrieval of the (...)

clicks: 536 536 2007-04-04 2007-04-04 goto url (new window) sql-server-perf... goto myNews programacao


Create astonishing iCal-like calendars with jQuery

According to my web designer experience, one of the most common requests from cl (...)

clicks: 266 266 2009-11-23 2009-11-23 goto url (new window) stefanoverna.co... goto myNews programacao


The Ruby Conspiracy

Who are those who are benefiting from Ruby on Rails? Answer: O'Reilly Publishing (...)

clicks: 483 483 2006-07-28 2006-07-28 goto url (new window) gregluck.com/bl... goto myNews programacao


Saving and Retrieving File Using FileStream SQL Server 2008

FileStream data type is a very important feature of SQL Server 2008 and graduall (...)

clicks: 443 443 2009-03-16 2009-03-16 goto url (new window) weblogs.asp.net... goto myNews programacao


8 Useful jQuery Calendar, Date Picker and Time Formatting Plugins that You Should Know

jQuery is one of the most popular Javascript library. It's easy to use, flexible (...)

clicks: 593 593 2009-11-19 2009-11-19 goto url (new window) bloggingdevelop... goto myNews programacao


Making A Slick Content Slider

Web masters constantly search for ways to optimize the way content is presented (...)

clicks: 247 247 2009-10-05 2009-10-05 goto url (new window) tutorialzine.co... goto myNews programacao


Mastering Ajax, Part 2: Make asynchronous requests with JavaScript and Ajax

Use XMLHttpRequest for Web requests. Most Web applications use a request/resp (...)

clicks: 457 457 2006-10-12 2006-10-12 goto url (new window) www-128.ibm.com... goto myNews programacao


Singletons - we're better off without them

With the introduction of Actionscript 3 there was a lot of discussion about how (...)

clicks: 492 492 2007-01-24 2007-01-24 goto url (new window) bigroom.co.uk/b... goto myNews programacao