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
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
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.
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.
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