views:

768

answers:

14

There are a lot of web application frameworks out there, based in Java/Ruby/Python/PHP amongst others. I'm keen to discover, compare and contrast features that are unique to individual frameworks.

Which framework feature do you think is useful and why is it important to know about?

e.g.

Can you please limit to one feature per post.

Summary:

  • Stripes - Flash Scope
  • Django - JSONified variables in templates
  • Symfony - model generation. Backend administration generation
  • Grails - Powerful ORM in the form of GORM
  • Seaside - no relational database, just code OO
  • Sinatra - Minimalism
  • Spring Web Flow - Flow and view scope
+1  A: 

You should know how to write custom template tags in Django. For example, the following tag lets me JSONify Django variables in the template.

@register.filter
def jsonify(o):
  return mark_safe(simplejson.dumps(o))

This is useful because my website is all Javascript, so I use the Django templates to make a no-script version of the site as well. This is mostly useful so Google can crawl my site. For example, look at the following page with Javascript on and off: http://www.trailbehind.com/Yosemite%20National%20Park/

Here's some other useful tags I have:

@register.filter
def attr_name(id):
  return util.get_attribute(id).name


@register.filter
def dashes(name):
  return name.replace(' ', '-')

And doesn't Python's decorator syntax make these short and sweet?

Andrew Johnson
Might want to fix your link.
Chris Kaminski
A: 

Hum... I am a PHP developer for about 15 years. Look at Rails (Ruby on Rails) framework. It has some unique features like database migrations, implementation of interfaces differs from languages like Java, PHP and others, configuration files are not like ini files (you can write code).

Hope it helps.

xpepermint
Can you specify one specific feature in Rails please that you think it important and a description rather than a list of framework features.
Jon
Sorry, there's no way you could have been a PHP dev for 15 years.
davethegr8
+3  A: 
Jon Winstanley
About the command line, Zend Framework is beginning to use it too, since v1.8 (and it really a good thing ; only whish it did before) ; about the model-related point, it's because symfony is using Doctrine as ORM, and it can be used with other frameworks as well (I've used it with ZF) ; no opinion about YAML files ; the best thing symfony has (from what you talked about), in my opinion, is it's admin generator -- that one is really great stuff (and I really would like having it in ZF ^^ )
Pascal MARTIN
Can you specify one specific feature in Symfony please that you think is important. The admin generation stuff sounds pretty awesome...
Jon
For me, the autogenerated model is even better than the admin generator. I can make a change to my database then ask Symfony to re-generate the schema and rebuild the model. I will then have access to a complete set of objects based on the new schema. Including basic setters and getters plus functions such as new, hydrate, save, findById etc. Also, only base classes are overridden, any extended code I have written is left as it was.
Jon Winstanley
+2  A: 

Minimalism of Sinatra. You can write entire web application in only one file. (Obviously, this is no way for large applications, but for rapid prototyping, small sites and web services it's great to have everything in one place.)

Lukas Stejskal
I hear you... coming from a Java web application perspective and picking up something like Django or Sinatra is refreshing... there's a certain element of over-engineered frameworks in the Java world...
Jon
+1 for Sinatra. It's nice to use with small projects and prototyping. Also, it's agnostic, so you can use whichever ORM, view renderer, etc that you wish.
JimNeath
+1  A: 

Seaside in Smalltalk supports refactoring and goto-less programming. Component based and no templates means you can avoid a lot of duplication.

Stephan Eggermont
+2  A: 
Rodrigo Rivera
+1 for the gigantic Grails icon. That's tremendous!
Mike Sickler
+1  A: 

Seaside, not having to bother with a relational database (SandstoneDB, Magma or Gemstone), allows the writing of OO code instead of database code with some methods.

Stephan Eggermont
+1  A: 

Spring Web Flow - Serialized conversations / great browser back button support

Supporting the browser back button and history is a headache with most web apps out there, simply because it's too easy for the client's perceived state / page to get out of sync with what's on the server.

SWF solves this by creating snapshots of the entire conversation state each time a view is rendered. Most stateful data is stored in one of SWF's additional scopes (conversation, flow, view), and is thus serialized with the conversation snapshot.

SWF's URLs don't identify a resource like a page or an action. Instead, they identify a flow and a conversation. Since SWF implements POST-REDIRECT-GET implicitly, each time a page is rendered the URL contains the flowExecutionId, which uniquely identifies the conversation and the serialized conversation snapshot. Thus, as the user uses the browser back button or history, each URL actually restores the entire conversation state at that point in time.

This results in ideal back button handling: client state is never out of sync with conversation state, and the user can freely continue from any previous state.

Developers can also discard or invalidate history (saved snapshots) when users perform certain actions. This is good for user actions which modify something in the database, since the user should not have the ability to go back to a state which doesn't represent what's in the database.

The developer can restrict exactly how many snapshots to save. Since hard drive capacity is plentiful, especially in comparison to memory, it's a fairly neat solution.

One major restriction, however, is that any attribute placed in conversation, flow, or view scope must be Serializable.

InverseFalcon
+1  A: 

Spring Web Flow - Flow and view scope

Most web apps are content to use the Servlet defined scopes of request, session, and context. However, much of the stateful data used in a web app doesn't quite fit into any of these scopes. Typically, such data lasts longer than a single request, but shorter than a session. Session scope is usually used in this case. This forces the developer to essentially perform manual memory management to place things into session scope, and then explicitly remove them when they are no longer needed for that portion of the application. This can be troublesome, as there are usually multiple places where attributes must be removed, as there are often several actions that the user can invoke to take them out of the use case where the attributes are needed.

In large or growing applications, attribute cleanup code becomes a necessary and pervasive clutter throughout the code. Forgetting to clean up attributes, or cleaning up the wrong ones by mistake, can introduce bugs.

SWF solves this by providing some additional scopes which better fit the life cycle of application attributes.

SWF introduces the concepts of flows, which are reusable modular groupings of behavior represented as a state machine consisting of states and transitions between them. A flow may include action-states for invoking server-side behavior, view-states for rendering pages to the user, and others. Flows often represent use cases. Flow-scoped attributes persist for the duration of the flow, and are cleaned up automatically when the flow ends. This results in attributes which only persist for the duration of the use case where they are needed.

ViewStates within a flow render a view to the user. Transitions from a viewState may navigate to a different state or can remain in the same viewState, rerendering the view (with or without AJAX) after performing some actions. Attributes in viewScope persist while control remains in the viewState. ViewScoped attributes survive browser refreshes, and are useful for data that is relevant only for the view being rendered, such as data which is used in AJAX requests, or for flags which influence the markup in some way. When a transition is invoked which leaves the viewState, viewScoped attributes are cleaned up.

In summary, SWF's additional scopes better fit the lifecycle of application attributes, and using these additional scopes removes the need to manually manage your attributes, resulting in less attribute-juggling plumbing code throughout your app and less potential for bugs.

InverseFalcon
A: 
hobodave
+2  A: 

Django's built-in admin is probably its killer feature as far as adoption is concerned. Write your db models, register them, and start entering data. Customize if needed. It's easy enough that I use it on non-django projects all the time.

jcdyer
+1  A: 
RaYell
Cake returns layered associated arrays, which are a nightmare, you can set a recursive flag (??!) that will get the base level (target object only) or n levels deep (objects linked to objects linked to the target object) arrays which are unwieldy to say the least.If you are building an app bigger than a simple blog it is better to use $Object->query() and take control away from cake to get any response times near respectable.Cake? no thanks i'm full.
Question Mark
I found CakePHP pretty good for building small scale websites, the associative arrays can be a pain to parse, the upgrade path is bizarre to say the least... but on the whole pretty good...
Jon
A: 

Icefaces has a powerful scalable ajax push framework

Dani Cricco
A: 

Uhhhh, hello? ASP.NET all the way baby!!!

Janie