New topic: 

Should I drop the Getter methods?

<http://forums.realsoftware.com/viewtopic.php?t=46448>

         Page 1 of 1
   [ 4 posts ]                 Previous topic | Next topic          Author  
Message        Gavin          Post subject: Should I drop the Getter 
methods?Posted: Sat Jan 05, 2013 12:30 pm                         
Joined: Fri Dec 09, 2011 6:27 am
Posts: 41                In an app I am working on for a client, I have a 
number of objects and each object has a tonne of properties (>50), mostly 
strings and integers. Normally I implement OOP practices quite carefully, but 
in this case, it feels like I'm cluttering up the classes unnecessarily with a 
getter method for every property. I'm tempted to just go ahead and make the 
properties public in scope, it seems less messy in this case, when there's so 
many of them.

Thoughts? Encouragement? Discouragement?     
_________________
Xcode and Real Studio developer. Using Real Studio since RealBasic 1.0  
                             Top                ktekinay          Post subject: 
Re: Should I drop the Getter methods?Posted: Sat Jan 05, 2013 12:38 pm          
                       
Joined: Mon Feb 05, 2007 5:21 pm
Posts: 335
Location: New York, NY                I know the "right" way to do this, but 
frankly, if the getter/setter methods would just get or set a property anyway 
without additional processing, I just expose that property and move on. If you 
need to restrict either in some way (some property needs to be read-only, for 
example), that's a different matter.      
_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.
  
                             Top                Gavin          Post subject: 
Re: Should I drop the Getter methods?Posted: Sat Jan 05, 2013 12:46 pm          
               
Joined: Fri Dec 09, 2011 6:27 am
Posts: 41                ktekinay wrote:I know the "right" way to do this, but 
frankly, if the getter/setter methods would just get or set a property anyway 
without additional processing, I just expose that property and move on. If you 
need to restrict either in some way (some property needs to be read-only, for 
example), that's a different matter.

Hey Kem
After I posted, I realised I had pretty much made up my mind and was hoping 
someone would just make me feel better about it, so thanks  Yes, there 
shouldn't be any additional processing on each property and if there is, I'll 
make that one a private property and do it properly.

Thanks for the reply.      
_________________
Xcode and Real Studio developer. Using Real Studio since RealBasic 1.0  
                             Top                npalardy          Post subject: 
Re: Should I drop the Getter methods?Posted: Sat Jan 05, 2013 4:10 pm           
            Real Software Engineer          
Joined: Sat Dec 24, 2005 8:18 pm
Posts: 7645
Location: Canada, Alberta, Near Red Deer                Gavin wrote:In an app I 
am working on for a client, I have a number of objects and each object has a 
tonne of properties (>50), mostly strings and integers. Normally I implement 
OOP practices quite carefully, but in this case, it feels like I'm cluttering 
up the classes unnecessarily with a getter method for every property. I'm 
tempted to just go ahead and make the properties public in scope, it seems less 
messy in this case, when there's so many of them.

Thoughts? Encouragement? Discouragement? 

If the only thing the getter & setter do is set & return some internal property 
then just make them public properties
If you do some code use a computed property
The nicest thing about Real Studio & the language is this is all invisible to 
the code that uses those properties / methods.
It's blissfully unaware that you've made a property a computed property or a 
pair of get / set methods as long as they all are named the same as the 
property      
_________________
My web site Great White Software
RBLibrary.com REALbasic learning  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 4 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to