AgileStudio Pet Shop Benchmark


Contents


1:   Abstract
2:   Comparison of lines of Code Required
3:   Introduction
4:   Functional Walkthrough
5:   Developing with AgileStudio
6:   AgileStudio Features used in developing the Pet Shop Application
7:   Pet Shop Object Model
8:   Page Navigation
9:   Additional Functionality included with AgileStudio Petshop
10: Conclusion

Appendix 1: Stored Procs List
Appendix 2: Automatically Generated SQL Server Tables
Appendix 3: Manual Coding
Appendix 4: Sample of Automatically Generated SQL Update Code
Appendix 5: Pet Shop Project Files


1: Abstract

The enclosed study takes the Microsoft implementation of Sun's primary J2EE blueprint application , the Sun Java Pet Store and implements the same functionality using the AgileStudio addin for Visual Studio.NET. Additional functionality has been added to the application in particular data driven menus, administration screens, enhanced validation and calculations, to demonstrate the programming efficiency gained using AgileStudio. Even with all this additional functionality, the total lines of manual code required to produce the AgileStudio Pet Shop benchmark has been reduced by 90% to a remarkable 206 lines across all tiers.

AgileStudio does not have any built in support for shopping carts. The enclosed Pet Shop benchmark is built using AgileStudio general functionality for building Windows and Web applications. AgileStudio handles a lot of routine tasks like the building of DataSets and Stored Procs and the binding of user interface controls. This allows developers to concentrate almost exclusively on application domain specific code.

The above Trademarks and those referred to in this document are the property of their respective owners


2: Comparison of lines of Code Required


The Pet Shop benchmark has been produced using the AgileStudio addin for VisualStudio.NET with 90% less manual coding than the .NET only implementation.



*.NET and J2EE figures are based on Microsoft's "Using .NET to Implement Sun Microsystems' Java Pet Store J2EE BluePrint Application". Click here to view.

The table below provides a breakdown of lines of code by tier for three implementations of the Pet Shop benchmark. There is no requirement for manual coding of the middle tier in the AgileStudio Pet Shop as this is handled by the DataStore Manager. Manual coding extensions of the middle tier are possible but not required for this application.



3: Introduction

The Pet Shop benchmark provides an ideal opportunity to showcase the powerful general functionality of AgileStudio to accelerates the development of Windows and Web data driven applications. The application project includes 22 Web Pages, 5 Web Controls and 22 Typed DataSets and encompasses a wide range of functionality. 12 AgileStudio Objects are used to automatically generate 14 SqlServer tables and numerous Stored Procedures. Try out the hosted demo of the AgileStudio Pet Shop application here.

Here the DataStore manager is linked directly into the application. It can also be installed as a seperate service where this is appropriate.

You can also Download a 30 day trial of the AgileStudio addin for Visual Studio.NET 2003 and install the Pet Shop sample.
In this document we detail the structure of the AgileStudio Pet Shop application and outline some of the features used to accelerate the development process.

4: Functional Walkthrough

The basic functions of the Pet Shop Application.
(Additional features added to the Pet Shop application are detailed in Section 9 )

A typical session using the Pet Shop may involve:





5: Developing with AgileStudio

AgileStudio is a tightly integrated addin which extends Visual Studio.NET to accelerate the development of Windows and Web Database Applications. See the sample Walkthroughs (No Download Required), for step by step building of such applications
AgileStudio:

AgileStudio employs a high level abstract object model which is sufficiently expressive to describe complex real world situations. The model allows for objects to be both internally hierarchical and also have the ability to refer to each other relationally. The object model is constructed using only items that appear in the real business world, without showing any underlying plumbing required by a specific data store implementation. The data situation is modeled with 4 basic elements - Objects, Items, Lists and Links.


The AgileStudio Pet Shop application makes use of a number of Views that are specified for an Object. AgileStudio Views can be used to build fixed reports or reports that have parameters determined at runtime. These Views can be easily and quickly modified through the View Collection Editor without requiring hand coding.



AgileStudio works with standard Windows or Web Projects and your choice of managed language. The AutoBind ToolBox Tab provides a set of Controls that are specific to the currently selected Object Item and the currently active Form. When a Control is dropped on the form, binding of the most commonly used properties to the DataSet is handled automatically for both simple and complex bindings.

 

AgileStudio automatically manages:





6: AgileStudio Features used in developing the Pet Shop Application

Below are some of the efficient and powerful AgileStudio features employed while developing the Pet Shop Application.

  1. Automatic generation of Sql Server Tables and Relations

    The Object Model is generated from intuitive Objects, Lists, Links and Simple Items. Saving the Object Model and the SQL Server tables are automatically generated, modified and updated without any requirement to modify Keys, Indexes, Relations or Constraints.


  2. Complex Calculated Expressions Produced with Ease

    The Expression Editor is envoked through the standard VisualStudio.NET Properties Window. The expression is formed by selecting Items from the current Object or from across links to an associated Object to easily produce complex expressions. The Shipping Method selection and calculation of associated cost is additional functionality added to the PetShop benchmark to demonstrate the ease of building expressions.


  3. Hyperlinks automatically pass id as part of the url

    One of the Controls provided by the AutoBind ToolBox Tab is a "smart" Hyperlink. On dropping the Hyperlink, a dialog allows selection of the target form. At runtime when the Hyperlink is clicked a query parameter is automatically appended to the target URL. This can then be processed by the DataSetManager Initial Action on the target form, allowing the selected row(s) to be displayed.



    The Text Property of the Hyperlink is bound by default, but this can be easily changed to an ImageUrl binding through ObjectBindings in the Property Editor. This feature is used on the Pet Shop home page to allow Category navigation by clicking on the Category Images.

    In the Petshop example below clicking on a category image on the home page determines which rows are returned for the "Products of a Specific Category" View.


  4. Conditional Visibility Property

    AgileStudio supports the conditional visibility of controls using the VisibleWhen property.



    Selecting a Country other than the USA and the State DropDownList is replaced by a Province TextBox as determined by the Province VisibleWhen expression.



  5. AgileStudio Validation Support

    AgileStudio incorporates strong data validation features with no requirement for manual coding.



    Five types of data validation are provided:
    • Required.
    • Unique.
    • Range for example for items of type System.Int32 or System.DateTime.
    • Validation Expression with a custom message.
    • Multiuser

    Below is an example of Required Validation being used in the Pet Shop application.



    The validation style above is the type generally used for user screens. Below is an example of a validation failure for a product administration page. This highlights all fields which have failed validation with specific validation messages available as hover hints. In this case, the Product ID is set as Unique and the PictureName is a required field.

    Other styles can be easily implemented.



    Below is an example of a custom Validation Expression failure.



    Complex validation expressions can be easily construction using the expression editor by selecting items from across links to other associated Objects. The expression below returns a validation failure if the delivery option choosen is not compatible with the delivery address. (The expression below is complicated by the fact that IIF is not an intrinsic function of Transact SQL).



  6. Calling User Defined Functions in SqlServer

    AgileStudio is an Open development tool. Below is an example of calling a User Defined Function in SqlServer from a calculated Item. In the Microsoft PetShop application only the Item attribute appears in the Shopping Cart i.e. Male Adult for the example below. In the AgileStudio Pet Shop application, the function below is used to append the Product Name, i.e. Bulldog.



  7. Search View



    The Search function in the Pet Shop application is implemented using AgileStudio functionality without a requirement for manual coding. A View aggregating the Product Name, Product ID and the Category Name fields is constructed. Note that the Category Name data is pulled from across the Link to the Category Object.



  8. Automatic Conditional Enablement of Buttons

    AgileStudio provides automatically data bound buttons for navigating lists which can be dropped onto Windows and Web Forms. The button enablement is automatically set as determined by the position in the record set.



  9. Adding additional bindings

    The most relevent property is automatically data bound when a control is dropped on a form from the AutoBind ToolBox Tab. In most cases this is the Text property. Additional data bindings can be added using ObjectBindings in the Property Editor.

    An example of an additional data binding is the Tooltip Property for the Category Image on the home page. Opening ObjectBindings in the Property Editor the ToolTip is data bound to the Category Name across the Link to the Category object.



  10. Update Actions

    Update Actions can be used to automatically make additional changes to the DataStore when a record is saved.
    • Updating Stock Quantity

      The Stock Quantity is ammended after completion of an order.



    • Updating Billing Address

      The Update Action below replaces the previous User Billing Address with the new Billing Address used for the current order. It is assumed that Delivery address will change from order to order.



  11. Next and Previous Paging Buttons

    AgileStudio provides stateless Next and Previous paging buttons to ensure applications are scaleable. As determined by the Page Size property of DateSetManager automatically data bound Next and Previous record set buttons are available for dropping on the Form. AgileStudio paging control is stateless and does not use database cursors or server side objects to keep track of position. Hence applications are higher performance and very scalable. Regardless of the query or the order of records the efficient Stored Procs produced by AgileStudio can produce the appropriate page of records satisifying the query.



    In the Pet Shop example below the paging size has been set to 4 for the Search results page.



  12. Extending the DataSetManager With Event Handlers

    The DataSetManager can be easily extended with Event Handlers to suit specific applications. An example used in the AgileStudio Pet Shop application is the AfterPerformAction event handler which clears out the CartId after check out and also passes the ID to the Order Page to display the processed cart.

    private void agilepagesDataSetManager1_AfterPerformAction(object sender, 
    Sekos.Data.AgilepagesClient.AfterActionEventArgs args)
    {
    	#region hand-coded
    	if (args.Action=="Save")
    	{
    		string cartId= this.Request.Cookies["CartId"].Value;
    		this.Response.Cookies["CartId"].Value= "";
    		this.Response.Redirect("Order.aspx?id="+cartId,true);
    	}
    	#endregion hand-coded
    }
    						

7: Pet Shop Object Model

The diagram below details the Object model for AgileStudio Pet Shop benchmark.



8: Page Navigation

The diagram below details the page navigation that would occur in a typical user session.





9: Additional Functionality included with AgileStudio Petshop

The original Microsoft .NET Pet Shop has been expanded to demonstrate the efficency of using AgileStudio to produce a complete working application with only a few extra lines of domain specific code. This application, like all applications developed using AgileStudio, is fully open and extensible.

  1. Data Driven Menus

    The original Microsoft .NET Pet Shop has hardcoded menus which is inflexible requiring a site redesign whenever the inventory is changed. The AgileStudio Pet Shop menus and sidebars are totally data driven. Changes to Categories and Products are displayed immediately.


  2. My Orders

    We have added a page to display summary details of all orders for the logged on User. Clicking on the order ID displays the full order details.


  3. Administration Pages

    We have added Administration pages which are accessible when logged on as an Administrator. These allow the maintenance of Users, Products, Categories and Suppliers. The Products page involves a "master-detail" record set with a child DataList to edit the Product Items. Support code to handle this is automatically generated by AgileStudio.


  4. FullFill Orders

    This option is available to an Administrator to display the list of Orders which have not yet been shipped. Clicking on the Order ID displays its details for fullfillment purposes. The status can then be changed from Pending to Shipped.


  5. Shipping Cost

    We added Shipping cost to the cart to demonstrate a calculated expression involving Links. This example generates the Shipping Cost using the "Percentage Extra Cost" Item in the "Shipping Methods" Object.


  6. Conditional Visibility

    Addresses in the .NET version of the Pet Shop force the entry of a State even when the Country is not set to the USA. Every address (Billing, Shipping, User and Supplier) in the AgileStudio version makes use of conditional visibility. Depending on the selected Country, a State DropDownList or a Province TextBox is displayed to implement a more realistic data entry. See section 6d above for details.

  7. Enhanced Data Validation

    A selection of data validation is employed throughout the application including Required, Unique, Range and Custom. Custom validation can be quite elaborate as demonstrated for shipping method in section 6e. We have also included a sample validation for credit card number.


  8. Update Action for Stock Level

    To demonstrate the ease of implementing Update Actions, we have incorporated an update action to decrement the Item stock level after completion of the checkout process See section 6j above for details.

10: Conclusion

The Pet Shop benchmark provided an ideal way to demonstrate the efficiencies gained by using the AgileStudio Addin for VisualStudio.NET. Although Pet Shop is essentially a shopping cart application it encompasses a wide range of functionality used across all data management applications.

As demonstrated AgileStudio automates a wide range of routine tasks freeing developers to concentrate on domain specific code. Even with a wide range of additional functionality, there was a 90% reduction in the lines of manual code required to implement the Pet Shop benchmark.

The demo version of the AgileStudio benchmark application is available here.

You can also Download a 30 day trial of the AgileStudio addin for Visual Studio.NET 2003 and examine the AgileStudio Pet Shop sample in detail.


Appendix 1: Stored Procs List

The following stored procs are automatically generated to service the UI. Each Stored Proc is automatically generated to serve only the data required for the controls on the form. This may include data (both simple and calculated) from multiple tables while excluding any data not required by the form. A sample Stored Proc is shown below. The full list of Stored Procs produced automatically for the Pet Shop application is detailed here.


A Stored Proc used for Checkout page 2

This includes shopping cart totalling and shipping cost. These calculations involve access of data across links into "Product Item" and "Shipping Cost". The data is returned as XML allowing a single round trip to the Data Tier to return data from multiple sources - a performant and scalable solution.



Appendix 2: Automatically Generated SQL Server Tables

The SQL Server Tables along with all Keys, Indexes, Relationships and Constraints are automatically generated by AgileStudio. Modifying the Object schemas will cause the database to be updated automatically.



Appendix 3: Manual Coding

The domain specific code required to produce the AgileStudio Pet Shop benchmark application is detailed here.


Appendix 4: Sample of Automatically Generated SQL Update Code

Below is a sample of the SQL Update code automatically generated by AgileStudio to commit data changes on the final checkout page.
This code performs a wide range of validations (for example "Credit Card Number"). It also implements Update Actions to update the User's Address and the stock quantities. Comments were added manually to describe the sections of code generated.
DECLARE @lastid_Order int

-- Set up temporary tables for ids and errors
DECLARE @lastid_Order_CreditCardType int
DECLARE @ids TABLE ( TableName varchar(255), Id int, OriginalId int )
DECLARE @errs TABLE ( Id int, ParentItemName varchar(255), ItemName varchar(255), 
Error varchar(255), CurrentValue varchar(255) )
SET ROWCOUNT 0

-- Flag an error for any item that has been changed by another user or 
task while the form was being edited
INSERT @errs SELECT pk_id as Id,'Order' as ParentItemName,'CreditCardType' as ItemName,'#1' 
as Error,ap_CreditCardType as CurrentValue from ap_Order WHERE pk_id = 194 and ap_CreditCardType!='0' 
and ap_CreditCardType!='1'
UNION ALL
SELECT pk_id as Id,'Order' as ParentItemName,'CreditCardNumber' as ItemName,'#1' as Error,ap_CreditCardNumber 
as CurrentValue from ap_Order WHERE pk_id = 194 and ap_CreditCardNumber IS NOT NULL 
and ap_CreditCardNumber!='12345678901234'
UNION ALL
SELECT pk_id as Id,'Order' as ParentItemName,'CreditCardExpiryYear' as ItemName,'#1' 
as Error,ap_CreditCardExpiryYear as CurrentValue from ap_Order WHERE pk_id = 194 
and ap_CreditCardExpiryYear!=NULL and ap_CreditCardExpiryYear!=2006
UNION ALL
SELECT pk_id as Id,'Order' as ParentItemName,'OrderDate' as ItemName,'#1' as Error,ap_OrderDate 
as CurrentValue from ap_Order WHERE pk_id = 194 and ap_OrderDate IS NOT NULL 
and ap_OrderDate!=CONVERT(datetime,'2005-06-08',120)
UNION ALL
SELECT pk_id as Id,'Order' as ParentItemName,'OrderStatus' as ItemName,'#1' as Error,ap_OrderStatus 
as CurrentValue from ap_Order WHERE pk_id = 194 and ap_OrderStatus!='1' and ap_OrderStatus!='2'
UNION ALL
SELECT pk_id as Id,'Order' as ParentItemName,'User' as ItemName,'#1' as Error,ap_User as CurrentValue 
from ap_Order WHERE pk_id = 194 and ap_User!='0' and ap_User!='1'
UNION ALL
SELECT pk_id as Id,'Order' as ParentItemName,'CreditCardExpiryMonth' as ItemName,'#1' 
as Error,ap_CreditCardExpiryMonth as CurrentValue from ap_Order WHERE pk_id = 194 
and ap_CreditCardExpiryMonth!=NULL and ap_CreditCardExpiryMonth!=12

