Hacker News new | past | comments | ask | show | jobs | submit login

Flat APIs are not affected by the 7+-2 limitation. They do not depend on each other, so we don't need to think about all of them at the same time.



I agree if attributes are global variables to the structured program that is the object, then methods are just functions and they are far less "dangerous". If you have a modest number of globals, like 3, you can have hundreds of different functions without much fuss. The only issue with tons of functions is really documentation and discoverability, teaching people what all you can do with the object.

It's common to have a nested tree of objects to control state and keep the implementation clean, but then expose a flat API on top of all that. While it's more code, sometimes it's the best of both worlds. In fact creating objects with many attributes is kind walking down the primrose path, you think you're making the API easier to use, but you are making the implementation into a quagmire that you many never pull out of.




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

Search: