Timeline for Why is Clean Code suggesting avoiding protected variables?
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 30, 2012 at 14:39 | comment | added | Andy | If it was obvious I wouldn't have been confused and downvoted you. The rule was made by our senior developers, as was our decision to run StyleCop, FxCop and require unit tests and code reviews. | |
| Aug 30, 2012 at 6:41 | comment | added | Random42 | @Andy It's pretty obvious that since I was referring to protected variables I was not talking about local or parameter variables but to fields. I also mentioned a scenario where non-constant protected variables are useful; imho it's wrong for a company to enforce the way the programmers write code. | |
| Aug 29, 2012 at 11:31 | comment | added | Andy | You may want to reword some of your post then, as you seem to use variable and field interchangably and make explicit that you'd consider things like protected consts an exception. | |
| Aug 29, 2012 at 9:33 | comment | added | Random42 | @Andy You haven't read what I said; I said that protected fields are not recommended and reasons for this. There clearly are scenarios in which protected variables are needed; you may want a constant final value only in the subclasses. | |
| Aug 28, 2012 at 22:35 | comment | added | Andy | Don't assume that because a language allows it, it's ok to do. I'm not sure there really is a god reason to allow protected fields; we actually disallow them at my employer. | |
| Aug 28, 2012 at 20:43 | history | answered | Random42 | CC BY-SA 3.0 |