To narrow the boundaries of the required solution, we extract the basic
requirements from the customer's story:
Standard-conformance
Parser implementation
Access to URL parts
Now we do some initial analysis on these facts:
Standard conformance
Internet Standards are written down in Requests for Comments (RFCs).
RFC 2396 provides the necessary grammar
to parse ASCII-based URLs and URIs. Other character sets are covered in different
RFCs and are not part of the tutorial project.
Parser implementation
The fastest solution would be to run a parser generator on a suitable
version of the RFC grammar. The result would usually be a class which provides
a parser method creating a syntax tree from an input stream. Custom code
would create the required output data based on the syntax tree during the parsing
process.
For the tutorial I prefer a manual parser
implementation because of the unreadable code created by most parser
generators. From a theoretic viewpoint, a grammar consists of rules
which have a left-hand (LHS) and a right-hand side (RHS). A common way to
implement such a grammar by hand is to write one function per left-hand
side of the grammar if all LHSs are realized by single variables. This
condition is met by the given grammar.
Access to URL parts
The common approach is to provide a class with accessor methods to
read and write it's attributes.
Now XP breaks down the stories into small tasks which can be done by
developers in a resonable times. The tutorial application is
small enough to be implemented as one task. Let's define the implementation
as first task and the functional tests as second task. The first task will
be carried out by the developer of the application, the second by a dedicated tester.
The analysis has shown the impact of the customer's story from the viewpoint
of software development. With this knowledge, we can now start an
initial design.