9,146 reputation
12339
bio website
location Melbourne, Australia
age 44
visits member for 3 years, 1 month
seen Oct 27 at 1:25

By day, a mild-mannered software developer with a keen interest in those areas of computer science that deal with the psychology of human machine interaction, and how that affects the processes and principals which we apply to create useful software.

By night, I imagine I'm the coding rebel, defying all conventions and "sticking it" to "the man" while liberating the free-thinking and allegedly down-trodden cube rats that I resemble during the day!! Or, I have a vivid imagination and way too much time on my hands! ;-)

about.me
LinkedIn


Nov
27
comment What should be allowed inside getters and setters?
To avoid having too many comments here, I'll take this conversation into this chat and address your comment there.
Nov
27
comment What should be allowed inside getters and setters?
I've created a Chat Session to allow these comments to continue as needed.
Nov
27
comment What should be allowed inside getters and setters?
@methodman Yes, I agree that a public field is wrong, however a public property can be useful. That property can be used to provide a place for validation or events related to the setting or returning of the data, depending on the specific requirement at the time. Getters and setters themselves aren't wrong per-se. How and when they are used or abused on the other hand can be seen as poor in terms of design and maintainability depending on the circumstances. :)
Nov
27
comment What should be allowed inside getters and setters?
I think you're missing the point of the article, which suggests using getters/setters sparingly and to avoid exposing class data unless necessary. This IMHO is a sensible design principle which should be applied deliberately by the developer. In terms of creating properties on a class, you could simply expose a variable, but this makes it harder to provide validation when the variable is set, or to draw the value from an alternate source when "got", essentially violating encapsulation, and potentially locking you into a difficult to maintain interface design.
Nov
26
comment What should be allowed inside getters and setters?
@glenatron You miss the point that I'm writing about. Side effects within properties aren't always predictable. When you set a property Value, you expect that same value to be returned. When you call a function that may use a value, then you assume the output won't necessarily be that value itself.
Nov
26
comment What should be allowed inside getters and setters?
@MarkByers You may wish to validate input of floating point values by applying a rule that only a fixed number of decimal places is allowed. In that circumstance, you could either raise an exception if too many decimal places are input, or you could simply round the input value. This may be preferable to raising an exception. I agree though that the sentence you've quoted probably needs to be modified. I'll think about this and edit. :)
Nov
26
awarded  Nice Answer
Nov
25
revised Is there a term for “Use procedures that execute a single task”?
grammatical correction
Nov
25
comment What should be allowed inside getters and setters?
There are a couple of problems with this. Arbitrarily setting a value creates a deliberate and unclear side-effect. Also, it doesn't allow the calling code to receive feedback which could be used to better deal with illegal data. This is particularly important with values at the UI level. To be fair though, one exception I just thought of could be if allowing multiple date formats as an input, while storing the date in a standard date/time format. One could at a stretch argue that this particular "side effect" is a normalization of the data at validation, provided the input data is legal.
Nov
25
answered Is there a term for “Use procedures that execute a single task”?
Nov
25
answered What should be allowed inside getters and setters?
Nov
24
revised What is the best way to evaluate new programmers?
modified a URL - to avoid a future dead link
Nov
24
revised Should SpecFlow be used with BDD as a solo developer?
corrected an aging URL - to avoid a dead link in the future ;)
Nov
15
awarded  Nice Question
Nov
1
awarded  Popular Question
Oct
21
awarded  Yearling
Oct
16
awarded  Necromancer
Sep
24
awarded  Good Answer
Jul
6
comment Is committing/checking in code everyday a good practice?
+1. I once worked in a team where we had to check code into the vcs every day, even if the code was a spike or a useless investigation. It proved inefficient and wasteful, particularly because it required periodic maintenance to clean the vcs up. It was a due to combination of paranoia over potentially risking losing a little time to redo something, and because the manager had read in a book that you should commit every day. An extreme example perhaps, but seriously, if you haven't the judgement to know whether it's "worth" checking something in, you're probably not well suited to the job.
Jun
25
revised Unit and Integration testing: How can it become a reflex
Better grammar and focus in the statements made