|
-
May 4th, 2009, 05:06 AM
#1
Using friend classes can improve encapsulation
My theory is that using friend classes can improve encapsulation when you use them together with factory and/or manager classes.
Say I have a class that is to unable to contstruct or initialize itself or I have a factory pattern where it is decided at runtime what object to create. My theory is by making the class that needs to be constructed befriend the manager/factory class will allow you to hide alot of class variables that shouldn't be directly accessed, while still allowing the manager/factory to initilize them.
This is my view on the subject but I would appreciate some input from other developpers.
Last edited by AlastrionaAdair; May 4th, 2009 at 05:09 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|