Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Borland Delphi > Re: String acce...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 5 Topic 3663 of 3952
Post > Topic >>

Re: String access error in class

by "Maarten Wiltink" <maarten@[EMAIL PROTECTED] > Mar 28, 2008 at 11:31 AM

"E Sterrett" <bgreenf@[EMAIL PROTECTED]
> wrote in message
news:ldSdnX6uUtYBp3HanZ2dneKdnZydnZ2d@[EMAIL PROTECTED]
>> If you need outside access, make properties. (If you don't, make
>> properties anyway, but make them protected. Then never touch the
>> fields again.)
>
> Is there a reason for doing this? I do want everything to be readable
> and writable.
>
> In this case I don't see the difference between a public variable and a
> property.

It's mostly just part of my system; I tend to do things always the
same way even if they're only needed sometimes. Allows me to substitute
finger macros for actual brain activity.

Properties allow you to put accessor methods between the value and its
storage. Sometimes, a value can be computed on demand from other values
and you don't even need storage. It's one way of keeping related things
synchronised.

Another way of keeping related things synchronised is to update one when
another changes. Write accessors can make that happen reliably.

Introducing a property also introduces the possibility to change how the
value is determined in a derived class if necessary. For instance, a Count
can be computed and unchangeable in the base class and become writeable in
a more advanced implementation.


<calling the inherited constructor>

> Gotchya.. Do I have to call it by name like: TObject.Create
>
> Or is there a generic parent object that can be used?

Type 'inherited', press F1, read help.

Explicitly calling TObject.Create would allocate a new TObject and hand
you
a reference to it. You could cast your Self reference to TObject and call
Create on it, but you'd best forget immediately that such a thing is even
possible. In any case, it would stop working correctly if you decided to
change the derivation of your class from TObject to TPersistent because
you
found out Assign is nice. 'Inherited Create' always does the right thing.

There is unfortunately no generic way to express the 'Create' part (which
I'd dearly like to have, in addition to Result and Self, to express
recursion
and inherited calls with parameters).

Groetjes,
Maarten Wiltink
 




 5 Posts in Topic:
String access error in class
E Sterrett <bgreenf@[E  2008-03-27 20:01:37 
Re: String access error in class
Jamie <jamie_ka1lpa_no  2008-03-27 19:07:48 
Re: String access error in class
"Maarten Wiltink&quo  2008-03-28 00:33:29 
Re: String access error in class
E Sterrett <bgreenf@[E  2008-03-28 00:24:13 
Re: String access error in class
"Maarten Wiltink&quo  2008-03-28 11:31:36 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 13 14:48:04 CDT 2008.