FW: Re: [Tutor] Dynamic creation of class instances...

dman dman@dman.ddts.net
Fri, 24 May 2002 16:47:27 -0500


--UugvWAfsgieZRqgk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable


This was sent off-list, but looks like it should be on-list :-).

----- Forwarded message from Bryce Embry <bryce@bembry.org> -----

| From: Bryce Embry <bryce@bembry.org>
| To: dman <dman@dman.ddts.net>
| Subject: Re: [Tutor] Dynamic creation of class instances...
| Date: Fri, 24 May 2002 14:39:37 -0500
|=20
| Howdy,
| I'm one of the folks who asked a question along the lines of dynamic clas=
s=20
| creation.  Coming from a very limited programming background I don't have=
 a=20
| strong grasp of OOP, and I haven't had to do any work in a language where=
=20
| all variables must be declared before use (ala C++).  I asked the questio=
n=20
| largely because of my understanding (or misunderstanding) of classes and=
=20
| OOP.
|=20
| I think this misconception comes from the examples of classes given in a=
=20
| lot of texts.  The examples given in most of the introductory texts are=
=20
| fairly shallow and leave the impression to newbies like me that a class i=
s=20
| something you define generically so that you can create specific instance=
s=20
| of it at runtime.   So, I define a generic "snake" class, and then the us=
er=20
| can specify more details about his snake named "Slytherin" and we'll save=
=20
| that as a new instance of the class at runtime. Or I define a generic ban=
k=20
| account class, and each user will create his own instance of the bank=20
| account at runtime.  This was my concept for a while, and I'm only now=20
| starting to move beyond it. Newbie programmers have heard a lot about OOP=
=20
| and are anxious to be "in the know" and use it.  Introductory texts cover=
=20
| classes, but their examples are necessarily short, often very artificial,=
=20
| and thereby give a wrong impression.
|=20
| As I learn more about classes it seems that the programs / scripts that I=
=20
| have been writing are just too simplistic to really use classes.  I can s=
ee=20
| that they would be very useful in a larger project, but for my dinky=20
| 100-line codes, it just seems that classes are not quite as practical.  I=
=20
| realize there may be some dinky codes that could benefit from OOP and=20
| classes, but I guess I just haven't gotten there quite yet.
|=20
| I think OOP was one of my first hang-ups with a lot of the Tkinter=20
| tutorials, too.  Most of the tutorials made their GUI programs using=20
| classes, but only had one instance of the class.  I don't understand how=
=20
| that's an improvement.  I understand how a Label() is a subclass of a=20
| Widget(), but I don't understand why I have to create a class just to mak=
e=20
| a GUI.  I guess that's why I wrote my own tutorial without using classes=
=20
| for Tkinter.
|=20
| I guess my suggestion, then, is to work on the introductions to OOP and=
=20
| classes.  I read quite a few of them when I was trying to figure out=20
| classes (Alan Gauld's, Lutz and Ascher's, Deitel's, DevShed's, and a few=
=20
| others) and I still didn't quite get it.  I really wanted to get it,=20
| though, so I could be a cool programmer and use OOP.  I've started workin=
g=20
| through some of the recommended reading posted a couple months ago, thoug=
h,=20
| and I realize that I can be a cool programmer even if I just use function=
al=20
| programming most of the time.  I like that.  I grok functional programmin=
g.
|=20
| Also, contrary to what a number of folks have suggested, I was not led to=
=20
| the dark side via the exec() function.  This function is not really cover=
ed=20
| in beginning tutorials and I had not heard about it until folks on this=
=20
| list mentioned it. I doubt that it is the primary culprit leading folks=
=20
| down the slippery slope of dynamic class creation.   I would tend to blam=
e=20
| the examples of OOP in texts.
|=20
| Well, those are my thoughts. Hopefully they're worth the paper their=20
| printed on.
|=20
| Bryce Embry
|=20
|=20
| "Lord, you establish peace for us.
| All that we have accomplished
| you have done for us" -- Isaiah 26:12

----- End forwarded message -----

--=20

Pleasant words are a honeycomb,
sweet to the soul and healing to the bones.
        Proverbs 16:24
=20
GnuPG key : http://dman.ddts.net/~dman/public_key.gpg


--UugvWAfsgieZRqgk
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAjzutO8ACgkQO8l8XBKTpRQhOQCfQfI0KSL2IV53w5Tg9HbuUODf
L3YAoLuihUD0d/K7nVUIiFN3f6JsethQ
=dWmj
-----END PGP SIGNATURE-----

--UugvWAfsgieZRqgk--