About the basics of the OOP


EJB design: About the basics of the OOP

  1. About the basics of the OOP (2 messages)

    We should treat the system as objects according to the rule OOP.
    But there are entity objects , controller objects .
    why there are controller object ?
    For example ,
    public class User{
        private String name;

    We can put the add method in the User class, However few of the designers do it this way.

    Will be so kind show your opinion?
  2. About the basics of the OOP[ Go to top ]

    User object should NOT have an add() method. This is why...

    For example, I am going to bake a cake. To bake the cake I will need all of the cake ingredients (flour, water, eggs, sugar, chocolate, etc) I, the baker, will use an oven to bake the cake.

    Should a cake know how to bake itself? cake.bake() Or, should the baker know how to bake the cake? baker.bake(cake);

    It is better to treat the cake as a data container and to use a system object, baker to process the cake.

    In your example, I would have a controller add any new users,

  3. About the basics of the OOP[ Go to top ]

    Controller object demonstrate a weak aggregation,but entity object has a strong aggregation in them.

    A entity object is always a whole,Controler object integrate the entity object.

    All entity object doesn't have to know other entity object. but a controller has to know the entity object on which it will act.:-)).

    Thats the strong reason i think to seperate them.