Information générale
Catégorie:
Codage, syntaxe et commandes
This was my first thought. My feelings about OO encapsulation are this: No class definition should reference an object NOT in teh class.
In other words, I'll use a real example. I commonly use OK, Cancel, Apply buttons. They ALWAYS do the same thing, so why code them? They generally line up the same way on every form, too. I made each button a class that does what it needs, then a container class with all three buttons. I now add my Buttonarray class to forms, and i'm done.
I think correct encapsulation should ensure that any object (with some exceptions, that we handle specifically as abstract classes) should be able to be instantiated by itself, and not rely on other objects it does not contain.
Just my thoughts after much ponderance on OO.
>One way of doing this if you've got a group of controls that need to function together is to put them in a container. They can talk to each other using this.parent.AnotherControl. The container becomes the place to put common methods so the controls can just call a this.parent.Method() to get stuff done. So this whole thing becomes a functional component that can just be dropped onto something else a form, page or other container.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement