Web Applications And Xp

A WebApplication is loosely defined as a piece of software following the standard Web application architecture and deployment model:

Web Browser <-- HTTP --> Web Server <-- SQL --> Database

This architecture poses specific challenges for an ExtremeProgramming ("XP") process. This WikiPage is meant to describe advice in meeting these challenges.

It was spawned from a thread on the xp list: http://groups.yahoo.com/group/extremeprogramming/message/70945?threaded=1

DaveHoover: There is a book on the topic (see ExtremeProgrammingForWebProjects). I haven't read it. I am interested in hearing if anyone else found it helpful. http://safari.informit.com/?XmlId=0-201-79427-6

Carlton:

I've read it. It is mostly OK. Nothing really bad and few good ideas. IMO, the AW books are starting to get repetitive.

I pulled two ideas from this book. One was a technique to separate your business logic from your presentation layer. Nothing really new to me, since that is a struggle in ALL web applications. The second idea was that indeed, in large web applications, you are going to have some specialization. The main specializations I have observed are the programmer/graphic designer divide. The types of experience and knowledge required make it almost impossible to cross this division.

AlexChaffee:

In practical terms, here are some things I've done that make XP's practices work better in a web project:

CurtisCooley: Critical in all applications, but web apps really can bite you hard when you cheat. Use struts or XMLC to keep these layers separate. We've gotten really good at unit testing Struts actions and it has paid us back many times over.

CurtisCooley: JWebUnit is your friend

For an example of that last point, if you have a page that must do a search, sort the results by date, and return the items on the Nth page of the results list, don't have the page perform the search or even select the subset! Instead, the page template should just tell your business logic the parameters and page number, ask it for an array of objects, and render them in the order returned.

CurtisCooley: We had a great DBA who wrote PlSQL for the complex database logic. Like you, I thought this was a bad idea. But he embraced XP and wrote his own set of tests and kept the database code cleaner than we kept the Java code. We were tied to Oracle (though it really wouldn't have been that much work to switch), but we were very grateful to not have to ever worry about the DB. All we did was call the correct stored procedure, and that was unit testable.

If you have a DBA like this, you are truly blessed, so take full advantage. If not, then heed Alex's advice and keep all the code in the same language.

See MartinFowler's great article on EvolutionaryDatabaseDesign? at http://www.martinfowler.com/articles/evodb.html

GeorgePaci:

AlexChaffee: I echo the recommendation for CVS and CSS. I'd also like to give a shout out for id attributes. Identifying your page data elements makes your tests much more straightforward and minimizes tedious HTML parsing/analysis. Also the span tag is good for identifying just the relevant bits of your page data without messing with page layout. E.g.

 <span id='customerName'>Tommy Franks</span>

Also XpathLanguage is a good weapon to add to your testing arsenal; the above is located using "//span[@id='customerName']" . See my http://www.xpathexplorer.com .

How to use XPath in PythonUnit:

 import unittest, urllib
 from xml.xpath import Evaluate
 import xml.dom.minidom
 class IndexTest?(unittest.TestCase):
     def __init__(self, methodName='runTest'):
         unittest.TestCase.__init__(self, methodName)
         self.content = urllib.urlopen('http://localhost/~user/sandbox/').read()
         self.dom = xml.dom.minidom.parseString(self.content)

def testTitle(self): assert Evaluate('/html/head[title="Page Title"]', self.dom)

We use XPath for the most part, but also do occasional RegularExpressionMatchAssertion against self.content, particularly negative testing (regression testing for things we've removed on purpose). -- KenBitskoMacLeod

EditText of this page (last edited February 28, 2006) or FindPage with title or text search