-- Continue if no errors have occured so far
IF @@ROWCOUNT=0
BEGIN

-- Do the updates for data entered in Checkout3.aspx
UPDATE ap_Order SET ap_CreditCardType = 1 , ap_CreditCardNumber = '12345678901234' , 
ap_CreditCardExpiryYear = 2006 , ap_OrderDate = CONVERT(datetime,'2005-06-08',120) , 
ap_OrderStatus = 2 , ap_User = 1 , ap_CreditCardExpiryMonth = 12 WHERE pk_id=194
SET @lastid_Order = 194
INSERT @ids values('ap_Order',194,194)

-- Do the updates corresponding to any actions that may have been defined 
for this object
UPDATE ap_User SET ap_FirstName= ap_Order.ap_BillFirstName,ap_LastName= ap_Order.ap_BillLastName,
ap_Address1= ap_Order.ap_BillAddress1,ap_Address2= ap_Order.ap_BillAddress2,ap_City= ap_Order.ap_BillCity,
ap_State= ap_Order.ap_BillState,ap_PostalCode= ap_Order.ap_BillPostalCode,ap_Province= ap_Order.ap_BillProvince,
ap_Country= ap_Order.ap_BillCountry FROM ap_Order WHERE ap_Order.pk_id=@lastid_Order 
AND ap_Order.ap_User=ap_User.pk_id

UPDATE ap_Product_Items SET ap_QuantityInStock= (select ap_Product_Items.ap_QuantityInStock 
from ap_Product_Items where ap_Product_Items.pk_id=ap_Order_Items.ap_ProductItems)- ap_Order_Items.ap_Quantity 
FROM ap_Order_Items WHERE ap_Order_Items.fk_Order=@lastid_Order 
AND ap_Order_Items.ap_ProductItems=ap_Product_Items.pk_id

-- Finally do any other validation- In this case two custom validations
INSERT @errs SELECT OriginalId as Id,'Order' as ParentItemName,'CreditCardNumber' 
as ItemName,'Credit Card Number should contain 16 digits and no spaces ' as Error,null 
as CurrentValue from ap_Order,@ids where pk_id=Id and TableName='ap_Order' 
and not(LEN( ap_Order.ap_CreditCardNumber )=16 AND PATINDEX('%[^0-9]%', ap_Order.ap_CreditCardNumber)=0) 
INSERT @errs SELECT OriginalId as Id,'Order' as ParentItemName,'CreditCardExpiryYear' 
as ItemName,'The month should be from 1 to 12, the year from 2005 to 2010 so the Expiry date next month 
or later.' as Error,null as CurrentValue from ap_Order,@ids where pk_id=Id and TableName='ap_Order' 
and not( ap_Order.ap_CreditCardExpiryMonth>=1 AND  ap_Order.ap_CreditCardExpiryMonth<=12 
AND  ap_Order.ap_CreditCardExpiryYear>=2005 AND  ap_Order.ap_CreditCardExpiryYear<=2010 
AND  (ap_Order.ap_CreditCardExpiryYear>YEAR(GETDATE()) OR ( ap_Order.ap_CreditCardExpiryYear=YEAR(GETDATE()) 
AND  ap_Order.ap_CreditCardExpiryMonth>MONTH(GETDATE())))) 
END
SELECT * from @errs
SELECT @lastid_Order
				

Appendix 5: Pet Shop Project Files

The application consisting of 22 Web Pages, 5 Web controls and 22 Typed DataSets.