I congratulate you with your design. This design has a very clear distinction between class and instance and is not bad at all.
Your question is unclear. What do you think is wrong with your design or needs improvement? Sometimes asking the right question is what will give you the right answer.
One thing I would have improved upon is the TestParameter class. I'd probably have generalized that. In other words, I would have made a RangeTestParameter, SingleValueTestParameter and a SelectableTestParameter. I would've made that generalized TestParameter include a factory method too:
ITestParameterValue ITestParameter.createValue()
Implemented by SelectableParameter it would return a SelectableValue. That SelectableValue would have been supplied with a set of selectable/permitted values via its constructor.
This way you could address two points in your design that triggered questions I would have asked myself if this was my design:
- TestParameterType: Why design a type class when the type is available to you at compile-time? How are you going to ensure that your Code parameter contains a valid and functional value? Who is responsible for creating these types based upon these Codes?
- PermitedValue: Does TestParameter have a list of ParameterValues only if the TestParameter has a (Code) reference to the ParameterType Selectable? What if it doesn't? Who ensures it does? Who knows how to interpret a TestParameter in this particular way? Only SelectableValue? Only those who have read the if statement in your class diagram?
If you'd like to present your users with a list of possible parameters you can create a TestParameterFactory that links your parameter types to some additional info. Here is a simple Java version of such a factory:
public class TestParameterFactory {
private final Map<String, ITestParameter.class> parameterTypes;
public TestParameterFactory() {
parameterTypes = new HashMap<String, ITestParameter.class>();
parameterTypes.put("Range", RangeTestParameter.class);
parameterTypes.put("Selectable", SelectableTestParameter.class);
parameterTypes.put("Single value", SingleValueTestParameter.class);
}
public getParameterTypes() {
return parameterTypes;
}
public ITestParameter createParameter(String name) {
ITestParameter parameterType = parameterTypes.get(name);
if (parameterType == null)
throw new IllegalArgumentException(name+ " is not a valid parameter type name");
return parameterType.newInstance();
}
}
I hope this helps. Good luck!