Problems? Is your data what you think it is? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hello Arunbear, Thank-you and ++ for an excellent post! I think it would make a useful tutorial. It might be a good idea to add a little information up-front on why encapsulation is a Good Thing. First, you could note that: encapsulation is one of the four fundamentals of OOP (The others being abstraction, inheritance, and polymorphism.) Then, you could use the following quote from Scott Meyers (one of the gurus of C++) to show why encapsulation is valuable: Encapsulation is a means, not an end. There’s nothing inherently desirable about encapsulation. Encapsulation is useful only because it yields other things in our software that we care about. In particular, it yields flexibility and robustness. That’s an article I would recommend to anyone interested in OO. Finally, you should perhaps point out that OOP is a programming paradigm, or methodology, and as such should not be confused with “OO language features” (such as bless) which are provided to facilitate implementation of the paradigm. It is possible to write an OO programme in straight C (I’ve seen it done very competently), and all-too-easy to write non-OO programmes in “pure OO” languages such as Java. Emphasising this distinction should help to forestall objections from those who find encapsulation to be “restrictive and prohibitive” — by pointing out that they are entirely free to use bless, etc., in any way they choose; but that when they choose to do so in a way which eschews encapsulation, the code they produce is, by definition, not OO. Hope that helps,
In reply to Re: OOP: How to (not) lose Encapsulation
by Athanasius
|
|