The Open-Closed Principle

Do przeczytania...


Hmm... tego nie znałem... Ja niemal zawsze używam protected. No moze poza wyjątkiem memberów synchronizujacych (sekcje krytyczne).

Make all Member Variables Private.
This is one of the most commonly held of all the conventions of OOD. Member variables
of classes should be known only to the methods of the class that defines them. Member
variables should never be known to any other class, including derived classes. Thus they
should be declared private, rather than public or protected.
In light of the open-closed principle, the reason for this convention ought to be clear.
When the member variables of a class change, every function that depends upon those
variables must be changed. Thus, no function that depends upon a variable can be closed
with respect to that variable.

0 komentarze:

Prześlij komentarz

Tomasz Kulig