Path: ...!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 27 Jun 2024 23:41:16 +0000 MIME-Version: 1.0 From: Robert Heller Organization: Deepwoods Software X-Newsreader: TkNews 3.0 (1.2.18) Subject: Re: My hang-up about OOP (snit) In-Reply-To: <20240627180832.3c8fc106@lud1.home> References: <20240625180928.43fcc5c1@lud1.home>????<20240626220932.62b9e27e@lud1.home>??<4wCdnSaPLuoGTOH7nZ2dnZfqnPudnZ2d@giganews.com> <20240627180832.3c8fc106@lud1.home> Newsgroups: comp.lang.tcl Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="us-ascii" Originator: heller@sharky4.deepsoft.com Message-ID: <76icnV37fZoBZeD7nZ2dnZfqnPudnZ2d@giganews.com> Date: Thu, 27 Jun 2024 23:41:16 +0000 Lines: 77 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-zBFHCBT8S30eqS4eoMl9S4przvm9gkMr7z1zOTAlJey8pd9u67uMj7/zf1BVVdoxEv5xexbYyDT1xjF!w82CgAKcRnOMMUpRRHmAclhVBkS7r+bguCGjVBfTU1+z5ZKuLr2G6IVe1UaMYELbrdwlNoAj/+uc!pGU= X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Bytes: 5348 At Thu, 27 Jun 2024 18:08:32 -0300 Luc 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