refactoring

Am terminat cartea de Refactoring de Martin Fowler
(multumesc de 2 ori, Somalezule!)

Ce mi-a placut cel mai mult:

Introduce Null Object
 
if (customer == null) plan =
BillingPlan.basic();
else plan = customer.getPlan();
 
 
 
Ron Jeffries
We first started using the null
object pattern when Rich Garzaniti found
that lots of code in the system
would check objects for presence before
sending a message to the object. We
might ask an object for its person,
then ask the result whether it was null.
If the object was present, we
would ask it for its rate. We were doing this
in several places, and the
resulting duplicate code was getting
annoying.
So we implemented a missing-person object that answered a zero
rate
(we call our null objects missing objects). Soon missing person knew
a
lot of methods, such as rate. Now we have more than 80
null-object
classes
 



Separate Domain from Presentation
 
If you have a grid, create a class to represent the rows on the grid. Use a
collection on
the domain class for the window to hold the row domain
objects.
 

( asta cu griudul nu o faceam intotdeauna- se potriveste cu ce zicea Lhotka: ok to duplicate fields, not ok to duplicate behaviour)

2 thoughts on “refactoring

  1. Good choice!

    Alte recomandări, pe aceeași linie: Pragmatic Programmer (Dave Thomas, Andy Hunt), The Art of UNIX Programming (E.S. Raymond). Nu-mi imaginez nici un developer (cu atît mai mult un senior) care să nu fi citit acestea.

Leave a Reply to andrei ignat Cancel reply

Your email address will not be published. Required fields are marked *