Search
Thursday, September 09, 2010 ..:: Blogs ::..   Login


Search Blog
 Most Recent Blogs - see full blog on Blog page Minimize

Jun 28

Written by: Eric Bell
6/28/2010 8:16 PM 

WSSF (Web Service Software Factory by Microsoft) is a neat DSL that can be a little hard to understrand. If you understand this technology and have to teach it to someone else, here's how.

WSSF from Microsoft Patterns and Practices group is a DSL (domain specific language) creating WCF and ASMX web service projects, using best practices, and round-trip engineering all for free. The catch is that it's not that well documented so picking it up on your own takes some work. However, once understood it can be taugh so that it's picked up fast. Assuming you have your project based on WSSF models, you've integrated elements that need to be explained too. These will be service implementations, business entities, business logic and data access components. They need to be taught as well and in context of the WSSF structure. However, how do you teach WSSF or any technology?

This article will show you how to teach it and by extension other technologies.

NOTE: If you don't understand web services you are at a disadvantage and should get that understanding first elsewhere.

If you don't understand WSSF - this article won't go there either. This article is about how to teach not WSSF, WSSF is just an exmaplewe started with in teaching technology. I will have more articles on WSSF and modeling technologies later. Back to your course.

Your course can be structured over a short period of time, say two days where each day you are instructing for 4 hours or so. Other technologies require larger investments in time but WSSF is a DSL and these should be short courses due to the sophistication of the product (WSSF in this case).

Prerequisite for the instructor: you have to know the DSL. Period. In this case WSSF. Learning it on you own can take some time due to the paucity of documentation however once you've learned it teaching it they way it's laid out here can convery the information very quickly.

Here's the course layout:

  1. What is WSSF and what is produced by WSSF? - create a sample do-nothing solution showing all the projects, where the generated code is, create a service model, a data model and a host. This takes upwards of two hours.
  2. Pick a simple project for your student(s) to build. Examples are a simplfied bank or simplified restaurant. See the examples afterwards - they were pulled out of thin air at the time.
  3. Start your student in this example, help them create the design for this simplistic application. Use a static in-memory structure for the data source, use other simple objects to do the work. Don't make this a real bank or restaurant, just enough of an application so that they model, code, fix the model, fix the code and learn. This exercise is home-work and is due the next day.
  4. Next day, review their application, make suggestions if needed and move on to your project that uses WSSF. Go over your design, if you have one, and discuss your project in terms of WSSF now that they have an understanding. Fini.

Conclusion

This approach and layout may seem overly simplistic however being someone who has taught many classes in technology and to business, this approach for DSLs is just right. The point of a DSL is to engender high productivity and simply the problem space. As such the learning curve of the DSL should not be too difficult generally and my approach introduces the concepts, works through an impromptu simple application (and the power of an impromptu example can not be overstated getting the studuents to understand the material) and then has the instructor continue to integrate the project at hand using the DSL.

These two examples were utterly impromptu at the time. I didn't know what the requirements nor design were however in minutes each were drafted on whiteboards with no trouble at all. Principally because the point of the exercise was not the example (a bank or a restaurant) but learning the DSL. As such corners were cut everywhere in the examples yet the students grasped everything immediately. Strong focus helps - focus on the DSL, not the app.

Simple Bank Example

The simple bank example represents a few capabilities of a bank namely create an account, add money to it, withdraw money from it, get balance. In terms of a web service built with WSSF this is perfect and will teach the student modeling, coding and round-trip engineering.

Requirements

  1. User can open an account and when they do so they must make an opening deposit.
  2. User can deposit addition funds.
  3. User can withdraw funds but balance can never go below  0.
  4. User can get a balance.
  5. Extra-credit. Maintain a transaction history and allow user to obtain the history as a set of records.

Nominally this requires one host, one service contract, a number of entities and data contracts. All three models (host, service contract and data contract) will be used giving the student exposure to all of the WSSF tools.

Entities

  • Bank - holds the accounts.
  • Account - holds the balance.
  • Transaction - an account reference and an amount of money.

Message Contracts

void OpenAccount(Name:string, Amount:double) - creates an account for Name user and deposits Amount. If the Named already exists, fault.

Balance:double Deposit(Name:string, Amount:double) - adds Amount to the balance and returns the balance. If the Name account does not exist, fault.

Balance:double Withdraw(Name:string, Amount:double) - removes Amount from the balance and returns the balance. If the Name account does not exist, fault. If removing Amount would dip the balance below 0, fault.

Balance:double GetBalance(Name:string) - return the balance. If the Name account does not exist, fault.

Simple Restaurant Example

This is example mimics the simplified review of the menu, choosing items making up an order, ordering and paying your bill.

Requirements

  1. "See" a menu of items to order.
  2. Order items however there are only a certain quantity on hand, if an order exceeds the quantity, reject the order.
  3. Get the bill which is an itemized list of items ordered with prices and total.

Entities

  • Pantry - a list of the items on the menu, along with initial quantities and per item price.
  • Menu - a list of items and prices derived from the Pantry.
  • Order - the list of items per user.
  • Bill - the list of items served along with prices and a single, total price.

Message Contracts

  • Menu:menu SeeMenu() - returns the menu, a list of items and prices.
  • OrderNumber:int Order(List) - return a number assocated with the order if the list of items are in the pantry. If one or more items cannot be ordered, fault.
  • Bill:bill GetBill(OrderNumber:int) - return the bill for order number. The bill is a list of items and prices ordered and single total price.

 

Tags:

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 

  

Copyright 2006-2009 by Polymorph Corporation   Terms Of Use  Privacy Statement