Re: AW: How to avoid code duplication on forms?

2009-05-11 Thread Vladimir K
Factory pattern is about Dependency Inversion Principle. You may use this pattern to avoid dependency to concrete classes. So the best way in your case is having Factory that constructs concrete editors via subclassing. They work best together :) Christian Helmbold-2 wrote: > > > I think the

Re: AW: How to avoid code duplication on forms?

2009-05-08 Thread Jonathan Locke
uh that was: class EmailField extends TextField[Email] where the square brackets are angle brackets :) Christian Helmbold-2 wrote: > > > I think the difference between sub classing and static factory methods is > a matter of taste in this case. > > If I have many fields, I'd need many clas

Re: AW: How to avoid code duplication on forms?

2009-05-08 Thread Jonathan Locke
the advantage to subclassing is that you're working better with the type system whereas static pulls you out of the object world and should be used with great caution. for example, subclassing enables more subclassing and therefore more reusability. static factory methods cannot be specialized.

Re: AW: How to avoid code duplication on forms?

2009-05-08 Thread Jonathan Locke
the advantage to subclassing is that you're working better with the type system whereas static pulls you out of the object world and should be used with great caution. for example, subclassing enables more subclassing and therefore more reusability. static factory methods cannot be specialized.

AW: How to avoid code duplication on forms?

2009-05-08 Thread Christian Helmbold
I think the difference between sub classing and static factory methods is a matter of taste in this case. If I have many fields, I'd need many classes for them. So I'd group them in a sub package. In the case of factory methods I'd group the methods to create fields in a class instead of a pac