VB man goes Java. Casting..
From: Alvin Ryder (alvin321_at_telstra.com)
Date: 05/25/04
- Next message: Nick Landsberg: "Re: Nearest Common Ancestor Report (XDb1's $1000 Challenge)"
- Previous message: Jeff Brooks: "Re: Multiple inheritance revisited"
- Next in thread: Phlip: "Re: VB man goes Java. Casting.."
- Reply: Phlip: "Re: VB man goes Java. Casting.."
- Reply: Daniel Parker: "Re: VB man goes Java. Casting.."
- Reply: Alex Kay: "Re: VB man goes Java. Casting.."
- Reply: TLOlczyk: "Re: VB man goes Java. Casting.."
- Reply: Daniel T.: "Re: VB man goes Java. Casting.."
- Reply: Cristiano Sadun: "Re: VB man goes Java. Casting.."
- Reply: Robert C. Martin: "Re: VB man goes Java. Casting.."
- Reply: H. S. Lahman: "Re: VB man goes Java. Casting.."
- Reply: Tsolak Petrosian: "Re: VB man goes Java. Casting.."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 24 May 2004 19:31:09 -0700
Hi,
I'm a VB man gone Java, sometimes I write code like
public aMethod( Object o )
{
String error = ""
if o instanceof X
ProcessX (o)
else if o instanceof Y
ProcessY (o)
else if o instanceof Z {
int mode = 2
ProcessX (o, mode) // Similar to X but a little different
}
else if ... about 10 of these
Process
else
error = "Error - unknown type " + o.getClass().getName()
}
But my OO-guru friend, in polite words, says this is crap.
He says do
Base o = new X()
o.process()
instead of
ProcessX (o)
ProcessY (o)
Should I explore that idea?
I am not interested in the exceptional, extreme, fance, guru, or
overly-testosterone cases I just want to know what is the *basic main
line majority of cases OO way*?
Yes I know there's another downcasting thread on this NG, but it's way
too advanced. Can we *please* keep this thread simple and acrnonym
free :-) No I'm not a moron, I'm just not familiar with these
particular concepts.
Thanks in advance
Alvin
- Next message: Nick Landsberg: "Re: Nearest Common Ancestor Report (XDb1's $1000 Challenge)"
- Previous message: Jeff Brooks: "Re: Multiple inheritance revisited"
- Next in thread: Phlip: "Re: VB man goes Java. Casting.."
- Reply: Phlip: "Re: VB man goes Java. Casting.."
- Reply: Daniel Parker: "Re: VB man goes Java. Casting.."
- Reply: Alex Kay: "Re: VB man goes Java. Casting.."
- Reply: TLOlczyk: "Re: VB man goes Java. Casting.."
- Reply: Daniel T.: "Re: VB man goes Java. Casting.."
- Reply: Cristiano Sadun: "Re: VB man goes Java. Casting.."
- Reply: Robert C. Martin: "Re: VB man goes Java. Casting.."
- Reply: H. S. Lahman: "Re: VB man goes Java. Casting.."
- Reply: Tsolak Petrosian: "Re: VB man goes Java. Casting.."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|