New topic: 

How to implement a read-only (computed) property

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

       Page 1 of 1
   [ 6 posts ]                 Previous topic | Next topic         Author  
Message       tomsi           Post subject: How to implement a read-only 
(computed) propertyPosted: Wed Jan 27, 2010 7:15 am                        
Joined: Wed Nov 16, 2005 4:58 pm
Posts: 47
Location: Sandvika, Norway              I have just discovered the computed 
properties. How does one create read only (or write only) computed properties. 
I cannot delete the set or the get part.

I could of course just create a method returning the "hidden" variable; but is 
there another way?

This is for properties that I only want to through the constructor, by the way. 
  
                            Top                Kabe           Post subject: Re: 
How to implement a read-only (computed) propertyPosted: Wed Jan 27, 2010 7:46 
am                               
Joined: Mon Apr 09, 2007 2:49 pm
Posts: 34              I'm struggling to understand what you're trying to do 
here...

If you just set the property in the constructor, why don't you use a private 
property and just write your own Get.. Method?

Kabe   
                            Top               tomsi           Post subject: Re: 
How to implement a read-only (computed) propertyPosted: Wed Jan 27, 2010 7:55 
am                        
Joined: Wed Nov 16, 2005 4:58 pm
Posts: 47
Location: Sandvika, Norway              I guess it is because I am lazy. 
Converting a normal property to computed one is only a click away. So if I 
could have deleted the setter or the getter; I would have been done in two 
clicks.

Also, I am not sure if there are any difference between a normal method and the 
computed property's getter that can bite me.   
                            Top                npalardy           Post subject: 
Re: How to implement a read-only (computed) propertyPosted: Wed Jan 27, 2010 
8:21 am                        
Joined: Sat Dec 24, 2005 8:18 pm
Posts: 5594
Location: Canada, Alberta, Near Red Deer              tomsi wrote:I have just 
discovered the computed properties. How does one create read only (or write 
only) computed properties. I cannot delete the set or the get part.

I could of course just create a method returning the "hidden" variable; but is 
there another way?

This is for properties that I only want to through the constructor, by the way.

No need to delete it
If there is no code in the setter then it's can't be set
If there is no code in the getter then it can't be read

put code in the parts you want     
_________________
My web site Great White Software
RBLibrary.com REALbasic learning  
                            Top               npalardy           Post subject: 
Re: How to implement a read-only (computed) propertyPosted: Wed Jan 27, 2010 
8:25 am                        
Joined: Sat Dec 24, 2005 8:18 pm
Posts: 5594
Location: Canada, Alberta, Near Red Deer              tomsi wrote:I guess it is 
because I am lazy. Converting a normal property to computed one is only a click 
away. So if I could have deleted the setter or the getter; I would have been 
done in two clicks.

Also, I am not sure if there are any difference between a normal method and the 
computed property's getter that can bite me.

Careful in the debugger as it calls your getter to display the value
So it can have side effects     
_________________
My web site Great White Software
RBLibrary.com REALbasic learning  
                            Top               tomsi           Post subject: Re: 
How to implement a read-only (computed) propertyPosted: Wed Jan 27, 2010 8:34 
am                        
Joined: Wed Nov 16, 2005 4:58 pm
Posts: 47
Location: Sandvika, Norway              npalardy wrote:Careful in the debugger 
as it calls your getter to display the value
So it can have side effects
Thanks for the tip. This is one can easily bite. But then again; isn't it a bad 
design to have a getter with side-effects? Then again, probably not.

Also thanks for the info in the previous post.   
                            Top            Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 6 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