Model View Presenter Part II - Unit Testing

by Rod 10/16/2008 11:55:00 AM

MVPUnitTesting.zip (516.67 kb)  

In this part we will discuss on how to plug test scripts and create unit test scripts in Model-View-Presenter (MVP).

Unit Testing is a test method that isolates a portion of an application and tests all conditions of that unit. Unit tests are most effective when written as code and automated via unit test framework. Testing can lead to high quality product and it also boosts developer's confidence on his work.

Three Tier vs. Four Tier Unit Testing

In three tier application you don't have direct access to the presentation logic because it is encapsulated inside the User Interface and often get tangled with user interface elements like dialog box, forms, and controls. For this reasons, it is hard for the tester to test the behavior of the application. The only way to test the behavior is through directly accessing the user interface which we called Black Box Testing. Black Box Testing is the process of testing the application without knowing the internal workings of the system. Black box testing is common process done by most of the testers. If you are testing the application directly from the web form or windows form you are doing black box testing.

Black Box testing is time consuming, hard to automate, impossible to integrate in a Continuous Integration (CI) system, not cost effective, and not efficient. Like for example in testing a registration form, in manual process a tester will consume more or less 10 min of his/her time to test the add, edit, delete, and list pages including its validation, process flow, business rules, however if you automate the process using CI tool it would only take more or less 2 seconds to finish the entire test cases and it can be done anytime you want. But this does not mean we need to skip Black Box testing, my point here is that if a test case can be translated to test script translate it. Black Box testing is important especially in web application where a tester need to check the compatibility across different browsers, how user-friendly the application is, how the application display the error messages, and etc. 

Three tier application is an application that splitted into 3 logical layers - UI or Presentation, Business Logic, and Data Access Layer. In three tier architecture you can plug your unit test script through BLL and/or DAL. As developer we cannot deny the fact that most of our workflow and business logic are hidden in the UI layer and often get tangled with UI elements especially if we are used to two tier applications. Question you may ask, what about the work flow, how we could test it in such a way when I press submit button, checkout button, or payment button it should behave the way we are expecting it behave. This is where the fourth layer comes into play.

Figure 1.0. Three Tier Unit Testing

The fourth tier is created by splitting the User Interface tier into two layers - Presentation (or View) and the Presentation logic. Having the presentation logic separated from the view allow developers/testers to plug a test module from the presentation logic layer and gives them power to simulate user inputs by providing a dummy views and capability to test the behavior of the application which is not possible in three tier application. This increase code coverage and make it flexible for the tester to plug different test cases to test different scenarios. This testing is called White Box Testing. White Box Testing is the process of testing that have visibility into application's code. In this process, in order to create a test case you must have an idea of the details of the application code and business flow. This is where testers converts test cases, scenario, and user actions into test scripts.

There are cases that you need to plug a unit test in Data Access Layer or Business Logic Layer to target specific method or routine to increase the code coverage.

Figure 2.0 Model View Presenter Unit Testing

Protoyping

Prototyping is a process of building a scale down version of the intended system to obtain rapid feedback of design and business workflow, isolate testing, minimizes cost, and to have a clear view of the entire application architecture. Its like your are building a lego house where it each lego brick corresponds to one component of the system. One of the challenging part of prototyping is when you start integrating each pieces of the lego brick to form a house. In software development there are two classification of Prototype - Vertical Prototype (Proof of Concept) and Horizontal Prototype(Mocking).

  • Horizontal Prototype, is also called Mocking. This prototype does not go deeply to the layers of the application like business logic, data access layers, and database. There is no concrete objects yet, we are just playing with abstract objects to represent the flow and structure of the component. This is best for testing the workflow and business process of the component. When I integrate this in my unit test I usually called it as Mock or Vertical testing. There are open source libraries that you can use in Mocking like RhinoMock and NMock. See FormTester.cs in Test project for mocking sample.
  • Vertical Prototype, is also called Proof Of Concept. This prototype is the opposite of horizontal prototype, where it checks the applicaton by going it deeply to the actual components, layers, and database system being used. Concrete components are already integrated to allow the component to execute actual objects and services to have tangeable results. In Proof Of Concept, we will see if the actual requirements and technology works as expected. This is where IEmployeeView becomes windows form or web form, where IEmployeeService become EmployeeService or  EmployeeWebService, IEmployee become EmployeeModel. See FormVerticalTestDBService.cs and FormVerticalTestWebService for sample. This test cases uses actual object and services to test if the requirements are met.

You can also take advantage of the Depenency Injection of Unity Application Block to map interfaces into concrete objects that makes the application more flexible. Like in our sample test project we created two test fixtures to test WebService and Database data sources. Using Unity, you can just create one test class and use the Unity container automatically generate the concrete class of the respective interface.

Lets get it on!

Download the code and launch your Visual Studio .NET and open the MVPUnitTesting.sln.

Note: The sample is built using Visual Studio 2005 and compatible with Visual Studio 2008. Also if its your first time to run the test script be sure that the webservice project already initialized else some of the web service test cases will fail. You can initialize the WebService project by running it (right click the project -> Debug -> Start new instance).

The sample is almost the same as the sample in MVP Part I with minor tweaks and integrated some of the features requested by users in Part I. If you noticed I added BLL and DAL projects,  new test case (like FormVerticalTest.cs under Test project), and minor tweaks on the mock tester (FormTester.cs) due to slight changes on the signature of other method. Also please note that EmployeeService is integrated to domain via Data Access Layer, EmployeeWebService is integrated to domain via web service, and EmployeeServiceViaBLL is integrated using business logic layer. This is to illustrate how to design service that is independent to the application and how to use service to provide different data sources (web service, db, flat file, xml, etc) without changing your application's code.

