KBD

Keith Devens .com

Thursday, March 11, 2010 Flag waving
Battle not with monsters lest ye become a monster and if you gaze into the abyss the abyss gazes into... – Friedrich Nietzsche
← Currying and partial applicationTime for me to learn Rails →

Daily link icon Thursday, August 25, 2005

When static typing gets in the way

I want to do the following in Java:

SuperClass s = Class.forName("fully-qualified-class").newInstance();
s.process(foo, bar);

I know that given what "fully-qualified-class" is I can call process on s, but Java's static typing thinks I can't, so it won't let me.

Update: I'd like to correct myself a little: Ultimately, the real reason that you can't call process on s is because on the base class the process method is protected, whereas on the subclasses I need to call it on it's public. So, you could argue that this is really a case where access controls (not static typing) are getting in the way, or a case where the access controls on this class hierarchy weren't designed well enough. I lumped this in with static typing because in a normal message-passing style of OO this wouldn't be an issue, since the message would be passed and the object would either accept or reject it.

← Currying and partial applicationTime for me to learn Rails →

Comments XML gif


Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

March 2010
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive

Generated in about 0.258s.

(Used 8 db queries)