Click here to Skip to main content
15,918,889 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: is this good practice? Pin
Nemanja Trifunovic26-Feb-02 10:27
Nemanja Trifunovic26-Feb-02 10:27 
GeneralRe: is this good practice? Pin
Roman Nurik26-Feb-02 10:24
Roman Nurik26-Feb-02 10:24 
GeneralRe: is this good practice? Pin
Christian Graus26-Feb-02 10:54
protectorChristian Graus26-Feb-02 10:54 
GeneralRe: is this good practice? Pin
Maximilien26-Feb-02 11:01
Maximilien26-Feb-02 11:01 
GeneralRe: is this good practice? Pin
Michael Dunn26-Feb-02 11:41
sitebuilderMichael Dunn26-Feb-02 11:41 
GeneralRe: is this good practice? Pin
Carlos Antollini26-Feb-02 10:31
Carlos Antollini26-Feb-02 10:31 
AnswerRe: is this good practice? Pin
Jon Hulatt27-Feb-02 1:04
Jon Hulatt27-Feb-02 1:04 
GeneralRe: is this good practice? Pin
Bill Wilson27-Feb-02 8:05
Bill Wilson27-Feb-02 8:05 
Readability is not the only benefit to encapsulation. The primary reason, in my opinion, is to divorce the audience of a member variable from the derivation of its value.

If you use accesor and mutator methods you can do things like changing the underlying storage or even add qualifications and calculations without impacting the audience of the value.

For example:

Say you have an inventory class that contains a Price variable. Then at a later date, after you've built your app, a buisiness decision is made to vary the price by warehouse location. If you used an accesor (GetPrice), you only need to modify it to accomodate the calculation, rather than modifying every reference to m_price in the entire app.

Just my opinion for what its worth,
Bill
GeneralRe: is this good practice? Pin
Roman Nurik27-Feb-02 9:43
Roman Nurik27-Feb-02 9:43 
AnswerRe: is this good practice? Pin
Stan Shannon27-Feb-02 1:29
Stan Shannon27-Feb-02 1:29 
GeneralOpenGl opening files Pin
Nnamdi Onyeyiri26-Feb-02 10:08
Nnamdi Onyeyiri26-Feb-02 10:08 
GeneralAuto-complete file combo Pin
Chris Losinger26-Feb-02 8:52
professionalChris Losinger26-Feb-02 8:52 
GeneralRe: Auto-complete file combo Pin
Michael Dunn26-Feb-02 11:42
sitebuilderMichael Dunn26-Feb-02 11:42 
GeneralRe: Auto-complete file combo Pin
Chris Losinger26-Feb-02 12:24
professionalChris Losinger26-Feb-02 12:24 
Generalnevermind... Pin
Chris Losinger26-Feb-02 13:44
professionalChris Losinger26-Feb-02 13:44 
GeneralGlobalAddAtom and RegisterHotKey Pin
26-Feb-02 8:41
suss26-Feb-02 8:41 
GeneralRe: GlobalAddAtom and RegisterHotKey Pin
Carlos Antollini26-Feb-02 9:03
Carlos Antollini26-Feb-02 9:03 
GeneralGlobal Variables Pin
Rajveer26-Feb-02 8:35
Rajveer26-Feb-02 8:35 
GeneralRe: Global Variables Pin
Chris Losinger26-Feb-02 8:34
professionalChris Losinger26-Feb-02 8:34 
GeneralRe: Global Variables Pin
Nemanja Trifunovic26-Feb-02 8:39
Nemanja Trifunovic26-Feb-02 8:39 
GeneralRe: Global Variables Pin
Carlos Antollini26-Feb-02 8:40
Carlos Antollini26-Feb-02 8:40 
GeneralRe: Global Variables Pin
Christian Graus26-Feb-02 10:56
protectorChristian Graus26-Feb-02 10:56 
GeneralRe: Global Variables Pin
Nemanja Trifunovic26-Feb-02 11:06
Nemanja Trifunovic26-Feb-02 11:06 
GeneralRe: Global Variables Pin
Christian Graus26-Feb-02 11:08
protectorChristian Graus26-Feb-02 11:08 
GeneralRe: Global Variables Pin
Nemanja Trifunovic26-Feb-02 11:28
Nemanja Trifunovic26-Feb-02 11:28 

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.