Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > BOOK: Professional ASP.NET Design Patterns
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET Design Patterns
This is the forum to discuss the Wrox book Professional ASP.NET Design Patterns by Scott Millett; ISBN: 978-0-470-29278-5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET Design Patterns section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 27th, 2010, 10:33 PM
Authorized User
 
Join Date: Dec 2010
Posts: 23
Thanks: 3
Thanked 2 Times in 2 Posts
Default Developing Layered Applications

Scott,
I was curious what your thoughts are on development process when working on a layered application such as Agatha's Storefront. Do you get the model + services very fleshed out and tested BEFORE working at all on the front-end UI ? Or is it more of an iterative approach where small amounts of progress are made in each layer as you work on the application? Where you'd touch the model, then maybe services, then UI, then back to the model, etc. etc.

I was thinking of trying to flesh out my domain model, services, and repository with unit tests before doing much, if any, work at the UI layer. Does that sound like a bad approach? My thinking was that this would make sure I have a very decoupled UI?
Reply With Quote
  #2 (permalink)  
Old December 28th, 2010, 06:13 AM
elbandit's Avatar
Wrox Author
Points: 599, Level: 8
Points: 599, Level: 8 Points: 599, Level: 8 Points: 599, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2007
Location: Southsea, Portsmouth, Hampshire, United Kingdom.
Posts: 107
Thanks: 10
Thanked 17 Times in 15 Posts
Default

Hi ksouthworth,

Because I had to squeeze Agathas strore into 4 chapters, coupled with that fact that I had worked on a lot of e-commerce sites before I didn't stick to a strict TDD process. However for real world projects I use a BDD process, or more precisly an outside in development methodolgy.

This is the process I use....

I first capture requirements/features as user stories (written by customers in their language) such as...

In order to receive a discount
As a customer
I should be able to apply a voucher to my basket

I then create some scenarios like..

Given I have an expired voucher
When I apply it to my basket
Then no discount should be applied
And a message should let me know that my voucher has expired

Given I have a valid voucher for 5% off of my order
When I apply it to my basket
The basket total should reduce by 5%

... etc...

Each line in the scenario is called a step.

With my user stories and scenarios, plus some screen mock ups on paper/paint, I work on a feature from the outside in. So I might pick the basket feature and I write a step from a scenario. I use SpecFlow as my BDD framework and WatiN as my web browser runner. I work from the point of view of a user and write the test to handle a voucher being applied to a basket, text box and button click etc. The step from the scenario will fail as there is no code for a basket, voucher etc so then I go 'inside' and flesh out a domain model, services etc - just enough to get the step to pass. I continue this way until my feature is complete, then I pick another. This way I focus on the behaviour of the system and I have working end-to-end software that the user can play with at a demo. After each test I will refactor the model to ensure it makes sense and has a simple design.

I hope that all makes sense, if not.....

I am in the process of writing a book on end to end development with SCRUM, XP and BDD, should be out in May:

Pro Agile .NET Development with SCRUM & XP
http://apress.com/book/view/9781430235330

I am also contributing to a chapter for a Wrox book that will cover User Stories, BDD and outside in development, but there is no link on Wrox at the moment.

Their is also a great book called the RSpec book about BDD in Ruby that is really good and worth a look.

let me know if you have any more questions.

Cheers
Scott
Reply With Quote
  #3 (permalink)  
Old December 28th, 2010, 08:17 PM
Authorized User
 
Join Date: Dec 2010
Posts: 23
Thanks: 3
Thanked 2 Times in 2 Posts
Default

So do you start with empty Infastructure, model, service, and UI projects in visual studio? Then fill them in as you go?

At what point do you add/write unit tests? Or do you consider the specflow and watin tests enough?
Reply With Quote
  #4 (permalink)  
Old December 29th, 2010, 06:39 AM
elbandit's Avatar
Wrox Author
Points: 599, Level: 8
Points: 599, Level: 8 Points: 599, Level: 8 Points: 599, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2007
Location: Southsea, Portsmouth, Hampshire, United Kingdom.
Posts: 107
Thanks: 10
Thanked 17 Times in 15 Posts
Default

