Click here to Skip to main content
15,886,519 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: good encapsulation technique ? Pin
«_Superman_»26-Dec-09 16:43
professional«_Superman_»26-Dec-09 16:43 
GeneralRe: good encapsulation technique ? [modified] Pin
doug2527-Dec-09 0:05
doug2527-Dec-09 0:05 
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 
No, the use of the PROTECTED macro actually makes code more maintainable and less prone to bugs, because the thing is, for a class in my project I was just going to make all the member variables public anyway but by placing the PROTECTED macro before their declarations, it allows me to see clearly that they are not ordinary public members since they should be changed with precaution when changing their values is required.

And using the macro in my project also makes better use of intellisense since it will show that the member variables are protected which in the case of classes written by myself means they are allowed to be read from but usually shouldn't be written to directly.

Of course some members may use the actual protected access specifier but if somehow a coding mistake is made to access those when they shouldn't be accessed then the compiler will produce errors at compile time where i.e. the PROTECTED macro is turned off (becomes #define PROTECTED public).

Well, I know it maybe doesn't seem like a good idea but while using this technique it's actually working very well in my project. public, protected and private are basically for editing purposes anyway and I can't see why you would decide to try and defy access rights to member variables so the PROTECTED macro seems pretty good cause it makes it easier to see how a member variable is intended to be used. Maybe there's a better name for the macro but PROTECTED suits me Smile | :)
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 
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 

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.