Board index » delphi » Difference between Close and Active=False

Difference between Close and Active=False

I've always been curious... when opening a table is there a difference
between

Table1.Active := True; and Table1.Open;
or when closing a table
Table1.Active := False; and Table1.Close;

Or are they the same thing?

As I said... just curious.

Cheers
Don

 

Re:Difference between Close and Active=False


Quote
Don wrote in message <94tqru8h217p1mevn143bre826a3lcp...@4ax.com>...

>I've always been curious... when opening a table is there a difference
>between

>Table1.Active := True; and Table1.Open;
>or when closing a table
>Table1.Active := False; and Table1.Close;

>Or are they the same thing?

I have a hunch that the property accessor method for Active
looks something like

FActive:=Value;
if Active
then Open
else Close;

... or perhaps Open and Close are implemented in terms of
setting Active to True or False.

But you can't tell from the outside. Properties were expressly
designed to let you do this. It's called information hiding; it's
considered good design practice (and not exactly a new idea).

Groetjes,
Maarten Wiltink

Re:Difference between Close and Active=False


Quote
Don <jus...@RemoveSpamProtect.donwalsh.com> wrote in message <news:94tqru8h217p1mevn143bre826a3lcpmrg@4ax.com>...
> I've always been curious... when opening a table is there a difference
> between

> Table1.Active := True; and Table1.Open;
> or when closing a table
> Table1.Active := False; and Table1.Close;

> Or are they the same thing?

> As I said... just curious.

> Cheers
> Don

This code is in DB.pas

procedure TDataSet.Open;
begin
  Active := True;
end;

HTH,

John

Re:Difference between Close and Active=False


Well that answers my question... they are the same. Thanks for the
reply.

Cheers

Quote

>This code is in DB.pas

>procedure TDataSet.Open;
>begin
>  Active := True;
>end;

Re:Difference between Close and Active=False


On 29 Oct 2002 09:05:50 -0600, Don

Quote
<jus...@RemoveSpamProtect.donwalsh.com> wrote:

>Well that answers my question... they are the same. Thanks for the
>reply.

>Cheers

>>This code is in DB.pas

>>procedure TDataSet.Open;
>>begin
>>  Active := True;
>>end;

This is a minor irritation to me.

I occasionally have trouble deciding on whether to implement something
as a method or a property, and there's nothing wrong with wrapping a
property in a method, but I think the naming should at least be
consistent!

Like:
  procedure Open;
  property IsOpen : boolean

or
  procedure Activate;
  property Active : boolean;

--
jc

Re:Difference between Close and Active=False


Quote
Jeremy Collins <jd.coll...@ntlworld.com> wrote in message

news:kk5vrugus11o240bnil25s7crko7a5i5vq@4ax.com...

Quote
> On 29 Oct 2002 09:05:50 -0600, Don
> <jus...@RemoveSpamProtect.donwalsh.com> wrote:

> >Well that answers my question... they are the same. Thanks for the
> >reply.

> >Cheers

> >>This code is in DB.pas

> >>procedure TDataSet.Open;
> >>begin
> >>  Active := True;
> >>end;

> This is a minor irritation to me.

> I occasionally have trouble deciding on whether to implement something
> as a method or a property, and there's nothing wrong with wrapping a
> property in a method, but I think the naming should at least be
> consistent!

> Like:
>   procedure Open;
>   property IsOpen : boolean

> or
>   procedure Activate;
>   property Active : boolean;

> --

Yep....... its those few seconds of thought before deciding on a name that
makes all the difference. Perhaps more important is taking the trouble to
change the name when a week later you realise the naming was poor.

Dave

Re:Difference between Close and Active=False


Quote
Jeremy Collins <jd.coll...@ntlworld.com> wrote in message <news:kk5vrugus11o240bnil25s7crko7a5i5vq@4ax.com>...
> On 29 Oct 2002 09:05:50 -0600, Don
> <jus...@RemoveSpamProtect.donwalsh.com> wrote:

> >Well that answers my question... they are the same. Thanks for the
> >reply.

> >Cheers

> >>This code is in DB.pas

> >>procedure TDataSet.Open;
> >>begin
> >>  Active := True;
> >>end;

> This is a minor irritation to me.

> I occasionally have trouble deciding on whether to implement something
> as a method or a property, and there's nothing wrong with wrapping a
> property in a method, but I think the naming should at least be
> consistent!

> Like:
>   procedure Open;
>   property IsOpen : boolean

> or
>   procedure Activate;
>   property Active : boolean;

Agreed, however now we are stuck with it unless you want us to go
through all our old programs changing little bits that will not
compile when Borland comes out with D8 implementing your changes.

John

Other Threads