Inheritance and static factories

  • Thread starter Thread starter Ken Kast
  • Start date Start date
K

Ken Kast

I have a class C that uses a static factory and a protected constructor to
create instances. I now want to derive a class from C. What I can't figure
out is how to create either a public constructor or static factory (either
would work) for the derived class. Can anyone give me an idea?

Thanks.

Ken
 
it sounds pretty much like a 'refactor' job.

1. roll up the class C, extract all public interfaces to another class, say
CBase

public abstract CBase {
//...
}

2. re- "wrap" to the class C
//original C
public class C: CBase {
C instance;
static C {
instance = new C();
}

protected C {
//...
}
}

3. Do whatsoever...
//NOW ya shud feel free
public class D: CBase {
//... NEW STUFF
}
 
Back
Top