Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
vane110542yyou have method foo() then cause you’re lazy and you think saving couple bytes can improve shit storm that’s coming, decided to not copy foo code you add foo(isfucked=false) and next year it becomes foo(isfucked=false, isreallyfucked=false) cause someone modified isfucked logic in the meantime cause isfucked due to business requirements is now isnotfucked then it’s indeed really fucked, from maintainability and design stand function should have one purpose but number of bool arguments exponentially multiply this purpose and makes code unmaintainable in the long run
-
@vane Swiss army knifes are indeed hard to maintain if not well-covered by unit tests.
Often, a swiss army knife is the most practical solution for dealing with real world constraints (rules imposed by law or management for example). Then it might be still better to pass pure functions to the swiss army knife instead of bools and have shortcut functions covering the most common cases.
But sometimes, just adding one well-named bool arg or maybe even two (but three is really pushing it) actually can be the right eay to do it... -
If you're in the OOP realm, you could always be passing it an object containing properties about said booleans. This way, the method's own signature won't risk exponential growth once the fucked up logic degenerates further.
Related Rants
bool values in function arguments
rant
fucked