bestie
Joined 13 years ago
Joined 13 years ago
Wait while I make this edit ....
Ben Lane, the founder of The Audacious Art Experiment was one of my closest friends growing up, we were also in a band together.
The problem with writing good code samples is that it requires a lot of time and thought. This was very much an MVP blog post and appears demand for the sample app / code snippets is very real so I will do my best to get something together.
Isn't more fun to spend all your time arguing on HN though? :)
Even adding a presenter, as I prefer, serializing your data should be handled by your service layer.
I'm not advocating writing an ORM, just some simple data translations from the raw database row data to a persistence-free domain object.
You could start with Rails, get ActiveRecord querying, migrations and template rendering for free and then maybe swap it out for Sinatra and the Sequel gem (I have actually done this).
Knowing your where your dependencies and technical debts are is very empowering.
I have to disagree, by returning a value and switching on it, not only are you querying state but you risk repeating the query code all over the place.
My approach allows you to write a small adapter for your delivery mechanism and use polymorphism to eliminate conditions and duplication.
Most objects cannot be used on their own as they have collaborators. My design allows me to write a trivial console adapter that can puts the results of my service object / interactor.