views:

325

answers:

8

As a programmer with zero design skills and a loathing for cross browser layout issues, what web frameworks have the best separation of layout code from business code?

Ideally the distinction between business code and layout code should be clear cut (as in separate source files, as well as logically), with the layout code easily understandable by design folks, and business code by the likes of me. Tool support for both perspectives is a plus.

So, for your language of choice (php, .net, ruby, python, java, etc.) which framework do you recommend?

Wicket is the best one I have found so far for Java, but there's still plenty of chance for layout code to intermingle with business code.

+3  A: 

The purpose of MVC frameworks is to separate layout from business logic from data storage.

Most frameworks make it easier to separate these aspects, but you can still go against the spirit of the framework you're using and muddy it up with layout logic in the database model. Poor design and implementation isn't eliminated by these frameworks.

I have used CodeIgniter and CakePHP (both of which are PHP MVC frameworks).

CakePHP provides a lot of libraries and functionality but is generally regarded as somewhat slow (though it's more than likely fast enough for most needs).

CodeIgniter is quite lean and is regarded as one of the fastest PHP MVC frameworks. I've moved to this one simply because CakePHP had much more than I needed for my basic sites.

Before choosing which you'll use check out the features and try to pick the one which meets all your demands without providing too much you won't use.

Ben S
agreed. But some frameworks are better than others at encouraging proper separation. The purpose of the question is to get your opinion of which ones are exceptionally good in this aspect.
Leif
whoops, missed your edit!
Leif
Yeah... I like to give a quick summary and post then follow up with more details in edits. Gives the OP something to think/read about while I'm still typing.
Ben S
+1  A: 

Ruby on Rails!

Snehal
A: 

In case you haven't seen this: What Java web framework best accomodates web ui designers?

Brian Laframboise
+3  A: 

On the Python side, I've heard good things about Django. I plan on experimenting with it when I get a chance. It appears to enforce strict boundaries between each of the layers, although I suppose you could mix business logic in the views if you really tried.

I've also heard good things for ASP.NET MVC in the .NET arena. However, I haven't experimented with it at all, so whether it keeps things well separated, I couldn't say.

In PHP, I've looked at a few, but some seem to be... overdone to put it mildly. While Symfony (for example) sounded interesting, it also seems to get very complex very quickly.

R. Bemrose
+1  A: 

For my PHP backend I use CodeIgniter as suggested above and for my JavaScript I use Yahoo UI. It sounds like you are trying to, on one hand make the code easier to maintain and, on the other, remove cross-browser issues in coding. Your backend language will not solve the second one. I suggest that you look at YUI's css reset file or something similar for the front-end.

Daniel
thanks for the insight on the client side
Leif
A: 

Smarty ? IMHO best template framework for separation of code. And you can still work with other frameworks.

And a thing about CodeIgniter: I asked some time ago people about it, and most says, that Kohana (based on CI) is better: http://stackoverflow.com/questions/717836/kohana-or-codeigniter

Thinker
+2  A: 

To be honest - I still prefer ASP.net, and with asp.net AJAX extensions it is (from my point of view) still the easiest, most versatile and best framework for creating web-applications.

I've tried java, jsf, gtk, spring, asp.net mvc and many other - but still. The ability to create good web pages/and application with pure asp.net still beats the others. Why? Asp.net is so well-tested... Things just work... Unlike many others where you keep hitting your head against the wall due to some stupid bug, or feature no possible to implement.

When it comes to dividing the UI, business logic and data logic - I still would say unless you need a 100% divided UI as view(MVC-pattern), asp.net is still the right choice. The dividing of code-behind and UI is good enough for most uses. People tend to yell out that MVC is much better when it comes to testing... Maybe yes... But untill now I've managed to do unit-testing without complications just as well with MVC and without MVC. It's more like instead of trying to blame it on the framework/pattern, try asking "Are we testing the right stuff - the RIGHT way...?" Set-up a good 3-layer webapplication, and you'll be creating good, easy to code web pages.

A note here: I usually receive PSD-files from my clients, which I ship to India for slicing and receive static HTML-pages. After a short modification, I'm up and running with my coded solution on the new design... Easy as that!

Now... On the other hand, it might just be because I know ASP.net the most ;)

Israr Khan
thanks for your perspective on "classic" ASP.net. Would you say that integrating the static html into your asp files is easier with "classic" than MVC?
Leif
I will say it's pretty much the same - Why? Because you either have to implement(in MVC) some HTML.helper which takes feed from the controller, or(in classic ASP.net) just use a <asp:XXXX> (where XXX is a textbox, image etc). The last one also renders in Dreamweaver and other populare WYSIWYG-editors, while HTML-helpers do not...
Israr Khan
So.. even thoug it's the "same" - having the ability to lauch your favorite html-editor, and still be able to see images, labels(text-spans), dropdownlist etc. is genius!
Israr Khan
Also - when working with code-behind/UI_files. I think(as far as I can "feel" your needs) - you do not want to clutter up the design with alot of code - right? And that's exactly what you don't have to with regular asp.net! No semi-coding or lot's of brackets here and there... It's PURE HTML, and anyone with HTML-knowledge will be able to understand the code in the UI-file. And also, for the coders, they can access all your textbox', images etc from the codebehind by using their ID-tag
Israr Khan
A: 

Seaside. In all major Smalltalks (squeak, pharo, gemstone, visual works, VA, Dolphin, gst). It helps you avoid templates, which are a major code smell when trying to separate layout from business code.

It uses a generated code (+separate css) style of working. That means that you can refactor and structure the code well. From a Seaside example:

renderContentOn: canvas
canvas form
 class: 'eventEditor';
 with:[
  self renderWhoOn: canvas;
   renderWhatOn: canvas;
   renderWhenOn: canvas;
   renderWhereOn: canvas;
   renderIsGameOn: canvas;
   renderGameTypeOn: canvas;
   renderButtonsOn: canvas]

where the canvas class is a html builder. Smalltalk has cascades (;) so first self sends renderWhoOn:, and then self sends renderWhatOn:. The renderWhoOn: method looks like this

renderWhoOn: canvas
self decorateDivAndLabel: 'Who' on: canvas around: [
 canvas select
  id: tagId;
  selected: model who;
  list: model whoList;
  callback: [:value | model who: value]]

Smalltalk has anonymous methods (blocks). The decorateDivAndLabel:on:around: method first renders itself, and then the value of its block:

decorateDivAndLabel: aString on: canvas around: aBlock
canvas div: [
 canvas label
  for: (tagId := canvas nextId);
  with: aString,':'.
 aBlock value]

(strings are combined with a comma operator instead of +).

Stephan Eggermont