Re: Discovering variable types...

From: Bjørge Sæther (bjorge_at_hahaha_itte.no)
Date: 08/13/04


Date: Fri, 13 Aug 2004 15:25:30 +0200

Marco van de Voort wrote:
> On 2004-08-09, Bjørge Sæther <bjorge@hahaha_itte.no> wrote:
>> The black-box thinking of OO doesn't mean
>> that you don't have the source for your classes, ya know...;-)
>
> .... In theory. However practice is different.

..in the sense that you may not be allowed to change the code. But that's
more about code reuse and problems introduced here.

>> Are you sure you *know* OOP ? I just can't understand what's worse
>> with a method than some other flat plain routine living in some unit
>> ?
>
> A useless extra scope? An instantiation that is unnecessary? A
> grouping that is not natural?

Bad OOP, yes. It can really be a nightmare.
I do not *only* write OO code. But - once I recognize a pattern like
"hmmm...all these routines concern a data structure ilke this...hmmm", then
the conclusion may be: "...I'll turn it into a class !". Typically, when a
group of routines take a data structure as a parameter, it's a good case for
OO. IMHO ;-)

>> You don't have* to use polymorphism or any of that nasty stuff...
>
> What's the point then?

The other things - data and code together. initialization & finalization
routines. "InstanceSize", "ClassName", "RTTI", "Messaging", "Interfaces",
"TStringList", "TList".

> I use OOP. All the time. But I explicitely chose for a multi-paradigm
> language as Delphi to escape it, if it is not needed.

It's not *needed*, of course. But it wouldn't be much of a problem if it was
mandatory. Again IMHO ;-)

>> Now, the final argument about the syntax: "Object.Method" is that
>> when you have just written "Object.M"...and there's a nice list
>> popping up showing all methods and fields of that class starting
>> with "M". Beautiful. Self-documentary !!!
>
> Try
>
> unitname.
>
> or
>
> programname.

Oh, yes. In a one-class-one-unit style of units, yes. My units typically
have a number of classes, and they would normally have routines for more
than one specific parameter type. I see programmers use procedure names like
"Int_XXXX" to solve part of this, the parallell to Java-style "Integer.XXX".
It's just a matter of preferences, but I believe I'm not the only one
finding OOP cleaner at this point.

>>> My argument is that I wanted a way to discover how big a variable on
>>> the other side of the procedure call was... that's all.
>>
>> What could you possibly do with this number without knowing anything
>> more ?
>
> Hmm. How to explain this. Hmm, maybe if I switch to OOP context:
>
> Implement tstream write/read methods without size value ?

Read/write on unspecified types is possible with Read() / Write(). I have
never come to miss being able to read the actual variable size, though, even
if it could save a few lines of code in the stream stuff. But if it was to
be *really* useful, you'd need the data type as well (much like with
variants).

-- 
Regards,
Bjørge Sæther
bjorge@haha_itte.no
-------------------------------------
I'll not spend any money on American Software products
until armed forces are out of Iraq.


Relevant Pages

  • Re: Public Variables
    ... If you wanted to really follow the OOP paradigm, ... > Are you stating that I should ALWAYS declare ALL variables as private? ... > My object is not to learn programming style as I only wrote this one ... >>> The program consists of 2 forms, and about 12 routines I wrote. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Discovering variable types...
    ... but also gray OOP should be avoided. ... I remember that the idea "avoid the objects - keep it ... you need to group routines in very specific units. ... I don't want a myriad of units, as OOP allows me to group functionality ...
    (comp.lang.pascal.delphi.misc)
  • Re: Conditional compilation in Ada?
    ... > Instead of directly manipulating the data structure, ... > to manipulate the data structure, and dispatch to the appropriate ... Using OOP and dispatching means that the decision ...
    (comp.lang.ada)
  • Re: Using Classes
    ... Obviously there was a learning curve but I have a programing ... I know that Python is very OOP friendly, but I could not figure out ... In essence, instead of letting general routines awkwardly and error-prone choose the right type-specific routines depending on the object, let the object specify ...
    (comp.lang.python)
  • Re: Discovering variable types...
    ... but also gray OOP should be avoided. ... A data structure may be part of a larger buffer, ... Class = scope with identifiers. ... This is a mapping of a var of a type to memory (either real memory or disk) ...
    (comp.lang.pascal.delphi.misc)