The solution is composed of the following projects:

  • DAL. Data Access Layer project responsible for providing data to the application. This also represents as our database data source.
  • BLL. Business Logic Layer. Houses business flow, workflow, validation, security checks, etc to ensure that data integrity.
  • Common. Contains common libraries, objects, and entities.
  • MVP. Houses the MVP objects like interfaces, services, and concrete classes.
  • Test. Houses the test cases.
  • WebService. Represents our web service data source.
  • WinUI. Windows Form user interface sample.
  • WebUI. Web user interface sample.

One question you may ask when you are doing Unit Testing in MVP is that, if its possible to create unit test without concrete UI (web form, windows form, etc). The answer is yes, all we have to do is to create a virtual view. This virtual view will represent our user interface. At this point you can feel the power of MVP pattern becase its not tied up to any UI so you can reuse the same presenter in different views as long as the view abides our IEmployeeView contract. I already tied MVP on Mobile, VSTO, Web, Win Forms, and Windows Service application so far no issue encountered. 

My Experience: When I apply MVP in my Windows Service application it helps me alot and makes me more efficient because I don't need to bother attaching process inorder to debug windows service application but instead I just plug a test script to its presenter and do the debugging from the Unit Test script.. pretty slick.. TDD way.. when I plug it to the service itself it works like a charm... besides that I can automate my testing...

How to create Virtual View

  1. On the Test project, create a new class and name it DummyEmployeeView.
  2. Inherit the IEmployeeView and implements all the interfaces of IEmployeeView interface.
  3. Create a constructor that will allow us to initialize the view's data.

Please refer to DummyEmployeeView.cs under Test project for the complete code.

Now we have a virtual view ready, we need to create class that will house our test cases. We will be creating a vertical test cases for employee form using database data source.

Creating Test Class

  1. On your Test project create a new class and name it FormVerticalTestDBService.cs
  2. Add reference to NUnit.Framework.dll
  3. Add TestFixture attribute in the class declaration. This marks the class as unit test fixture.
  4. Create an instance of the presenter by passing the model, view, and service objects.
  5. Create a Save() method and mark it as a test case by adding Test attribute.

          [Test]

          public void Save() {...}

    6. Write a code to call presenter's save method.

Please refer to FormVerticalTestDBService.cs under Test project for the complete code. You can expand the test cases to test different scenarios like the InvalidInputNoLastName test case, in this case we are testing saving employee data where lastname is not provided. If you noticed, In FormVerticalTestDBService.cs we are using database data source, you can check the FormVertialTestWebService.cs for the sample that uses web service data source. You will also noticed that to switch from DB source to Web service source we just modify one line of code (see below) and viola it works without affecting underlying implementation of the presenter's Save method.

      _presenter = new EmployeePresenter(_view, _model, new EmployeeWebService());

You can check my MVP Part I article on how to run the unit test using NUnit and ReSharper's Test Runner. Also check the code that comes with this article. I put some inline comments that will help you understand MVP, Services, responsibilities of each layer, and some tips.

To add flexibility to the MVP you an use Unity Application Block for its Dependency Injection (DI). It facilitates building loosely coupled application.

MVP is also advantage to .NET developers who develop application accross different platform because MVP pattern is not tied up to any UI platform.

For all developers out there Unit Testing is your responsibility and not for the testers.

Rock On!

Rod

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , ,

Architectures | MVP | TDD

Related posts

Comments

10/17/2008 1:14:57 AM

Rod

Hi Guys,

Sorry for the very late part II.

Enjoy and May the force be with you!
Rod

Rod

10/21/2008 5:56:30 AM

Chris

Finally! I've been waiting for this. Thanks!

Chris ph

10/22/2008 9:04:57 PM

Rapid Prototyping

nice method of prototyping... in cycle method.

Rapid Prototyping us

10/30/2008 3:36:56 PM

Oleg Zhukov

Nice reading! You might be interested in Model View Presenter framework implementations for .NET. If so take a look at the <a href="http://www.mvcsharp.org" title="Model View Presenter for .NET">MVC# Framework</a>.

Oleg Zhukov ru

10/30/2008 3:43:39 PM

Oleg Zhukov

Sorry, the correct website link in the previous post is http://www.mvcsharp.org.

Oleg Zhukov ru

10/31/2008 12:03:21 AM

Rod

Hi Oleg,

Good work on that. Your framework has similarity on UI Process Application block of microsoft.. I read through your article, we have similar goal why we choos MVP over other patterns. MVP is one Pattern for all platform... I tried using it on windows service and mobile application and i can feel no difference...

My team is currently working on a full blown MVP framework that will be used internally and we are integrating it to our custom source code generator...

At first look, I thought you are talking MVC pattern until i read through the introductions.. the name is confusing..

Great Work!

Rod

2/10/2009 11:14:11 PM

Thomas

Thanks heaps for these articles, between part 1 and 2 it has really clarified what MVP is all about as well as how it can be implemented. Cheers!

Thomas nz

2/27/2009 8:07:26 AM

Mubarag Ali

Awesome Rod , This article gives me clear picture of MVP pattern. Great Explanation.
Thanks a lot.

Mubarag Ali in

