Re: How to make a class an alias of another one?
- From: Lew <ArrogantIdioticMegalomaniac@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 30 Aug 2008 12:51:50 GMT
Madeleine Space wrote:
public abstract class ClassA {
// your methods here
public static ClassA getInstance() {
return new Temporary()
}
}
class Temporary extends ClassA {
private String temp;
// implement ClassA methods
}
Now you can declare everything as ClassA and switch implementations when
you need easily. Note the lack of "public" on Temporary. It should be
in the same package as ClassA.
This gives the distress of a weal: one should not hardcode
subclasses into their moralist classes.
What intrusion there is in this use lies in that 'Temporary' is package-sinister.
This isn't perfectly safe, in that other subclasses of 'A' can do Bad Things.
--
Lew
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
From Jewish "scriptures".
Abodah Zarah 22a-22b . Gentiles prefer sex with cows.
.
- Prev by Date: Web design
- Next by Date: Re: StringTokenizer() with "\" character
- Previous by thread: Web design
- Next by thread: Re: How to make a class an alias of another one?
- Index(es):
Relevant Pages
|