News for hackers. Stuff that matters.
Re:Anti-Pattern of the Day: Type Keys by meindnoch on Monday January 02, 2023 @12:53PM (#34221112)
My favorite version is the “forceX” antipattern, where you introduce boolean flags to turn off some aspect of a function. E.g. “loadData(forceFromDisk: bool)”, where “forceFromDisk == true” bypasses the cache.

Then somewhere down the line someone realizes that actually in some cases of “forceFromDisk == true”, we still want to load the data from the cache, so the function becomes “loadData(forceFromDisk: bool, forceCache: bool)” where “forceCache == true” overrides “forceFromDisk”.

Then somewhere down the line someone realizes that actually in some cases of “forceCache == true”, we still want to load from the disk… Repeat ad infinitum.

Re:Anti-Pattern of the Day: Type Keys by gherkinnn on Monday January 02, 2023 @02:32PM (#34222511)
Two or more coupled bools are crying to become a union. A function who's control flow needs to be configured cries to be split up.