3/4/2009 9:57:43 PM

Alex

Hi Rod,

Before I learn the MVP, I usually loaded a list to customer into a dataTable then bind the datagridview to the datatable.

Currently, I change the design of my application to MVP and load a list of customer to an array list of customer model. then bind the list array to the datagridview.

The funny thing is that if the datagridview bind to a datatable the datagridview can be sorted by any column but if bind to the array list the datagridview cannot be sorted.

Do you think I should load the array list to a dataset on the UI layer and then bind datagridview to the datagridview again?


Alex us

3/7/2009 10:12:05 PM

Rod

Hi Alex,

I usually do the paging on the SQL side. This improves the performance, and minimize payload of your network. Here is a sample script for Northwind's Customers table that allow you to sort it by customer name. You can also use the WITH of SQL 2005 insted of temp table.

CREATE PROC [dbo].[CustomersSelectPagedByCompanyName]
@StartRecord INT,
@StopRecord INT,
@Ascending BIT,
@Count INT OUTPUT
AS

DECLARE @TempTable TABLE
(
[ROWNUM] INT IDENTITY(1,1) PRIMARY KEY NOT NULL,
[CustomerID] NCHAR(5)
)

SET ROWCOUNT @StopRecord

IF (@Ascending = 1)
BEGIN
INSERT @TempTable
(
[CustomerID]
)
SELECT [CustomerID]
FROM [Customers]
ORDER BY [CompanyName] ASC
END
ELSE
BEGIN
INSERT @TempTable
(
[CustomerID]
)
SELECT [CustomerID]
FROM [Customers]
ORDER BY [CompanyName] DESC
END

SELECT [Customers].[CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address],
[City], [Region], [PostalCode], [Country], [Phone],
[Fax]
FROM @TempTable TEMPTBL
INNER JOIN [Customers] ON [Customers].[CustomerID] = TEMPTBL.[CustomerID]
WHERE @StartRecord <= ROWNUM

SELECT @Count = Count(CustomerID) FROM [Customers]


GO

Rod ph

3/13/2009 1:41:06 AM

Alex

Thanks for your respond Rod. I start seeing the beauty of using the MVP.

Another question: If in my application has social security number entry field. The format will be xx-xx-xxxx. I want to check if there is a value before store the data into the model by using this if replace(ssn,"-","")<>"" then store the data. Do you think I should put this in UI or model?

thanks again
Alex

Alex us

3/14/2009 12:34:16 AM

Alex

Hi Rod,

question again, I think the app.conf file should be place in the MVP project. But after I move the app.conf from the UI project to the MVP project there is error: System.Configuration.cofigurationErrorsException: The requested database connection string is not defined in the configuration. at Microsoft.practices.enterpriseLibrary.commont.............
I just don't understand why is not working because MVP is the one access to the databse.

Alex

Alex us

3/18/2009 7:31:45 AM

Global Cash Mavericks

good presentation. very specific and easy to understand.

Global Cash Mavericks us

3/18/2009 6:30:05 PM

Rod

Hi Alex,

On validation, you can place the validation in Model and/or Presentter. I usually create a custom IValidatable interface that contains bool Validate() and ErrorMessageCollection. The ErrorMessageCollection contains the collection of error found whenn Validate() is called. The IValidatable inteface is inherrited by Model. If you are validating a format, required fields, range, and some integrity check like SSS # you can place this in Model. But if you valiation is more on worklfow place the valiation in presneter.

I suggest that you explore the Microsoft Application Validation block or Castle Project Valiation . These are really cool libraries when i comes to validation.

Ic no problem placing it in you application. App.config are renamed as <assembly name>.config (ex. MyDLL.dll.config or myExe.exe.config) In your case the application could not find your configuraiton file because you moved it to the MVP layer.

Why you decided to move it in MVP layer?

Rod ph

3/20/2009 1:00:51 PM

giving4prosperity

Thanks for this great post. Continue your good work.Smile

giving4prosperity us

3/24/2009 12:03:38 AM

Alex

Hi Rod,

Thanks for your respond again.

The reason I want to move the config file to MVP is because I put the data access layer in the MVP folder. And I think it might make sense both the config and data access layer should be together.


Alex

Alex us

3/24/2009 9:10:13 AM

bolinao

Hi, i enjoy reading your website or blog. I got many ideas for my blog. Thanks for the info.

bolinao us

3/26/2009 10:06:35 AM

high pinay

its a matter of self relation for this site and they can help to produce the more ability and feature.

high pinay us

4/1/2009 11:24:22 PM

tnomeralc web design toys

Thank for the sharing..

tnomeralc web design toys us

4/3/2009 2:06:51 PM

free background check

Very informative post, I learn something here.. Thank you very much for posting here..

free background check us

4/9/2009 7:00:40 PM

Alex

Hi Rod,

Recently I have a new project with one to many relationships.
Mother has many children. They are stored in different tables (mother saved to motherTable, children saved to childrenTable)

Can you give me an idea how should I design the project in MVP?

Thanks
Alex

Alex us

4/11/2009 5:27:53 AM

Rod

Hi Alex,

This will depends on your design. Actually most of the work will be done in your Business Logic Layer. You can create a class that will act as your facade to monther-child objects in your BLL. MVP layer on the otherhand will just manage the flow, validation, and separation of UI logic with the UI itself.

For instance in your BLL, you create a Tree object that has the following interfaces:

SaveMother(motherid, name, attribute);
- will use Mother DAL that manages CRUD actions in motherTable
SaveChild(montherId, childid, name, attribute);
- will use Children DAL that manages CRUD actions in childrenTable
DeleteMother(motherId);
- will use Mother DAL that manages CRUD actions in motherTable
DeleteChild(childId);
- will use Children DAL that manages CRUD actions in childrenTable
GetChildren(montherId);
- will use Children DAL that manages CRUD actions in childrenTable
GetAllMothers();
- will use Mother DAL that manages CRUD actions in motherTable

This will allow the clients or consumer of your BLL NOT concern how monther/child data are inserted,updated, and deleted in the database.

In your MVP layer all you need to do is to initialize the Tree object and call respective interfaces.


TIP: if your Monther and child tables are almost the same fields you can just use 1 table to handle monther child relationship. This can be done by adding parentid that reference to itself.

Ex Table:

nodeId
parentId
Name
Attribute

ParentID references to nodeID that determines its parent/mother node.

Hope this helps

Regards,
Rod

Rod ph

4/11/2009 5:34:56 AM

Rod

Hi Alex,

On your configuration (config) file question, placing config in the application (ex. web.config) its accessible through out the application from UI-DAL layer. But if you put it in your MVP layer it is only accessible by MVP assembly.

Rod

Rod us

4/15/2009 9:23:51 PM

Ben

Hi Rod,

Your posts have been extremely helpful- thank you. I'm in the process of figuring out how to migrate my dev team's approach from the very tired 'all business logic in the forms' approach to using MVP and my first question is about project segregation.

What are the tradeoffs involved with combining the DAL, BLL, MPV, and Common layers into one well organized core project? For our purposes, it seems like they'd never exist in a solution without all of them present.

I ask because my manager would like to minimize the complexity of the new paradigm we switch to wherever possible and this might be one way to do that. Our developers are used to maintaing two projects in their solutions (app & common), and while a fully blown-out design is probably the more correct way to go, the acceptance-curve may be less steep with a middle-of-road approach... especially if we wouldn't necessarily need that level of modularity.

I'm curious for your thoughts on where comprimise is okay, or if it just isn't really worth it in the long run.

Thanks~
Ben

Ben us

4/15/2009 11:08:24 PM

Rod

Hi Ben,

Thanks!

For the project segregation here are few tips:
1. Move UI Logic to Presenter. UI logic oftenly rooted in the event say button_Click. Encapsulate it in one method in the presenter. then use View to communicate with the UI.

For instance if have a button that save the data to DB.

OLD Code:
void button_Click(object sender, EventArgs e)
{
....
Tons of code goes here..
...
}

NEW Code, encapsulate all the conent in one method:

void button_Click(object sender, EventArgs e)
{
_presenter.OnSave();
}

2. Create an entity object that will be used as a model. This will serve as a lump data that maintains the state of your data. This will serve also as your transport object accross the layers. In our sample this is the employee object.

3. Validation. You can add validation in your model and/or presenter. Business logic layer and service layer can also contain some validation routines to ensure data integrity. You can use Validation Application block for declarative validation on your entity.

On your second question, If i understand it right, you are placing all the layesr into one project/assembly? if yes, placing all layers (BLL, MVP, DAL, Common) will improve performance but you will sacrifice testability, maintainability, orthogonality, and reusability. As your application grow, it will be hard for you to distribute task accross engineers. MVP allows you parallel development, separation of concerns, and can assign each layer to specialized engineer. Say you can assign UI to your Use Experience Engineer, DAL to your engineer speialized on data management and database, MVP/BLL to engineers knows more about the flow or the process of the system.

Depending on your application needs, you might not need BLL or service layer or both in your application. Like for instance, if your application will only have one consumer which is a Windows Form you, in this case you might not need the service layer. You need service layer if you have two or more differnt data sources or data providers (web service, local database, etc). For more tips you can read Microsoft's Application Architecture guide 2.0. this is free.

If you don't mind me asking, what type of appliation you are working? if you are working with on small application you can place the MVP, BLL, and DAL in one assembly/project and just group it using folders that way when grows you can easily move the folder into separate project/assembly.

Regards,
Rod

Rod ph

4/16/2009 1:15:57 AM

Alex

Hi Rod,

I am planning to include a datagrid in Mother UI for child.
But there is something wrong in the design, especially in the Presenter and the UI area.
Here is my structure of the application:

Comment:
•Imother
•motherModel
•Ichild
•childModel


DAL
Public Sub InsertMother(ByVal mother As Imother)
End Sub

Public Sub InsertChild(ByVal child As Ichild)
End Sub

MVP
•IServices
•IView
ReadOnly Property motherID() As String
ReadOnly Property motherName() As String
ReadOnly Property childName() As List(Of ChildModel)
•Presenter
Private _view As IView
Private _service As IServices
Private _MotherModel As MotherModel
Private _ChildModel As List(Of ChildModel)

Public Function Save() As Boolean
_MotherModel.id = _view.id
_MotherModel.name = _view.name

_ChildModel = _view. childName

_service.SaveSTD(_MotherModel)
_service.SaveHist(_ChildModel)
End Function
•Services

Form (Mother UI)
Public ReadOnly Property childName () As
System.Collections.Generic.List(Of Common.ChildModel) Implements
MVP.IView.childName
Get
Dim CList As List(Of childModel)
Dim i As Integer
For i = 0 To gdPreHist.Rows.Count - 2
HList.Add(datagrid.Rows(i).Cells("name").ToString)
Next
Return CList
End Get
End Property


