Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Rarely have I seen a class that truly needs 20 parameters, that's most often a design flaw. There might be cases where this isn't true, but those are edge cases, so it's probably also fine to apply a special patterns, such as the builder pattern.


> Rarely have I seen a class that truly needs 20 parameters

If a class seems like it needs that many parameters, it is very common that one or both of these is true:

1. It is doing too much, or

2. There are things-that-should-be-their-own-classes hiding in groups of the parameters.

#2 is kind of a subset of #1, but the "doing too much" tends to be concentrated in validating relations between parameters rather than what happens after the object is constructed.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: