Timeline for Class design dilemma: Encapsulation vs Single Responsibility/Separation of Concerns
Current License: CC BY-SA 3.0
12 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 23, 2017 at 12:40 | history | edited | CommunityBot | replaced http://stackoverflow.com/ with https://stackoverflow.com/ | |
| Dec 8, 2015 at 12:17 | comment | added | Doc Brown | @firtydank: encapsulation has nothing to do with "what is general practice" or "hiding information behind obfuscation". Either your class provides some kind of data and meta-data, or it does not. How in does in detail is not relevant. | |
| Dec 8, 2015 at 12:06 | history | edited | Doc Brown | CC BY-SA 3.0 | added 198 characters in body |
| Dec 8, 2015 at 12:04 | comment | added | firtydank | True, however, it seems to me to be general practice to expose the getters "as-is" and then leave it to the various representation generators to do format-related processing and filtering, especially in cases where a single domain object may have multiple representations. | |
| Dec 8, 2015 at 11:58 | comment | added | Doc Brown | @firtydank: it is the same with "getters": you provide some data through them, but your private implementation might look differently, there is no rule saing each getter must map to one private member - similar to the XML. And encapsulation has nothing to do with convenience - if "getters" and "XML" expose exactly the same data and structure, you have the same level of encapsulation, even if one form of access is more convenient than the other. | |
| Dec 8, 2015 at 11:40 | comment | added | firtydank | Hmmm, still not convinced. At least you have to admit it is much less likely for a downstream developer to invoke your XML representation in order to get to your internals, and even then he will only have access to the internals related to that specific XML representation. With the getter approach, he has carte blanche on everything. | |
| Dec 8, 2015 at 11:31 | comment | added | Doc Brown | @firtydank: maybe you misunderstood my answer, see my edit. | |
| Dec 8, 2015 at 11:31 | history | edited | Doc Brown | CC BY-SA 3.0 | deleted 12 characters in body |
| Dec 8, 2015 at 11:25 | history | edited | Doc Brown | CC BY-SA 3.0 | deleted 12 characters in body |
| Dec 8, 2015 at 11:03 | comment | added | firtydank | I think there is a difference between exposing all your internals to whoever can abuse it and providing a representation for a well-defined integration point. | |
| Dec 7, 2015 at 15:55 | history | edited | Doc Brown | CC BY-SA 3.0 | added 713 characters in body |
| Dec 7, 2015 at 15:37 | history | answered | Doc Brown | CC BY-SA 3.0 |