Indecent Exposure

Prev don't be afraid of buying books Next

This smell indicates the lack of what David Parnas so famously termed "information hiding" [Parnas]. The smell occurs when methods or classes that ought not be visible to clients are publicly visible to them. Exposing such code means that clients know about code that is unimportant or only indirectly important. This contributes to the complexity of a design.

The refactoring Encapsulate Classes with Factory (80) deodorizes this smell. Not every class that is useful to clients needs to be public (i.e., have a public constructor). Some classes ought to be referenced only via their common interfaces. You can make that happen if you make the class's constructors non-public and use a Factory to produce instances.

Amazon


Refactoring to Patterns (The Addison-Wesley Signature Series)
Refactoring to Patterns
ISBN: 0321213351
EAN: 2147483647
Year: 2003
Pages: 103

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net