Click here to Skip to main content
15,892,298 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: good encapsulation technique ? Pin
Cedric Moonen27-Dec-09 1:53
Cedric Moonen27-Dec-09 1:53 
GeneralRe: good encapsulation technique ? Pin
doug2527-Dec-09 2:05
doug2527-Dec-09 2:05 
GeneralRe: good encapsulation technique ? Pin
BonshatS27-Dec-09 3:14
BonshatS27-Dec-09 3:14 
GeneralRe: good encapsulation technique ? Pin
doug2527-Dec-09 6:02
doug2527-Dec-09 6:02 
GeneralRe: good encapsulation technique ? Pin
Bram van Kampen27-Dec-09 12:03
Bram van Kampen27-Dec-09 12:03 
GeneralRe: good encapsulation technique ? Pin
doug2527-Dec-09 13:16
doug2527-Dec-09 13:16 
GeneralRe: good encapsulation technique ? Pin
Bram van Kampen27-Dec-09 14:30
Bram van Kampen27-Dec-09 14:30 
GeneralRe: good encapsulation technique ? Pin
Jimmanuel27-Dec-09 14:39
Jimmanuel27-Dec-09 14:39 
doug25 wrote:
the use of the PROTECTED macro actually makes code more maintainable and less prone to bugs

Spend some time actually maintaining code and you'll see just how wrong that statement is.

doug25 wrote:
see clearly that they are not ordinary public members since they should be changed with precaution

Clearly see? Seeing something is worthless without enforcing it, and that's what private/protected is for. I guarantee you that when someone comes along later and sees that they can easily modify the internals of all of your classes because they're public, they'll do it. Unless you design your classes to prevent misuse, they'll be misused and then they'll be broken. When something is public, that means that it's open to the wild and it should be changed however and whenever the programmer wants.

One of the general principals in OO is that objects should interact with each other through their public interfaces and not care about each others internal states. When you violate this it generally means that classes are too tightly coupled and therefore not very reusable (and hence, not well defined). This is such a fundamental concept of OO that C# has turned encapsulation into a feature of the language itself. See Properties[^]. Being able to directly read/write the internal state of other objects shreds this concept completely.

doug25 wrote:
public, protected and private are basically for editing purposes anyway

No, they're not. They are for creating reusable, maintainable, self contained objects with well defined interfaces not just for you but for everyone else that will come along later and use/edit your code.

I agree with Cedric that you may need to go reread a few chapters of your C++ book.

doug25 wrote:
PROTECTED

As a great (fictional) man once said: You keep using that word, I do not think it means what you think it means.[^]

Badger | [badger,badger,badger,badger...]
GeneralRe: good encapsulation technique ? [modified] Pin
doug2527-Dec-09 22:52
doug2527-Dec-09 22:52 
GeneralRe: good encapsulation technique ? Pin
doug2528-Dec-09 1:33
doug2528-Dec-09 1:33 
GeneralRe: good encapsulation technique ? Pin
Jimmanuel28-Dec-09 3:05
Jimmanuel28-Dec-09 3:05 
GeneralRe: good encapsulation technique ? Pin
doug2528-Dec-09 3:37
doug2528-Dec-09 3:37 
GeneralRe: good encapsulation technique ? Pin
Bram van Kampen28-Dec-09 13:05
Bram van Kampen28-Dec-09 13:05 
QuestionDisplaying cyrillic alphabet Pin
bhanu_850925-Dec-09 22:22
bhanu_850925-Dec-09 22:22 
AnswerRe: Displaying cyrillic alphabet Pin
Rajesh R Subramanian26-Dec-09 0:13
professionalRajesh R Subramanian26-Dec-09 0:13 
QuestionAssigned value becoam garbage value Pin
Anu_Bala25-Dec-09 20:58
Anu_Bala25-Dec-09 20:58 
AnswerRe: Assigned value becoam garbage value Pin
Nelek25-Dec-09 23:06
protectorNelek25-Dec-09 23:06 
GeneralRe: Assigned value becoam garbage value Pin
Anu_Bala27-Dec-09 16:31
Anu_Bala27-Dec-09 16:31 
GeneralRe: Assigned value becoam garbage value Pin
Nelek27-Dec-09 23:20
protectorNelek27-Dec-09 23:20 
QuestionHow to find out if a pe file has been packed? Pin
Joseph Marzbani25-Dec-09 18:50
Joseph Marzbani25-Dec-09 18:50 
AnswerRe: How to find out if a pe file has been packed? Pin
Adam Roderick J25-Dec-09 20:00
Adam Roderick J25-Dec-09 20:00 
QuestionFile browser control in MFC Pin
Member 439977125-Dec-09 18:47
Member 439977125-Dec-09 18:47 
AnswerRe: File browser control in MFC Pin
Joseph Marzbani25-Dec-09 18:54
Joseph Marzbani25-Dec-09 18:54 
AnswerRe: File browser control in MFC Pin
rp_suman27-Dec-09 0:12
rp_suman27-Dec-09 0:12 
Question[Message Deleted] Pin
Mattzimmerer25-Dec-09 16:43
Mattzimmerer25-Dec-09 16:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.