Re: My hang-up about OOP (snit)

Liste des GroupesRevenir à cl tcl 
Sujet : Re: My hang-up about OOP (snit)
De : heller (at) *nospam* deepsoft.com (Robert Heller)
Groupes : comp.lang.tcl
Date : 28. Jun 2024, 00:41:16
Autres entêtes
Organisation : Deepwoods Software
Message-ID : <76icnV37fZoBZeD7nZ2dnZfqnPudnZ2d@giganews.com>
References : 1 2
User-Agent : TkNews 3.0 (1.2.18)
At Thu, 27 Jun 2024 18:08:32 -0300 Luc <luc@sep.invalid> wrote:

 
On Thu, 27 Jun 2024 02:42:35 +0000, Robert Heller wrote:
 
The above is wrong in several ways. Widgets *never* use $self to reference
the widget's path. ($self would only be used to reference methods.)
Secondly, components are "installed" [exception: *typecomponents* are
set]. So the above should be:
 
Thanks!
 
But I already regret snitting the toplevel.
 
I mean, is there any benefit in snitting everything or should I rather
just snit the things I know there will be many of?

Any thing where you have encapsulated data or state benefits from being a
class, if only to document the encapsulated data or state, even if there is
only ever one or if it is in fact an instance-less snit::type.  It is a
convenient way to gather the "global" data that is part of a logical function
block or programming unit.  One major problem to many scripting languages
(including especially Tcl), is polluting the global namespace.  Yes you can
simply create a namespace filled with variables and procs rather than a
snit::type, and get to the same logical situation.  It is that snit takes care
of all of the "infrastructure" to implement that and "hides" some of that
infrastructure and provides some special support features (like the
typeconstructor) that are convenient.

The other benefit is creating a self-contained code library. You may only have
one toplevel in any given program, but you are likely to write many programs.
You might have a certain "style" of toplevel you like and want to reuse in
your many programs. Creating this styled toplevel and parameterizing it in a
"library" package as a snit::widget or snit::widgetadaptor is useful, because
you get reuse this code.

 
And apart from very personal preferences, is there any really good
reason for someone to prefer snit over TclOO?

In my case I started using snit before TclOO became available, so...

 
From where I stand (about 2 inches tall so not a great view), it *seems*
that snit is easier. But it also seems that TclOO has better documentation.

Snit always seemed to have good enough documentation for me. OTOH, I was
already very familiar with OO (C++, Java, etc.), so I never needed a general
OO primer. Maybe Snit might not be good for a first time OO programmer -- I
can't really say.


I'm also wondering, is this "delegate" business really good for me?
Wouldn't it be better for me to get used to a more traditional (inheritance)
approach to OOP? Would TclOO give me the more tradiional approach?
Does it also handle widgets? Can I make megawigets with it?
 

I don't know about whether TclOO handles widgets or not. The delegate business
seems really good for everything I do in Tcl -- it fits well with Tk's widget
methodology. Tradiional inheritance (ala C++ and Java) can be a bitch sometimes
(you don't want to hear my rants about Java GUI programming). I would say that
one is not "better" than the other. Just different and they solve different
problems differently -- I do a lot of C++ programming (generally NOT GUI work)
and Tcl/Tk programming (using SNIT). So I use both flavors of "inheritance"
all the time, just doing different things. I know, that is not really the sort
of answer you are looking for, but there it is.  Sometimes you need a hammer
and sometimes you need a screwdriver, so you have both in your toolbox.  One
is not really "better" than the other, just that hammers work better with
nails and screwdrivers work better with screws...

--
Robert Heller             -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software        -- Custom Software Services
http://www.deepsoft.com/  -- Linux Administration Services
heller@deepsoft.com       -- Webhosting Services
                                                                                                         

Date Sujet#  Auteur
25 Jun 24 * My hang-up about OOP (snit)22Luc
25 Jun 24 +* Re: My hang-up about OOP (snit)10Rich
25 Jun 24 i`* Re: My hang-up about OOP (snit)9Luc
26 Jun 24 i +- Re: My hang-up about OOP (snit)1Robert Heller
26 Jun 24 i +- Re: My hang-up about OOP (snit)1Rich
26 Jun 24 i +- Re: My hang-up about OOP (snit)1Rich
26 Jun 24 i `* Re: My hang-up about OOP (snit)5Rich
27 Jun 24 i  +* Re: My hang-up about OOP (snit)3Luc
27 Jun 24 i  i`* Re: My hang-up about OOP (snit)2Rich
27 Jun 24 i  i `- Re: My hang-up about OOP (snit)1Lawrence Woodman
27 Jun 24 i  `- Re: My hang-up about OOP (snit)1Robert Heller
26 Jun 24 +- Re: My hang-up about OOP (snit)1saito
26 Jun 24 +* Re: My hang-up about OOP (snit)9Robert Heller
27 Jun 24 i`* Re: My hang-up about OOP (snit)8Luc
27 Jun 24 i `* Re: My hang-up about OOP (snit)7Robert Heller
27 Jun 24 i  `* Re: My hang-up about OOP (snit)6Luc
28 Jun 24 i   `* Re: My hang-up about OOP (snit)5Robert Heller
28 Jun 24 i    `* Re: My hang-up about OOP (snit)4Luc
28 Jun 24 i     `* Re: My hang-up about OOP (snit)3Robert Heller
28 Jun 24 i      `* Re: My hang-up about OOP (snit)2Luc
28 Jun 24 i       `- Re: My hang-up about OOP (snit)1Robert Heller
26 Jun 24 `- Re: My hang-up about OOP (snit)1Luis Mendes

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal