3 ms·
For the web, I find Lift's "View-First" setup much compelling, and easier. The issue I have with traditional web-framework MVC is that it assumes that each URL
by TylerE 14y ago
For the web, I find Lift's "View-First" setup much compelling, and easier.
The issue I have with traditional web-framework MVC is that it assumes that each URL associates with one controller, which I've found to be very straightjacket-esque. Often the pages I'm building have many separate bits of functionality present, from simple stuff like a login box, numerous widgets, and then the main thing the page is about.
In lift, each URL maps onto a view, which will contain the templating code for that page, including perhaps inheritance to pull in an overall template, and then will contain one or more (and perhaps MANY) snippet invocations.
A snippet in Lift is kind of sort of like a controller method. It takes the contents of it's template tag as input, and as output returns a transformed document tree, using what ever resources (models, web service calls, calling out to other classes, etc) it wants to do that.
If you write the snippets in a general way, binding text off of IDs, this allows you to get different outputs for the same data, depending on how you call the snippet - it's like passing a partial template in as a closure. Very different but powerful - the snippet handles the LOGIC, but only abstractly the templating.
It's a very powerful paradigm - it frees you from the MVC straightjacket, since you can arrange and organize your code however you like, but forces very strict separation of concerns - it forces you to compartmentalize your business logic, but doesn't force you to do it a certain way. Lift does really cool stuff with your xHTML/HTML5 templates too - it's truly operating on a server-side DOM tree, none of this is textual substitution.
http://www.assembla.com/spaces/liftweb/wiki/Templates_and_Binding http://www.assembla.com/spaces/liftweb/wiki/Templates_and_Bi... for more info.
- SkyMarshal 14y agoSecond that about Lift too. It's basically server-side jQuery. Instead of parsing templates as one big string, it does DOM transforms on sub-trees. Parallel, independent, lazy-loading transforms using an Actor for each for each Snippet/subtree. Really awesome model. Also, Twitter's recent 180 on shifting some processing from the client back to the server [1] suggests a server-oriented framework like Lift's is worth considering, despite the hype and excitement around client-heavy Rich Web Apps. Lift does the API-consuming rich client model as well, but its uniqueness is the DOM transform stuff. Very different mental model than MVC and hard to get started with for some because of that, but here's a great bit of advice on best practices I came across recently (especially the part about pretty everything being done via either LiftRules or the S object) [2]. 1. http://engineering.twitter.com/2012/05/improving-performance-on-twittercom.html http://engineering.twitter.com/2012/05/improving-performance... 2. http://www.quora.com/Lift-web-framework/What-are-the-best-practices-for-using-Lift http://www.quora.com/Lift-web-framework/What-are-the-best-pr...
- TylerE 14y agoYea, having done a two small projects in it now, my brain is starting to adapt to it a bit. Maybe a bit easier for me than for some, since I never really bought into MVC all that hard, so I'm not having to break too many habits.