I start with an empty Model, Service, UI, and Controller projects, my Infastructure project is usually a core company library project with helpful bits and pieces that I include and add to when needed.

When the skeleton of the solution is set up the first thing I do is add a unit test, well integration test actually. take the example...

Given I have an expired voucher
And I am on the basket detail page
When I apply the voucher to my basket
Then no discount should be applied
And a message should let me know that my voucher has expired

The first step to this scenario is

Given I have an expired voucher

My test using SpecFlow looks like this..

Code:
 
        private IVoucher voucher;
 
        [Given(@"I have an expired voucher")]
        public void IHaveAnExpiredVoucher()
        {
            voucher = new Voucher();
            voucher.ExpiryDate = DateTime.Now.AddDays(-1);
            Assert.True(voucher.HasExpired);
        }
Now at this point I have no Voucher class, so I have a failing test. I create the class etc and the test passes. Ok so on to next step in the scenario...

And I am on the basket detail page

And I write a failing test for this step...


Code:
        
        [Given(@"I am on the basket detail page")]
        public void IAmOnTheBasketDetailPage()
        {
            WebBrowser.Current.GoTo("/BasketDetail");
 
            Assert.AreEqual("Basket Title", BasketPage.Title);
        }
Now this test will fail as I have no controller that is mapped to the route '/Basket', so now I drop into unit testing code from the outside and test the controller, hence outside in. I go on like this starting from scenario steps and discovering other objects as I delve through the layers until all my features are complete. As mentioned previously the further I progress with a project the more I learn and the more I can refactor my model to make it simpler and better reflect the behaviours of the real domain.

I will usually create seperate projects for Acceptance tests (SpecFlow & WatiN) and Core domain tests (NUnit) as the acceptance tests will run a lot slower and I will generally be working in the unit tests for most of the time.

Does that make sense?

Last edited by elbandit; December 29th, 2010 at 06:42 AM.
Reply With Quote
  #5 (permalink)  
Old January 6th, 2011, 03:37 PM
Authorized User
 
Join Date: Dec 2010
Posts: 23
Thanks: 3
Thanked 2 Times in 2 Posts
Default

Thanks for the additional explanation. Using the process you described, how do you make sure that your layers stay separated/decoupled properly as you go? Does unit testing help ensure that?
Reply With Quote
  #6 (permalink)  
Old January 6th, 2011, 05:24 PM
elbandit's Avatar
Wrox Author
Points: 599, Level: 8
Points: 599, Level: 8 Points: 599, Level: 8 Points: 599, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2007
Location: Southsea, Portsmouth, Hampshire, United Kingdom.
Posts: 107
Thanks: 10
Thanked 17 Times in 15 Posts
Default

Hi Ksouthworth,

Before each iteration we have a design meeting, where we work out the high level design of the system and the feature that we will be working on. During this session we decide on the architectural style we will be going for, so the projects and layers come out of that.

During coding we assign classes to the most appropriate layer. If you take a look at the Microsoft Application Architecture Guide it will give more info on the responsiblities of the layers (http://apparchguide.codeplex.com/), this should help you.

If you need more info just let me know.

Cheers
Scott

btw I have updated the Agatha code on http://aspnetdesignpatterns.codeplex.com/ to include more tests and a slight refactor of the domain mode.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Developing other applications SP2010Dude BOOK: Beginning ASP.NET 4 : in C# and VB 3 September 18th, 2010 03:49 AM
Developing mobile applications in ASP.Net Edhouse ASP.NET 2.0 Basics 0 March 23rd, 2010 11:00 AM
Multi Layered Design jumbojs BOOK: Beginning C# 2005 Databases 1 October 19th, 2008 12:29 PM
Layered Applications Muhammad Zeeshan General .NET 5 July 25th, 2007 05:08 AM
tools for developing PDA applications kamumata VB.NET 2002/2003 Basics 0 September 4th, 2005 04:02 AM



All times are GMT -4. The time now is 03:16 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.