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();
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
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.
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)
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.
Mersi
alte sugestii aici
http://ronua.ro/CS/forums/thread/16366.aspx