Archive for the 'Software Design' Category

Javascript Testing Talk in Oakland

Next week at EBig Jonah and I are wrapping up our world tour of talking about Javascript testing. March 17th in Oakland: ”Recent evolutions in Javascript testing frameworks now allow creating test suites, test-driving development, and running tests on a continuous integration server. This allows us to support more complex Javascript, have confidence in the implementation, and push more of the logic from the server into the browser, reducing the load on the server.” The focus of the talk is walking through a suite of tests we build for a real-world example.

For those of you who caught it last week at the SDForum, here are the links people requested:

To sign up for next Wednesday, go to the EBig site.

Test-Driven JavaScript with ScrewUnit and BlueRidge

Jonah and I are taking our presentation about Javascript Testing on the road next Tuesday at 6:30 in Palo Alto, at the SDForum

The teaser for it… Recent evolutions in JavaScript testing frameworks now allow creating test suites, test-driving development, and running tests on a continuous integration server. This allows us to support more complex JavaScript, have confidence in the implementation, and push more of the logic from the server into the browser, reducing the load on the server…

Hope to see you there.

Agile Modeling Techniques for Story Writing

At Carbon Five, all our projects begin with ‘customer facing’ meetings focused around determining scope and expectations. A core component of these early meetings involves one or more story writing sessions. The end goal of story writing sessions is to have most user stories in a project documented (i.e. in Pivotal Tracker) regardless of whether you have a requirements document or not. Story writing sessions are informal and conversational in nature, where information from customers are digested by a Team Lead and converted into stories. Most of the time, I compile user stories as a linear list in Tracker (displayed on the wall using a projector) while discussing functionality with a customer. However, sometimes customers have a difficult time ‘connecting the dots’ because of the linear nature of a list.       

On those occasions, I supplement my list in Tracker with another technique for capturing user stories. It involves modeling using a UML IDE. Primarily, I use Activity Diagrams because they capture behavior using ‘actions’ and allow for flow. Because activity diagrams are essentially flow charts, they provide a simple comprehension mechanism for all customers regardless of their technical background. I usually display my desktop in the conference room using a projector and interactively add elements to the diagram as I receive customer input. For demonstrating modeling techniques, I will use a ‘Music Store’ web application as an example.

Summary of Steps:

  1. Create an Activity Diagram from a High-Level Functional Requirement.
  2. Capture Customer Input for Identified Functional Requirement.
  3. Model Flow for Activity, Link Actions with Diagram Elements.
  4. Aggregate Similar Actions to Separate Activity.
  5. Convert Activity Diagram into User Stories.
  6. Repeat Steps until all Functional Requirements are Exhausted.

Step 1: Create an Activity Diagram from a High-Level Functional Requirement

Start with a known high-level functional requirement and create an Activity diagram. When starting, I will identify a large chunk of functionality that I know to be required for the project and use that as a discussion point with the audience. For my sample Music Store project, I would choose ‘Browsing the Inventory’ as a large piece of functionality. At this point, the audience might begin to shout out other large pieces of functionality (i.e. ‘Customers can create accounts’, ‘Employees can add to inventory’). If this occurs, I like to create empty Activity diagrams named appropriately. These large pieces of functionality will eventually be decomposed into smaller, more manageable, Activities and Actions.

 

High-Level Functional Requirement as an Activity

Step 2: Capture Customer Input for Identified Functional Requirement

Gather input from the audience regarding this Activity / functional requirement and capture pertinent information as Actions. Essentially, what you are trying to do here is decompose the larger ‘Browsing the Inventory’ functional requirement into smaller ones. Make an attempt to name each of the Actions with story-like syntax (i.e. ‘As a <role> I can <result> so that <benefit>’). The goal of this step is to create a catalog of smaller functional requirements so that you can start modeling flow.

Capturing Smaller Functional Requirements as Actions

Step 3: Model Flow for Activity, Link Actions with Diagram Elements

Start modeling flow for this Activity, linking Actions with other diagram elements. All Activities must have a start as well as an end point. I model my Activities so that my flow is complete. This ensures that all known paths have been captured. This step is crucial in capturing all known functionality for the high-level requirement.

Remember that this is an interactive step with the audience. The audience / customer will provide input as to the flow of the Activity from Action to Action.

Adding Flow to Activity

Adding Flow to Activity

Step 4: Aggregate Similar Actions to Separate Activity

If the diagram begins to flow outside of your viewable area, this is an indicator for breaking out one or more actions into a separate Activity. Several actions can be converted into one abstract action that encompasses all the functionality provided by all those actions. In the figure in step 3, the Action ‘Purchase an Item’, was created to represent another Activity diagram. The separate Activity diagram that I created was named ‘Purchasing an Item’ and contains the detailed flow for that functionality.

This step is reliant on the Tech Lead’s skill to identify similar areas of responsibility within the activity. 

Step 5: Convert Activity Diagram into User Stories

After one Activity diagram is fairly complete, begin entering them into Tracker as Stories. Each Action should be converted into a user story using a consistent syntax (i.e. ‘As a <role> I can <result> so that <benefit>’).

 

Convert Action elements into User Stories

Convert Action elements into User Stories

User Story list with Activities as Milestones

User Story list with Activities as Milestones

 

Step 6: Repeat Steps until all Functional Requirements are Exhausted

Steps 1-5 must be repeated until all high-level functional requirements have been modeled as Activities during discussion. In the end, I will have a catalog of Activity diagrams. In the figure below, a Package Diagram displays all the Activity Diagrams that I have modeled. I like to use each of the Activities as a milestone during planning. This may or may not be ideal depending on how granular your functional requirements are.

Inventory of Activities as Milestones

Package Diagram: Inventory of Activities as Milestones

 

Conclusion

There are many arguments against modeling in the agile communities, so it is important to view modeling as being supplemental to the process. In the end, our models are used to aid in the process of conveying and gathering information with the customer. Some other benefits include:

  • The diagrams can serve as a documentation deliverable
  • Interactive modeling along with the diagrams, which serve as a visual aid, improves customer comprehension of our software development process
  • This is a great way to capture requirements when none exist
  • The Activity diagram allows us to write stories in a format that follows an accompanied wireframe (if available)
  • User roles can be added to Activity diagrams as swimlanes (partitions). This aids in separating functionality by use case

Designing Remote Service APIs

I’ve been meaning to bring an ongoing discussion about remote API design to this forum. A recent post to the Caucho hessian-interest mailing list prompted me to write a response that I am essentially reposting here.

The question at hand is what is the best approach for designing, publishing and versioning remote service APIs. Through my experiences designing and programming against remote service APIs I’ve come to develop the following opinion.

If you are developing remote APIs for a known and manageable set of clients, exposing your fine grained object model through the API over a mechanism like SOAP/Hessian makes for rapid development and easy integration.
Being able to rev your object model and have the changes show up in the API is a benefit in this case since you do not have to manage a translation layer to DTOs, XML or something else.

If you are developing remote APIs for an unknown and unmanageable set of clients, you need a layer between your internal object model and the model exposed to the clients. This allows you to rev your internal model while keeping the external interface consistent. Of course, you then have to maintain the translation.

I have seen this second approach addressed well using SOAP by
Salesforce.com in their remote APIs. They expose an object model in their APIs that is explicitly designed for remote use.

To manage versioning Salesforce makes different WSDL available for different versions of the API. Using different WSDL gives you access to different versions of the service. I’m not sure of the versioning mechanism but it could be either contained in the SOAP session that you establish with Salesforce or simply be a different end point for accessing the service.

Different end points for different versions seems like one good way to manage versioning your services, if you want to support multiple versions. Clients opt in to a version by choosing an end point.

I have also seen this second approach addressed well by Flickr in their RESTful XML APIs. Flickr does not seem to have addressed versioning and simply has kept their APIs ‘in beta’ to allow them to rev the APIs without supporting old versions.

The success of Flickr in getting the general developer community to use their APIs has led me to the conclusion that if you want people to use your APIs v. providing them because users are demanding them, then a custom, well documented XML-over-HTTP API will be most successful. Clients have to write more code but the code they have to write is obvious by looking at the APIs.

If you use a SOAP/Hessian/Burlap implementation that will convert your object model to a wire format for communication between server and client, you then need to maintain an object model for your API separately from your internal object model. I’m starting to think that if you are maintaining a translation between an internal and public model, you may as well have that public model be XML based. Remember, I’m talking about the case where you a supporting an unknown and unmanageable set of heterogeneous clients.

I’d prefer that developers of remote clients all wanted to use SOAP (or Hessian or Burlap) but it just doesn’t seem to be that way. In the enterprise developer community, sure, but what about people writing Flash and Javascript clients of which there are increasing numbers every day.

I’m very interested to hear what others have to say on this topic.