[TriZPUG] web application best practices

Joseph S. Tate dragonstrider at gmail.com
Fri Nov 4 19:17:06 CET 2011


After nearly 12 years building web applications, I've only just recently
realized how to do things according to your list.  It's too easy to blur
the lines between separation of concerns in web dev, and too few developers
are well trained in the art.  Discipline is definitely required.  Using a
framework like Django or Turbogears will break your spirit because they are
not built for separation of concerns to the extent that you describe.  You
will also be discouraged by the deployment options compared to CGI or PHP,
but Python makes a a great language for web development despite these
things.

One thing you should add to that list though is some sort of offline
processing capability.  Eventually you'll have to send email or render
images and you're going to want to do that asynchronously.  Also you're
going to want to implement caching, but if you're adding caching at a
handler level or lower, you're probably doing something wrong.  Think
Varnish first, then memcache.  If you've built a SOA, you can use varnish
at the service layer for incredible speed.

A few words of caution.  Make sure you can use AJAX before going down that
road.  If not, don't give up on the (Service Oriented Architecture) SOA,
but move your page assembly to an intermediate web server.  Put your caches
as close to the user as possible.

When you learn about REST, don't treat it as the be all end all.
Streamlining specific operations outside of your REST API is a best
practice.  REST is great for generic API, but doesn't solve all problems,
and CAN'T solve problems like wholesale object modification.

Some will try to convince you that WSGI is the best thing to happen to web
development since PHP, but in practice it's just a pluggable dispatching
mechanism, and a recursive one at that.  WSGI has some very notable
limitations, and doesn't actually free you from having to do real
application dispatch.

Finally, don't fear to learn JavaScript.  It's not a bad language.  It's
not OO though, so don't try to fit that shoe on it until you understand the
prototype aspects.

Here's my preferred tool stack these days:

Server:
Varnish - http protocol level caching
RabbitMQ + Celery - offline processing
cherrypy - application server.  Easy to generate tools and engine plugins
to do Authentication and Authorization, page rendering, and other
necessaries without having to learn the wsgi stack, but compatible with
WSGI should you decide later that you need it.
mako - HTML templating.  Though my templates are so simple in my SOA that a
string replacement would work fine.  All I'm doing is setting some JS
globals for the application to load.
postgresql or mongo - data storage (SQL or No, depending on the
application).

Client:
JavascriptMVC (contains tools for building MVC applications all browser
side)
jQuery (lots of slick plugins available, and makes cross browser testing
less of a headache, but watch out for stuff that will break your separation
of concerns)

Joseph


On Fri, Nov 4, 2011 at 11:42 AM, Nathan Rice <
nathan.alexander.rice at gmail.com> wrote:

> Hi all,
>
> Though I'm not normally a web guy, my job has me doing some web
> related stuff.  As a result, I've been trying to translate standard
> software engineering best practices over as much as possible.  Since
> this is a web-dev heavy group, I'd like to hear from other people
> about what they consider best practices.
>
> My current list of web application specific things...
>
> 1. separate client side and server side cleanly using services.
> 2. avoid generating client specific code on the server as much as possible.
> 3. separate out complex page elements into their own pages, then pull
> them in to a main page with an ajax load.
> 4. Do not put ANY logic in your request handlers.  Just use them to
> collect and validate any URL arguments or post values, manage
> security, then call a separate function and generate a response from
> the result of that.
> 5. Avoid hand coding presentation functions for every class
> separately.  Create middleware layers, and implement functions on
> divergent classes that let the middleware generate the proper results.
>
>
> Nathan
> _______________________________________________
> TriZPUG mailing list
> TriZPUG at python.org
> http://mail.python.org/mailman/listinfo/trizpug
> http://trizpug.org is the Triangle Zope and Python Users Group
>



-- 
Joseph Tate
Personal e-mail: jtate AT dragonstrider DOT com
Web: http://www.dragonstrider.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/trizpug/attachments/20111104/f0f989b4/attachment-0001.html>


More information about the TriZPUG mailing list