Alex

Alex us

4/16/2009 12:05:33 PM

cash4trends

Thanks for sharing the important information.Smile

cash4trends us

4/16/2009 9:20:26 PM

Ben

Hi Rod- thanks so much for your quick reply. This has been a great resource for me as I wrap my head around these higher development concepts.

I work for a financial company and write software for internal use. Each of our WinForm applications is fairly specific in scope and our developers typically do all layers of development. As a smaller team, we usually work individually and are responsible for designing the UI (with direction from our non-dev UI team), writing all business logic and and data access code, and writing all backend sql procedures. As such, we don't necessarily need the ability to divide labor- however, we would like to graduate to a more sophisticated method of development to improve scalability and maintainability.

Things that may become possibilities for us in isolated areas: needing a web interface for a portion of a WinForm application; making an application viable as an external offering.

It seems like we might fall into that description you mentioned in your last paragraph in the short-term. One project with all UI elements (views) and another well organized project for MVP, etc. that would be break-out-able if the need should arise.

I appreciate you pointing me to Microsoft's Application Architecture Guide- I definitely give that read. I imagine that will help crystallize these ideas for me.

Another more specific question: Do you always pass an empty Model instance to the Presenter even if you are opening an existing record from the database? Would it be the Presenter's job to use the Service to get data and fill the Model? For instance:

In View:
private void Form_Load(...)
{
(Instantiate presenter)

presenter.Initialize(34);
}

In Presenter:
public void Initialize(int id)
{
model.Fill(service.GetEmployee(id));
}

In Model:
public void Fill(DataSet ds)
{
...
}

OR maybe View looks like:
private void Form_Load(...)
{
(Instantiate presenter)

presenter.Initialize();

presenter.Load(34); -- cleanly separate the load code from the init code
}


Thanks for your help and time-
Ben

Ben us

4/16/2009 9:35:27 PM

Ben

Hi Rod- Thanks so much for your quick reply. We're a financial company that and we write Winform apps for internal use. As a small team, our developers handle all aspects of development from designing the UI (with guidance from our non-dev ui duo), writing all business logic and data access code, and writing all backend sql procedures. As such, we don't necessarily need the ability to split labor as fully as a completely separated architecture would allow. All applications use a common database as well.

It sounds like we might fall into the category mentioned in your last paragraph. Our solutions could contain one WinForm project for all Views and then a second Class Library project with all other MVP etc. components, well-organized to allow for easy break-out down the line. With this we could slap a web interface on if necessary (that may be a need in the future).

One question about loading an existing entity. Would it be the Presenter's job to use the Service to fill the Model? Something like:

EmployeeView:
private void Form_Load(...)
{
(instantiate presenter)

presenter.Initialize();
presenter.Load(34);
}

EmployeePresenter:
public void Load(int id)
{
model.Fill(service.GetEmployee(id));
}

EmployeeModel:
public void Fill(DataSet ds)
{
...
}

Thanks for your help and time,
Ben

Ben us

4/16/2009 9:42:59 PM

Ben

My apologies for the double-take it looked like the first comment didn't go through Smile

Ben us

4/21/2009 2:16:38 PM

free conference call

Just found your blog through Google, and I have to say I thoroughly enjoy it.
Thank you for the info. I’m looking forward to the additional valuable information here.

free conference call us

4/27/2009 7:34:26 AM

Rod

Hi Ben,

I'll get back to you anytime this week, i was busy with my son's baptism and projects I'm handling.

Rock On!
Rod

Rod us

5/22/2009 3:30:21 PM

Rod



@Ben: One question about loading an existing entity. Would it be the Presenter's job to use the Service to fill the Model?

