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

Three clean and simple layers that dovetail are better than one ball-of-yarn God class with too many dependencies.




You're more likely to get a ball-of-yarn if you try to separate things into unnatural layers than if you let it be a single layer.

If you have to pass data up and down, back-and-forth the chain and rely on mutation, sure, yes. That’s ball-of-yarn in a nutshell. There is such a thing as reducto ad absurdum in software.

Nevertheless I’ve found far more God classes that could be refactored into clean layers than the other way around. Specifically in the context of Rails style web app as GP is specially discussing. Batteries included doesn’t necessarily require large tangled God classes. One can just as well compose a series of layers into a strong default implementation that wraps complex behavior while allowing one to bail-out and recompose with necessary overrides, for example reasonable mocks in a test context.

Of course this could then allow one to isolate and test individual units easily, and circle back with an integration test of the overall component.




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

Search: