<pedrocorreia.net ⁄>
 

<Object Oriented Design Principles ⁄ >




clicks: 368 368 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" ⁄>

A Collection of Examples of 64-bit Errors in Real Programs

Our company OOO "Program Verification Systems" develops a special static analyzer Viva64 that detect (...)

clicks: 22 22 2010-09-03 2010-09-03 goto url (new window) gamedev.net/ref... goto myNews programacao


Don't Rely on Environment.ProcessorCount

One of the most hidden knowledge in multithreaded programming is the question "How many threads I sh (...)

clicks: 53 53 2010-09-02 2010-09-02 goto url (new window) blog.liranchen.... goto myNews programacao


Ajax Best Practices: Reduce and Aggregate similar XHR calls

My mobile contract is expiring soon, so I went online and checked the different mobile companies for (...)

clicks: 43 43 2010-08-31 2010-08-31 goto url (new window) blog.dynatrace.... goto myNews programacao


A Guide to Writing Games with QML

My last post on QML had a lot of people asking for an example, as opposed to a general discourse. In (...)

clicks: 53 53 2010-08-31 2010-08-31 goto url (new window) labs.trolltech.... goto myNews programacao


Why jQuery needs JavaScriptMVC

More than a year and a half ago, I begged the jQuery community to start taking seriously the challen (...)

clicks: 55 55 2010-08-30 2010-08-30 goto url (new window) jupiterjs.com/n... goto myNews programacao


The Ultimate Roundup of 55+ CSS3 Tutorials

CSS3 is something that will take web development into the next level, while modernizing the web and (...)

clicks: 50 50 2010-08-29 2010-08-29 goto url (new window) 1stwebdesigner.... goto myNews programacao


Beginning PHP: 6 Must-See Sites, Programs and Articles For New Developers

These days there's a wealth of information online for anyone wishing to learn a new programming lang (...)

clicks: 72 72 2010-08-29 2010-08-29 goto url (new window) divisionbyzero.... goto myNews programacao


Quick Tip: An Introduction to Sammy.js

You've been seeing it for a while now with Google's Reader, Gmail, and most recently, on Facebook. P (...)

clicks: 49 49 2010-08-28 2010-08-28 goto url (new window) net.tutsplus.co... goto myNews programacao