🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.oodesign
Article #90

Re: BCB and OO

#90
From: Chris Uzdavinis
Date: Tue, 03 Aug 2004 13:57
43 lines
2342 bytes
"fwang11" <fwang11@pub3.fz.fj.cn> writes:

>>Which class would you propose to embed it in?  
>
> could embed it in another class, eg  
>
> class TForm1: public TForm
> {
>       private: 
>         TForm2 *Form2; 
> }

That's fine and all, but you still have to have an instance of TForm1
before you can access the pointer to Form2.  If Form2 really depends
on having a Form1 already made, then write your code exactly like you
have it above, and take form2 out of the auto-creation list.

>>Does it really matter?
>
> To make it pure C++ instead of mix C and C++.

First, how is this C instead of C++?

Second, what is wrong with C (even if this were C?)

Third, why is this better?


Making Form2 be a member of Form1 is a fine design idea, and you're
free to do it.  But the auto-created forms (created by starting your
application, without any code by you needing to be written) are
implemented with a global variable.  If you move form2 into form1,
then you're changing the meaning of your program.  Before, form2 was
created by the generated code at program startup.  Your proposal makes
it that form2 isn't created until sometime after form1 is created, and
you have to write (by hand) the code to create the object and
initialize the Form2 pointer that is inside form1.

Both are valid designs that accomplish different things.


-- 
Chris (TeamB);
Technical Details
Message-ID: <j5r7qonx3c.fsf@explicit.atdesk.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <410eeeef$1@newsgroups.borland.com> <j5acxdgdzy.fsf@explicit.atdesk.com> <410f0267@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10db1e,2b952f7b4dbe888b
X-Google-Attributes: gid10db1e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Newsgroups: borland.public.cppbuilder.oodesign
Subject: Re: BCB and OO
References: <410eeeef$1@newsgroups.borland.com> <j5acxdgdzy.fsf@explicit.atdesk.com>
 <410f0267@newsgroups.borland.com>
From: Chris Uzdavinis (TeamB) <chris@uzdavinis.com>
Organization: TeamB
Date: Tue, 03 Aug 2004 09:57:11 -0400
Message-ID: <j5r7qonx3c.fsf@explicit.atdesk.com>
User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.2 (gnu/linux)
Cancel-Lock: sha1:u/L9dc8wCIkXENucxNXifrUC2d0=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
NNTP-Posting-Host: 63.68.0.194
X-Trace: newsgroups.borland.com 1091541429 63.68.0.194 (3 Aug 2004 06:57:09 -0700)
Lines: 43
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail