Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

using static inner classes good or bad design ?

513500Nov 8 2007 — edited Nov 9 2007
Using lots of static inner classes is it a good design or not ? I am using inner classes to retrieve initialization variables

example

public class Person {

private String firstname;

private String lastname;

public Person(String firstname, String lastname){
this.firstname=firstname;
this.lastname=lastname;
}

public static interface IPerson {
public String getFirstName();

public String getLastName();

}
public static class NewPerson implements IPerson {
public String getFirstName() {
// TODO Auto-generated method stub
return "New firstname";
}
public String getLastName() {
// TODO Auto-generated method stub
return "New lastname";
}
}

}



package com.reisys.service.review.service.event.addon.action;


public class PersonCreator extends Person {


public PersonCreator(IPerson aPerson ) {
super(aPerson.getFirstName(),aPerson.getLastName());
}

public PersonCreator() {
this(new NewPerson());
}
}


In this example PersonCreator is initialized using static inner class . I am confused with the approach the approach mentioned above is it a good design?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 7 2007
Added on Nov 8 2007
22 comments
776 views