Rod: yep, presenter is the only one can access the service or the business logic layer (if you don't have service layer). Based on my experience, I only use service layer if there are two or more data sources like database and web service but if you only have one datasource like your case (the database), you can directly access your BLL from the presenter.

Service Layer is use to abstract the datasources and business flow. It can also be a factory of your supported services. Say for example if you have two datasource an XML and database, in your service you'll probably create XmlUserService and DatabaseUserService that inherits your IUserService. This allows you to coinfigure your application to use XML or database as data source.

On the model, I usually use the presenter to initialize the model and use the view to populate the UI.

@Alex:

I think you don't need IMonther and IChild interface you can normalize it to INode or something.

interface INode
{
INode Parent {get;set;}
string Name {get;set;}
int ID {get;set;}
IList<INode> Children {get;set;}
}

Where:
If Parent is null, it is the root node.
If Parent is not null, it is a child of that parent.
Childrend contains the list of child nodes.

Then you can create Node model to replace your Mother and Child model.

Sorry for the very late reply.

Happy Coding!

Rock On!
Rod

Rod us

5/30/2009 12:55:50 PM

EDI

This was really worth reading. A bit confusing at times. But I really liked the code here. It's very nice.

EDI us

6/8/2009 7:21:02 PM

joe

I am learning .net applications but this is new to me. information overload though I have heard about blackbox testing.

joe au

6/25/2009 11:28:05 AM

vicman

The proto type is nice and clean, that is good and i also get an idea to make mine smoother ^^... thanks for the share it really gives me a help, Keep on posting more of your proto type sample.
http://www.24hpayday.com

vicman us

7/20/2009 12:42:44 PM

Web design

Useful article.
Thanks for helpful information you catch up us with your instructional explanation.

Web design gb

7/22/2009 10:19:44 PM

Jm-Experts

Good post and nice blog design,is it a custom design?

Jm-Experts us

7/30/2009 9:26:25 PM

local online dating

You share valuable information and excellent design you got here! I would like to thank you for sharing your thoughts and time into the stuff you post!! Thumbs up.

local online dating us

8/13/2009 5:49:02 PM

Post ads car for sale for free

Awesome Rod , This article gives me clear picture of MVP pattern. Great Explanation.
Thanks a lot. Regards

Post ads car for sale for free us

8/14/2009 2:31:53 PM

seo company

How to create Testing Environment for Patch Management using Wsus?

seo company us

8/14/2009 2:55:05 PM

online poker

Hi,

I am a B.Com graduate and wish to persue a career in Software Testing. Are there any chances of getting a job?

online poker us

8/19/2009 2:58:43 PM

casino en el Internet para jugar

Service Layer is use to abstract the data sources and business flow. It can also be a factory of your supported services. Say for example if you have two data source an XML and database, in your service you'll probably create Xml User Service and Database User Service that inherits your I User Service. This allows you to configure your application to use XML or database as data source.

casino en el Internet para jugar in

8/21/2009 12:20:34 PM

Antivirus software

Hi,
In current anti-virus software a new document or program is scanned with only one virus detector at a time. CloudAV would be able to send programs or documents to a network cloud where it will use multiple anti-virus and behavioural detection simultaneously. It is more thorough and also has the ability to check the new document or programs access history

Antivirus software us

8/24/2009 12:29:09 PM

soni sharma

Thanks so much for your quick reply.MVP is one Pattern for all platform..

<a href="http:/www.ibowsolutions.com/algeria">WEB HOSTING</a>

soni sharma in

9/2/2009 10:33:07 AM

SEO Company UK

Thank you for sharing with us this good piece of information. I am a bit confused with the codes but I think after some deep study through it would do me good.

SEO Company UK gb

9/10/2009 3:41:04 AM

Make Money Online

This was really worth reading.

Make Money Online us

9/12/2009 2:02:57 AM

Earlobe repair Philadelphia

This is kind of helpful. I didn't know the implications of black box testing until today. Thank you very much!

Earlobe repair Philadelphia us

9/28/2009 2:28:04 PM

gator host review

Awesome Rod ,I am really obliged by the post that you have shared with us. I found it very useful and informative. thank you very much.

Cheers

gator host review us

9/29/2009 7:27:13 AM

Make Money Online

Great overview. Your style of writing is really a joy to read.

Make Money Online us

10/7/2009 10:17:43 AM

wine gifts

Fantastic walk-through. I appreciate this post.There is obviously a lot to know about this. I think you made some good points in Feature also

wine gifts sa

10/7/2009 10:21:33 AM

green tea for weight loss

Useful information shared..Iam very happy to read this article..thanks for giving us nice info.Fantastic walk-through. I appreciate this post.

green tea for weight loss sa

10/7/2009 10:27:24 AM

anti-aging products

Hey ur post left me quenching for more Your post really gives out useful knowledge.. thanks for good info..

anti-aging products us

10/7/2009 10:59:31 AM

Custom Thesis

This is an interesting blog. And you'll probably create Xml User Service and Database User Service that inherits your I User Service. This allows you to configure your application to use XML or database as data source.

Custom Thesis us

10/7/2009 11:00:41 AM

Dissertation

This is really a good provision of the data source. This allows you to configure your application to use XML or database as data source.

Dissertation us

10/8/2009 2:32:12 PM

Tamaflu

You seem to be very interested in MVP. Anyway you have done a good job. I shall be looking forward to more of your articles.

Regards, Denise Sasser

My Health Blog: http://stomachflusymptoms.net/

Tamaflu us

10/9/2009 1:26:05 PM

Custom Essays

Excellent post.I want to thank you for this informative read, I really appreciate sharing this great post. Keep up your work…

Custom Essays us

10/9/2009 1:26:56 PM

Essay Writing

Thanks for post. I am thinking of using PS Print for a business card job, but it requires 3 Spot colors.

Essay Writing us

10/9/2009 1:27:49 PM

GCSE Coursework Help

I am very glad to see such information which I was searching for a long time.This made very glad..This site has given us an useful information..

GCSE Coursework Help us

10/9/2009 1:28:48 PM

Dissetation Help

This is really a good provision of the data source. This allows you to configure your application to use XML or database as data source.

Dissetation Help us

10/9/2009 5:04:07 PM

play free games

Black Box Testing is the process of testing the application without knowing the internal workings of the system. Black box testing is common process done by most of the testers. If you are testing the application directly from the web form or windows form you are doing black box testing...

play free games us

10/11/2009 2:29:58 PM

Essays

You made some good points there. I did a search on the topic and found most people will agree with your blog.

Essays us

10/11/2009 2:31:00 PM

Custom Essays

Awesome site. Very informative and nice design. I really like your posts and your style.

Custom Essays us

10/11/2009 2:31:55 PM

Custom Essay

Thank you for the work you have put into your nice blog. We will bookmark to your blog because it is very informational. We love the site and will come back to see your new posts.

Custom Essay us

10/11/2009 2:33:32 PM

Essay Writing

Very creative, one of the nicer sites I have seen today. Keep up the great work.

Essay Writing us

10/11/2009 6:42:32 PM

Evening Primrose Oil

More coding to be done here..., cool I love to code, thanks for the info.

Evening Primrose Oil us

10/12/2009 11:28:04 AM

riverbelle casino

In software development there are two classification of Prototype - Vertical Prototype (Proof of Concept) and Horizontal Prototype(Mocking).

riverbelle casino us

10/12/2009 2:28:59 PM

web design

Thanks for your straignt forward approach.

web design gb

10/13/2009 9:43:35 AM

Best antivirus

Unit Testing is a test method that isolates a portion of an application and tests all conditions of that unit.

Best antivirus us

10/14/2009 1:25:01 AM

Fast cash loans online

Nice resource. rss feed added

Fast cash loans online us

10/16/2009 12:57:14 AM

Cialis

Hello, we are conducting research on tadalafil prices on the web and were wondering if You could recommend any good erectile dysfunction resources ?

Cialis us

10/16/2009 8:42:04 AM

slots of vegas casino

Thank you, this site has given us an useful information

slots of vegas casino es

10/16/2009 3:25:18 PM

Buy Research Papers

Useful information shared..Iam very happy to read this article..thanks for giving us nice info.Fantastic walk-through. I appreciate this post.

Buy Research Papers us

10/16/2009 3:26:05 PM

Research Paper

Great article mate! I just had some 2nd thoughts after reading your post Bryan. I might consult first with my wife about this. Thank you for sharing.

Research Paper us

10/16/2009 3:26:43 PM

Custom Term Paper

I always tell to myself the participation is more important than the result!

Custom Term Paper us

10/16/2009 3:27:34 PM

Buy Term Paper

You made some good points there. I did a search on the topic and found most people will agree with your blog.

Buy Term Paper us

10/19/2009 4:35:29 AM

Free Vacation

Thanks for your straignt forward tips.

Free Vacation th

10/20/2009 4:18:37 PM

Apex Professionals LLC

I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business.Thanks for sharing posts.
Regards,

Apex Professionals LLC us

10/20/2009 5:23:16 PM

green tea health benefits

Useful information shared..Iam very happy to read this article..thanks for giving us nice info.Fantastic walk-through. I appreciate this post

green tea health benefits us

10/21/2009 6:15:14 PM

four seasons wine club

Thanks for sharing info. Keep up the good work..we hope you will visit our blog often as we discuss topics of interest to you

four seasons wine club us

10/22/2009 2:16:31 PM

Nokia help

Many thnks for the almost 'step by step' guide. It's really useful to a newbie like me. I shall be bookmarking this for future reference

Nokia help gb

10/22/2009 8:43:43 PM

kerja keras adalah energi kita

Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful and beneficial to your readers.

kerja keras adalah energi kita us

10/23/2009 2:41:30 PM

hoover steam vac

This is exactly what Ive been looking for. Since I've had problems understanding tiers. Thanks for finally sharing this pal. Will definitely bookmark this for future reference.

hoover steam vac us

10/23/2009 2:58:26 PM

the wine club

I have really enjoyed reading your blog posts. Any way I am going to subscribe to your feed and I hope you post again soon.

the wine club us

10/24/2009 9:48:36 PM

Kerja Keras Adalah Energi Kita

great article. thanks for taking the time to sharing this with us.
very useful.

Kerja Keras Adalah Energi Kita us

10/26/2009 3:39:19 PM

Kenali dan Kunjungi Objek Wisata di Pandeglang

interesting article. really enjoy reading this.

Kenali dan Kunjungi Objek Wisata di Pandeglang us

10/26/2009 6:45:47 PM

Term Paper Topics

I enjoyed reading it. I need to read more on this topic...I admiring time and effort you put in your blog, because it is obviously one great place where I can find lot of useful info..

Term Paper Topics us

10/26/2009 6:46:34 PM

Research Paper Help

I check your posts more often! Really interesting articles.I enjoyed reading it. I need to read more on this topic..Thanks for sharing a nice info...

Research Paper Help us

10/26/2009 6:47:10 PM

Dissertation Topics

Easy option to get useful information as well as share good stuff with good ideas and concepts

Dissertation Topics us

10/26/2009 6:47:49 PM

Thesis Topics

Really interesting articles.I enjoyed reading it. I need to read more on this topic..

Thesis Topics us

10/26/2009 10:15:30 PM

Kerja Keras Adalah Energi Kita

yep, i agree with this post. great job!

Kerja Keras Adalah Energi Kita us

10/27/2009 5:43:22 AM

best teeth whiteners

Very interesting site..Useful information shared..Iam very happy to read this article..thanks for giving us nice info..Keep up the work..

best teeth whiteners us

10/28/2009 12:32:18 AM

cash loans

thanks! very helpful post!! like the template btw ;)

cash loans us

10/28/2009 5:31:36 AM

free music downloading sites

I enjoyed reading it. I need to read more on this topic..Thanks for sharing a nice info..

free music downloading sites us

10/29/2009 1:06:56 PM

Dimitar Keclok

Well, I just found your blog unexpectedly from the search engine. First time I saw it, I know it's a very informative blog. I got so many something new from here. Good work and thanks for that!

Dimitar Keclok us

10/30/2009 6:41:41 AM

Custom Essays

Really interesting articles.I enjoyed reading it. I need to read more on this topic..Thanks for sharing a nice info...

Custom Essays us

10/30/2009 6:42:23 AM

Essay Help

Very interesting post to hang on..Iam really impressed with this article..Looking for more info..

Essay Help us

10/30/2009 6:43:06 AM

Custom Essay

It was a very nice idea! Just wanna say thank you for the information you have shared. Just continue writing this kind of post. I will be your loyal reader. Thanks again.

Custom Essay us

10/30/2009 6:43:42 AM

Sample Essay

Thank you very much for the information provided! I was looking for this data for a long time, bit I was not able to find the trusted source

Sample Essay us

11/4/2009 10:34:20 AM

green tea diets

I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commentators here!

green tea diets us

11/11/2009 10:25:34 AM

educational toys

Hi,

What is the difference between community,standard and professional compiere ERP products?

educational toys us

11/14/2009 10:50:55 AM

Restaurant Recipes

Thank you for the sensible critique. Me and my neighbor were just preparing to do some research about this. We got a grab a book from our local library but I think I learned more from this post. I am very glad to see such great information being shared freely out there.

Restaurant Recipes us

11/17/2009 9:23:32 AM

Premium Wordpress Themes

This articles is very nice.

Premium Wordpress Themes us

11/17/2009 1:12:51 PM

fast payday loans

Just wanted to say thanks for this.

fast payday loans us

11/25/2009 7:58:30 PM

learn guitar

I was very happy that I found this site. I wanted to thank you for this great information!! I definitely enjoyed every bit of it and I have you bookmarked your blog to check out the new stuff you post in the future.

learn guitar us

11/26/2009 2:57:08 AM

bokep 3gp

Thank you for sharing with us this good piece of information. I am a bit confused with the codes but I think after some deep study through it would do me good.

bokep 3gp us

11/30/2009 2:59:39 PM

faxless payday loans

I guess there's always an easier way ...

faxless payday loans us

12/3/2009 7:03:59 AM

Cheap auto insurance quotes

Thank you for the work you have put into your nice blog. We will bookmark to your blog because it is very informational. We love the site and will come back to see your new posts.

Cheap auto insurance quotes us

12/4/2009 11:14:49 AM

Tom Smith

Thanks heaps for these articles, between part 1 and 2 it has really clarified what MVP is all about as well as how it can be implemented.

Tom Smith us

12/7/2009 6:19:31 PM

Essay Writing

Your article is amazing, I will forward it to my friends...

Essay Writing us

12/7/2009 9:25:02 PM

Research Papers

Thanks for useful article.

Research Papers us

12/7/2009 9:27:46 PM

Freelance Writing

Thanks for useful blog tips and pictures.

Freelance Writing us

12/8/2009 5:05:26 PM

college papers

Hi,
Nice work, thanks again for sharing such an informative ideas. I appreciate the information, well thought out and written. Thank you.

college papers

12/8/2009 5:08:15 PM

Thesis Writing

Well, I just found your blog unexpectedly from the search engine. First time I saw it, I know it's a very informative blog. I got so many something new from here. Good work and thanks for that!

Thesis Writing us

12/14/2009 9:57:48 PM

buy essay

Interesting post. I normally comment AFTER reading the posts I visit. If I am ona interesting blog, but, do not like the post, or do not find it worthy to comment on, I refrain from doing so. Thanks for sharing.

buy essay us

12/14/2009 10:01:30 PM

research papers

Hi,
That's a great info. Thanks for sharing, really like your view. I can see that you are putting a lot of time and effort into your blog. Keep posting the good work.

research papers us

12/14/2009 10:04:11 PM

custom research papers

I just come here to refresh myself and get lot of information.
Thanks for sharing.

custom research papers us

12/15/2009 8:07:50 AM

colon clenase

I must admit that today is my first time I visit here. However, I have found so many interesting thing in your blog and I really love that. Keep up the good work!

colon clenase us

12/15/2009 10:56:18 PM

stop panic attacks

I am glad that I found your site. I wanted to thank you for this great read!! I definitely enjoying every bit of it and I have you bookmarked to check out the new stuff you post.

stop panic attacks us

12/16/2009 9:56:20 PM

sears parts

Questa?

sears parts us

12/18/2009 4:02:13 AM

Hypnosis

I came here from another blog and liked it so much that I have told my friends to read this, too.

Hypnosis az

12/22/2009 3:40:12 AM

paper writing service

good thing I found this tip, very useful indeed for a not-so technical person like me.

paper writing service us

12/23/2009 5:26:06 AM

sewage pump 

very informative, thanks

sewage pump  cn

12/26/2009 7:42:21 AM

exchange rate widget

good one!

exchange rate widget

12/26/2009 7:53:00 AM

exchange rate widget

good one!

exchange rate widget

12/26/2009 7:55:15 AM

currency converter widget

nice one!

currency converter widget

12/26/2009 7:55:54 AM

forex trading system software

nice one!

forex trading system software

12/26/2009 7:56:29 AM

mortgage calculator widget

I like it!

mortgage calculator widget

12/26/2009 7:57:08 AM

gold price

enjoying it!

gold price

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

3/10/2010 12:37:14 PM

Powered by BlogEngine.NET 1.3.0.0
Theme by Mads Kristensen

About the author

Name of author Rod Cerrada
One way to enrich world's treasure is to share your knowledge to younger generations.

E-mail me Send mail  |  LinkedIn  |  ScrumMaster

Company: www.cerquit.com


Recent posts

Pages

    Calendar

    <<  March 2010  >>
    MoTuWeThFrSaSu
    22232425262728
    1234567
    891011121314
    15161718192021
    22232425262728
    2930311234

    View posts in large calendar

    Authors






    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2010

    Sign in