Design: Single Responsibility Principle (SRL)
September 18, 2008
Every object in your system should have a single responibility, and all the object’s services should be focused on carrying out the single responsibility.
This is a simple test that can help to understood if an object violates the SRP.
For each method in your class write the ‘test phrase’:
The class_name method_name itself.
If exist a phrase that has no sense, probably your object is non SRP compliant and you need to refactor your design.
Advertisement
Il senso del codice quando letto con gli occhi del linguaggio naturale dovrebbe essere evidente, se non sempre perlomeno molto spesso. Una disciplina, chiamata Domain Driven Design, si occupa di questo aspetto del design software.
Dopo le letture degli scorsi anni e le prime scaramucce in pubblico (http://www.sviluppoagile.it/extreme-programming-e-domain-driven-design) terrĂ² un talk su questo argomento al prossimo International PHPCon a Roma. Se ti capita…
Ciao!
Se riesco vengo di sicuro a sentire…
Mi sto avvicinando ad Agile (in particolare XP) e la cosa mi iteressa molto…
Altrimenti ci vediamo all’ AgileCamp2009(http://barcamp.org/AgileCamp2009)