I’m about to do the damnable – something that could potentially banish me from the glorious ornate gates of supercoderom where all the coding superheroes reside and play bocci and telepathically converse in binary and where transporters move more than just one molecule from destination a to b. I am about to say, well even confess, that I am not a fan of getters and setters. That’s right. Your literacy skills haven’t failed you, you read that right.
Let me back up the train and explain a bit. I’m not a fan of vagueness. So its not entirely getters and setters that I fault. I just prefer bluntness and explicity – those who know me right now are nodding agreement – probably wishing that along with those traits I had acquired more tact and grace. Sorry dudes, gotta have my shortcomings somewhere.
But back to explicity. Its not that I don’t like a get set property. It’s easy and efficient. Its that I really really like seeing “get” or “set” as opposed to just a property view. There is no confusing getItemID – rather than ItemID. You are aware that something is being retrieved and therefore action is explicit and not assumed.
So just to pull an example out of my ass:
I would much rather see :
It makes more sense to me. I know that an action is occuring there – so that I had to jump into some foreign code to do changes or determine the bootstrapping its self-evident. Some of you would argue the first example is pretty self-evident and obvious and I wouldn’t necessarily disagree with you – but really, when is explicity a bad thing? ( Think code… NOT Ron Jeremy playing piano.)
Reading an old post Mr.Radio-Announcers-Dream-of-my-Voice Darron Schall about No brain getters and setters made sense to me – just as Peldi in one of his coding cafe’s had casually mentioned that he didn’t really use -I will refrain from stating why because I can’t really remember – i just remember going ” hell yah”.
I’m all about the blunt.