Write the static method create() on a base class that returns 'new static()' so subclasses get an instance of themselves, not the base class.
Scenario
A Model base class needs a generic create() factory that subclasses like User can call and correctly get a User instance back.
Ready to try it?
Create a free account and try "Write a Late Static Binding Factory Method" free for 7 days, no card required. Earn 90 XP and track your internship progress.