Design Patterns

C

Christine Mayer

Does it make sense to use design patterns like the strategy pattern for
jave beans (as simple data containers) too?
Or maybe just inheritance? Or interfaces?
Or nothing at all, as we are just speaking of plain simple getter and
setter method classes?

Any idea, what serves best?
 
T

Tobias Schierge

Does it make sense to use design patterns like the strategy pattern for
jave beans (as simple d for a containers) too?
Or maybe just inheritance? Or interfaces?
Or nothing at all, as we are just speaking of plain simple getter and
setter method classes?

Strategy pattern targets instance behaviour, how to apply that to a java
bean? Maybe the best is just semantically correct inheritance, interfaces
are not useful most of the time as the beans cannot be instanciated by
reflection anymore, you need a factory. Most frameworks just call the
no-arg-constructor for model classes.

Regards,

Tobias
 
?

=?ISO-8859-1?Q?Martin_M=FCcke?=

Maybe the best is just semantically correct inheritance, interfaces
are not useful most of the time as the beans cannot be instanciated by
reflection anymore, you need a factory. Most frameworks just call the
no-arg-constructor for model classes.

> What means "instanciated by reflection?"

>Maybe the best is just semantically correct inheritance ....you need a
factory.

Simple inheritance, or factory?
Anyway, for beans that are just used once, there is no need for a
factory, imho.
>Most frameworks just call the
> no-arg-constructor for model classes.

what?


Anyway, what I also wanted to ask was, does it make any sense to make
a simple thing such as a Java Bean - consisting of nothing more then get
and set methods, more complicated by using inheritance, a pattern, or
whatsoever.

Using composition might help explaning and documentating the application,
like Animal.fur.getColor() instead of animal.getColor() -

but not sure if that really makes sense for getter methods.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top