generic factory method convention
generics, java
Solution
It actually depends on the scenario in which you are you using the `newInstance()`. In most general cases:
Since `Child` is implementing `newInstance()`, According to me
protected static Child newInstance()
{
// ...
}
would be more appropriate.
Problem
Let me say there is an abstract class which looks like ``` abstract class Parent<V> { protected static <T extends Parent<V>, V> T newInstance( final Class<T> type, final V value) { // ... } } ``` Within following Child class ``` class Child extends Parent<XXX> { public static Child newInstance1(final XXX value) { // ... } public static Parent<XXX> newInstance2(final XXX value) { // ... } } ``` Which one is preferable? `newInstance1` or `newInstancw2`?