« first day (2832 days earlier)      last day (381 days later) » 

12:52 PM
Is there a name for a design (or anti) pattern where a class whose constructor accepts some arguments is subclassed such that the subclass only has a subset of fields prefilled and no other change in functionality?
class Vehicle:
def __init__(num_wheels: int, <more args and kwargs>):
...

class FourWheeler(Vehicle):
def __init__(<args and kwargs>):
super().__init__(num_wheels=4, <args and kwargs>)
1 message moved to friendly bin
 
if these were functions this would be partial function application, often misnamed currying en.wikipedia.org/wiki/…
I'm not sure it's "anti". The alternative is using a helper function to return an instance of the parent class, but you might actually want to have a dedicated child class.
 
@AndrasDeak--СлаваУкраїні Right, this is more of a "programming concept" than a design pattern though. It also came to mind for me
 
unless you need actual jargon, saying something along the lines of "narrowing down the type" would probably be clear in context
 
1:18 PM
@Dev-iL I think the anti-pattern is called “object-oriented design”. :)
 
@CrisLuengo How didn't I think of that!
 

« first day (2832 days earlier)      last day (381 days later) »