[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Designing Classes, needing stubs
From: |
Laszlo Gulyas |
Subject: |
Re: Designing Classes, needing stubs |
Date: |
Tue, 18 May 1999 17:24:30 +0200 (MET DST) |
Hi,
as far as I know the kind of method you mentioned is usually called
'an abstract method' (and thus makes your A class an 'abstract class') in
OO engineering. (Languages usually have a special syntax and a special
name for this classes and methods.) So, what you are aiming at is quite
natural in OO thinking. On the other hand, this does not help you any.
As I don't know Objective-C that deeply, I would expect Glen's solution
to be the one to use.
Yours, Gulya
On Mon, 17 May 1999, Paul Johnson wrote:
>
> I came across an issue yesterday and I suppose people who design OO
> software must face it all the time, but for a moment I was surprised and
> made a note to ask about it. What do you do when a superclass has a
> method that includes calls to other methods that are implemented in the
> subclasses? I found myself creating hollow (call it a stub?) methods in
> the superclass to stop the compiler from complaining.
>
> Let me explain.
>
> There is a class A. Instances of A are never created, rather there are
> subclasses B and C. B and C have specialized implementations of a
> method, say we call it handleProblem. All of the other things that B
> and C do are inherited from A. A does not have a handleProblem method.
>
> In the class A, there is a "step" method that outlines a number of
> things to do, and one of them is [self handleProblem]. This step
> method is called from ModelSwarm in the usual way, it tells each agent
> to do a series of actions. The "step" method is defined in the
> superclass A, and there is no need to specialize it in B and C.
> However, when I try to compile, I get the understandable compiler
> warning that class A does not respond to handleProblem. However, since
> I never create any objects of class A, only the subclasses B and C, the
> warning is not important.
>
> To make it go away, the only thing I could think of was to put a stub in
> A for the -handleProblem method, and then have the specialized actions
> in B and C override. Good, bad, or indifferent?
>
> --
> Paul E. Johnson email: address@hidden
> Dept. of Political Science http://lark.cc.ukans.edu/~pauljohn
> University of Kansas Office: (785) 864-9086
> Lawrence, Kansas 66045 FAX: (785) 864-5700
>
>
>
>
> ==================================
> Swarm-Support is for discussion of the technical details of the day
> to day usage of Swarm. For list administration needs (esp.
> [un]subscribing), please send a message to <address@hidden>
> with "help" in the body of the message.
>
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.