Re: [Dev-C++] public/private data decision
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <or...@vp...> - 2004-04-12 22:00:34
|
Hi! Thanks for both of your comments, they were indeed really helpful! Actually, I was thinking about the same, that "data-storage" like=20 classes, where I don't need to check for anything special (no=20 invariant), there is no need for get/set methods, I was just in doubt,=20 which leads me to my next question: What should count as an invariant? Suppose I have some class, which=20 stores a file-path internally. There is a method: Save (saves the=20 object). Should the path always be valid? Or should Save throw an=20 exception if it cannot open the file for writing? Or both? Because if I look at it the second way, there is no need for the get/set=20 stuff, as Save will check the path anyway. Any comments? (The above is just a very simplified example) I'll look for Stroustrups's writings what you mentioned, BTW. -- Greetings, Bal=E1zs |