Timeline for Why do we need private variables?
Current License: CC BY-SA 3.0
41 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 1, 2024 at 1:03 | comment | added | NickJ | Job security. It's one more hurdle to jump through. It's like typing "void" in front of every function that doesn't have a return type. It's boiler plate to shove obstacles and meaningless details down your throat so the 'act' of programming takes longer and is the end goal is to sit and type instead of produce useful work. More details means more things that need to be learned and can go wrong. Contrast this with a language that has useful defaults and can infer obvious things. Sadly the latter type is less popular for obvious financial reasons. | |
| May 8, 2019 at 4:33 | answer | added | Purvi Barot | timeline score: -1 | |
| Jan 19, 2018 at 0:24 | comment | added | gnasher729 | @mouviciel: In practice, Objective-C has private class members. You just declare them in the implementation file, not in the header. You can even declare a property readonly in the header file, and readwrite in the implementation. | |
| May 3, 2017 at 18:05 | answer | added | AturSams | timeline score: 1 | |
| Jun 17, 2016 at 9:02 | comment | added | gnasher729 | If you catch anyone using a seatbelt in their car, you should take their driving license away, since obviously they don't trust their own abilities to drive. | |
| Jun 17, 2016 at 2:48 | answer | added | Aquarius Power | timeline score: 0 | |
| Feb 22, 2016 at 19:32 | comment | added | Solomon Slow | Something to consider when reading the answers below: Source code is documentation. When you see private foo, you know that the author of the code did not intend for foo to be used from other compilation units, and when you see public foo you know the opposite. | |
| Aug 5, 2015 at 16:27 | review | Close votes | |||
| Aug 7, 2015 at 13:29 | |||||
| Aug 28, 2013 at 10:25 | history | protected | Arseni Mourzenko | ||
| Jun 27, 2013 at 13:41 | history | edited | gnat | CC BY-SA 3.0 | http://meta.programmers.stackexchange.com/q/6017/31260 |
| Jun 27, 2013 at 13:08 | answer | added | Arnab | timeline score: -3 | |
| Jun 27, 2013 at 11:48 | review | Close votes | |||
| Jun 27, 2013 at 21:43 | |||||
| Jun 27, 2013 at 11:30 | comment | added | Tulains Córdova | possible duplicate of When are Getters and Setters Justified | |
| Jun 27, 2013 at 10:45 | review | Suggested edits | |||
| Jun 27, 2013 at 11:21 | |||||
| Jun 27, 2013 at 6:56 | comment | added | mouviciel | @James - This is not language-agnostic: private variables don't exist in Objective-C for instance. | |
| Jun 27, 2013 at 4:10 | history | edited | mwallace | edited tags | |
| Apr 17, 2012 at 19:27 | answer | added | phorgan1 | timeline score: 2 | |
| Apr 12, 2012 at 20:27 | comment | added | gnat | for the record: this question has been discussed at Programmers Meta | |
| Apr 11, 2012 at 14:39 | history | edited | CommunityBot | remove duplicate link | |
| Apr 11, 2012 at 14:39 | history | reopened | Doug T. maple_shaft♦ | ||
| Apr 10, 2012 at 17:15 | vote | accept | mwallace | ||
| Apr 10, 2012 at 17:09 | history | edited | CommunityBot | insert duplicate link | |
| Apr 10, 2012 at 17:09 | history | closed | Bill the Lizard gnat CommunityBot JeffO Walter | exact duplicate | |
| Apr 10, 2012 at 16:47 | answer | added | Erik Reppen | timeline score: 1 | |
| Apr 10, 2012 at 16:37 | comment | added | Nazar Merza | The usage and difference of private and public variables, and why we have them, can only be understood in the context of general Object-oriented principles. It cannot be understood separately. You probably need to look at it from that perspective, things may get clearer. | |
| Apr 10, 2012 at 15:53 | answer | added | Karl Bielefeldt | timeline score: 6 | |
| Apr 10, 2012 at 15:41 | answer | added | jmoreno | timeline score: 2 | |
| Apr 10, 2012 at 14:42 | answer | added | KeithS | timeline score: 2 | |
| Apr 10, 2012 at 14:15 | comment | added | Jesvin Jose | I had a similar question when I saw implementation-agnostic classes being used. | |
| Apr 10, 2012 at 14:07 | comment | added | kba | For the record, creating a private method doesn't increase "security". Other parts of your application can still access private members using reflection. | |
| Apr 10, 2012 at 12:08 | comment | added | James | Your question sounds very language-agnostic, but you have tagged it as java and c++. If you are interested in perspectives from outside those two languages, you should probably say so. | |
| Apr 10, 2012 at 11:09 | history | edited | mwallace | CC BY-SA 3.0 | deleted 30 characters in body |
| Apr 10, 2012 at 6:14 | history | edited | gnat | edited tags | |
| Apr 10, 2012 at 5:52 | answer | added | Jeffrey Sweeney | timeline score: 8 | |
| Apr 10, 2012 at 5:52 | history | tweeted | twitter.com/#!/StackProgrammer/status/189591639348613120 | ||
| Apr 10, 2012 at 5:52 | answer | added | rajNaveen | timeline score: 1 | |
| Apr 10, 2012 at 5:48 | answer | added | Frank | timeline score: 32 | |
| Apr 10, 2012 at 5:48 | answer | added | tdammers | timeline score: 340 | |
| Apr 10, 2012 at 5:41 | answer | added | Oleksi | timeline score: 117 | |
| Apr 10, 2012 at 5:38 | answer | added | bbb | timeline score: 3 | |
| Apr 10, 2012 at 5:31 | history | asked | mwallace | CC BY-SA 3.0 |