Hacker News new | ask | show | jobs
by holaberlin 6222 days ago
It looks like there is no separation between view and controller. Mixing HTML into your controller methods seems like a step backwards.
3 comments

If this is a port of Sinatra that is an option to make a very small concise webservice. You can choose to do seperation, but if you want something very simple and compact a single file can be easier. We have a Sinatra app that has the model,view,controller, and tests in a single file that is less than 250 LOC. It would be more obfuscated to have 5 files of less than 50 LOC each (Some with as little as 4 lines).

If it doesn't provide any option for separation that is bad, but for micro services it can be really nice.

For sure. I'm just using XML literals in the example because it looks cool. But I'm also using this for a client job, and it's producing JSON.

It's not nearly as powerful as the real Sinatra, but it saves me the shenanigans of warbling Sinatra apps for servlet deployment.

I have barely glanced at Scala, but I assume that it has HTML templating libraries. You can then make your controller pass whatever data structure you want to the template, which then takes care of rendering the view.

Microframeworks are appealing in that way: you can pick and choose which components to use, and they let you adapt MVC to whatever fits most naturally to your application. It's hard to argue with the brevity of the underlying code and the clarity of the example.

Presumably there's nothing stopping you from factoring out all that HTML into methods on a 'view' class.