Re: How to make a class an alias of another one?



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.

.



Relevant Pages

  • Re: How to make a class an alias of another one?
    ... public static ClassA getInstance() { ... It should be in the same package as ClassA. ... in that other subclasses of 'A' can do Bad Things. ...
    (comp.lang.java.programmer)
  • Re: abstract class question about operators
    ... public abstract class ClassA ... public static ClassA operator + ... public class ClassB: ClassA ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to make a class an alias of another one?
    ... I am planning to implement a class (say ClassA) in some special ... public static ClassA getInstance() { ... // implement ClassA methods ... Now you can declare everything as ClassA and switch implementations when you need easily. ...
    (comp.lang.java.programmer)
  • abstract class question about operators
    ... public abstract class ClassA ... public static ClassA operator + ... public class ClassB: ClassA ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Help with modules/packages.
    ... __init__.py makes the dir a package. ... "import CJB.ClassA" imports MODULE ClassA from PACKAGE CJB into the ... Ok now onto the imports. ...
    (comp.lang.python)