Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Testing your data access layer in another project part of samesolution

Reply
Thread Tools

Testing your data access layer in another project part of samesolution

 
 
mazdotnet
Guest
Posts: n/a
 
      10-31-2009
Hi,

I've been doing web development for a long time using a single web
application file (Classes in App_Code folder). However, now I'm
starting a new web application and I want to break all the layers
into
different projects where at least Web Application is one project &
a
data access layer is another project.


My steps,
I create an application in IIS 'e.g., MyAppSite'. (I like to use IIS)
I create a new solution in VS2008 and add a class libary project
'DAL'
<- is this correct?
I add the http://localhost/MyAppSite to the solution
I change the output of my DAL to point to http://localhost/MyAppSite/Bin
and everything works fine.


My problem is debugging DAL project (I'm using LINQ to SQL). Is there
way for me to set break points in DAL project and see what the values
are? Without creating a unit test project for my .dbml file since it
has so many methods? I might want to add transactions later using
stored procedure and my own C# class..etc, I want to test the output
of the DAL (data access layer) to make sure it works (where I want to
set breakpoints if needed)


Can you please explain how I can do this? Am I taking the correct
approach by creating a Class Project for my data access layer or I
should be doing this differently?


Greatly appreciate your help


Thank you
M.

 
Reply With Quote
 
 
 
 
Mr. Arnold
Guest
Posts: n/a
 
      10-31-2009
mazdotnet wrote:
> Hi,
>
> I've been doing web development for a long time using a single web
> application file (Classes in App_Code folder). However, now I'm
> starting a new web application and I want to break all the layers
> into
> different projects where at least Web Application is one project &
> a
> data access layer is another project.
>


It should be UI/BLL/DAL. The UI should not be in contact with the DAL.
If you want to come right down to it, the UI should not be in contact
with the BLL either.

>
> My steps,
> I create an application in IIS 'e.g., MyAppSite'. (I like to use IIS)
> I create a new solution in VS2008 and add a class libary project
> 'DAL'
> <- is this correct?


You're missing some layers.


> I add the http://localhost/MyAppSite to the solution
> I change the output of my DAL to point to http://localhost/MyAppSite/Bin
> and everything works fine.
>
>
> My problem is debugging DAL project (I'm using LINQ to SQL). Is there
> way for me to set break points in DAL project and see what the values
> are? Without creating a unit test project for my .dbml file since it
> has so many methods?


You don't test the database model. You test the classes/objects of the
DAL that act upon the database model.

Many call a functional test a unit test. They are two different types of
tests, which can be done with a test-harness.

A unit test is about the simulation of object behavior within the domain
for expected results with pre-written test cases against the domain --
Domain Driven Design and Test Driven Design.

A functional test is about testing functionality, whereas, testing
involves the database, filesystem, going across a network and special
configuration like a config file being used to perform the test.


> I might want to add transactions later using
> stored procedure and my own C# class..etc, I want to test the output
> of the DAL (data access layer) to make sure it works (where I want to
> set breakpoints if needed)


You can put the classes/objects in the DAL into a transactional mode
against the Linq-2-SQL model by using the System.Transaction. You don't
need spocs.

You need to find out how to use the ADO.NET Entity Framework an ORM
solution. You can start with Link-2-SQL but where you should position
yourself is using EF.

> Can you please explain how I can do this? Am I taking the correct
> approach by creating a Class Project for my data access layer or I
> should be doing this differently?




UI
MVP or MVC
BLL
WCF
DAL
database Model

And yes, you can set breakpoints in each one of the layers and single
step all the way from the UI to the DAL.

You should get the book and get the DOFactory software and learn.

http://headfirstlabs.com/books/hfdp/

Dofactory is well worth the price if you're interested in how to
develop n-tiered solutions.

Head First is in the dofactory.

http://www.dofactory.com/Framework/Framework.aspx


I'll give you the rest of my little take on things, which a is needed to
develop solid .NET solutions, particularly Web and SOA solutions.

What is Object-oriented-programming?

(OOP) is a programming paradigm that uses "objects" and their
interactions to design applications and computer programs.

The key concepts of OOP are the following:

Class
Object
Instance
Method
Message passing
Inheritance
Abstraction
Encapsulation
Polymorphism
Decoupling

http://en.wikipedia.org/wiki/Object-...ed_programming

No matter what development platform Java, .Net or others OOP is OOP.

http://math.hws.edu/eck/cs124/downlo...Zulu-Natal.pdf

http://www.blackwasp.co.uk/ObjectOrientedConcepts.aspx


What are design patterns?

Design patterns are recurring solutions to software design problems you
find again and again in real-world application development. Patterns are
about design and interaction of objects, as well as providing a
communication platform concerning elegant, reusable solutions to
commonly encountered programming challenges.

http://www.developer.com/design/article.php/1502691

http://www.dofactory.com/Patterns/Patterns.aspx

<http://computerprogramming.suite101...._antipatterns?

http://msdn.microsoft.com/en-us/library/ms954638.aspx

http://www.designpatternsfor.net/Pre...px?tid=3&cid=4


What is Domain Driven Design?

(DDD) is an approach to the design of software, based on the two
premises [1] that complex domain designs should be based on a model, and
that, for most software projects, the primary focus should be on the
domain and domain logic (as opposed to being the particular technology
used to implement the system).

http://en.wikipedia.org/wiki/Domain-driven_design

What is Test Driven Design?

(TDD) is a software development technique that uses short development
iterations based on pre-written test cases that define desired
improvements or new functions. Each iteration produces code necessary to
pass that iteration's tests. Finally, the programmer or team refactors
the code to accommodate changes. A key TDD concept is that preparing
tests before coding facilitates rapid feedback changes. Note that
test-driven development is a software design method, not merely a method
of testing.

http://en.wikipedia.org/wiki/Test-driven_development

http://weblogs.asp.net/rhurlbut/arch...ess-story.aspx


What is Model-View-Controller?

(MVC) is an architectural pattern used in software engineering.
Successful use of the pattern isolates business logic from user
interface considerations, resulting in an application where it is easier
to modify either the visual appearance of the application or the
underlying business rules without affecting the other. In MVC, the model
represents the information (the data) of the application; the view
corresponds to elements of the user interface such as text, checkbox
items, and so forth; and the controller manages the communication of
data and the business rules used to manipulate the data to and from the
model.

http://en.wikipedia.org/wiki/Model-view-controller

http://msdn.microsoft.com/en-us/library/ms978748.aspx

<http://weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framework.aspx>

http://cristobal.baray.com/indiana/projects/mvc.html

http://www.devx.com/dotnet/Article/29992/0/page/1



What is Model-View-Presenter?

MVP is a software pattern considered a derivative of the
Model-view-controller.

http://en.wikipedia.org/wiki/Model_View_Presenter

http://msdn.microsoft.com/en-us/magazine/cc188690.aspx

http://mrrask.files.wordpress.com/20...-presenter.pdf

http://www.mvcsharp.org/Reworking_AS...e/Default.aspx

<http://www.codeproject.com/KB/aspnet/ModelViewPresenter1.aspx?fid=1531640&df=90&mpp=25& noise=3&sort=Position&view=Quick&select=2822806#Re using%20the%20presenter%20in%20windows>

<http://codebetter.com/blogs/jeremy.miller/archive/2006/02/01/test-driven-development-with-asp-net-and-the-model-view-presenter-pattern.aspx>


MODEL-VIEW-PRESENTER

http://www.polymorphicpodcast.com/

click 'Shows'

click 'Design Patterns Bootcamp: Model View * Patterns*

view parts 1-5

What is Object Relational Mapping?

(ORM) is a programming technique for converting data between
incompatible type systems in relational databases and object-oriented
programming languages. This creates, in effect, a "virtual object
database," which can be used from within the programming language. There
are both free and commercial packages available that perform
object-relational mapping, although some programmers opt to create their
own ORM tools.

http://en.wikipedia.org/wiki/O-RM

http://www.objectmatter.com/vbsf/doc...ormapping.html

What is Language Integrated Query?

LINQ is a Microsoft .NET Framework component that adds native data
querying capabilities to .NET languages.

Microsoft LINQ defines a set of query operators that can be used to
query, project and filter data in arrays, enumerable classes, XML,
relational database, and third party data sources. While it allows any
data source to be queried, it requires that the data be encapsulated as
objects. So, if the data source does not natively store data as objects,
the data must be mapped to the object domain. Queries written using the
query operators are executed either by the LINQ query processing engine
or, via an extension mechanism, handed over to LINQ providers which
either implement a separate query processing engine or translate to a
different format to be executed on a separate data store (such as on a
database server as SQL queries). The results of a query are returned as
a collection of in-memory objects that can be enumerated using a
standard iterator function such as C#'s foreach.

Many of the concepts that LINQ has introduced were originally tested in
Microsoft's C? research project. LINQ was released as a part of .NET
Framework 3.5 on November 19, 2007.

http://en.wikipedia.org/wiki/Language_Integrated_Query

What is Linq-to-SQL?

LINQ to SQL, a component of Visual Studio Code Name "Orcas", provides a
run-time infrastructure for managing relational data as objects without
losing the ability to query. It does this by translating
language-integrated queries into SQL for execution by the database, and
then translating the tabular results back into objects you define. Your
application is then free to manipulate the objects while LINQ to SQL
stays in the background tracking your changes automatically.

http://msdn.microsoft.com/en-us/library/bb425822.aspx

What is ADO.NET Entities framework?

ADO.NET Entity Framework is an object-relational mapping (ORM) framework
for the .NET Framework. This framework is Microsoft's first ORM offering
for the .NET Framework. While Microsoft provided objects to manage the
Object-relational impedance mismatch (such as a DataSet).

ADO.NET Entity Framework is included with .NET Framework 3.5 Service
Pack 1 and Visual Studio 2008 Service Pack 1, released on 11 Aug 2008.
It also includes the capability of executing LINQ against ADO.NET Entity
Framework entities

http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework

http://msdn.microsoft.com/en-us/libr...27(VS.80).aspx

http://www.springerlink.com/content/kg3216v2014r00u0/

<http://blogs.msdn.com/adonet/archive/2008/03/27/ado-net-entity-framework-performance-comparison.aspx>













 
Reply With Quote
 
 
 
 
mazdotnet
Guest
Posts: n/a
 
      10-31-2009
On Oct 31, 4:59*pm, "Mr. Arnold" <(E-Mail Removed)> wrote:
> mazdotnet wrote:
> > Hi,

>
> > I've been doing web development for a long time using a single web
> > application file (Classes in App_Code folder). However, now I'm
> > starting a new web application and I want to break all the layers
> > into
> > different projects where at least *Web Application *is one project &
> > a
> > data access layer is another project.

>
> It should be UI/BLL/DAL. The UI should not be in contact with the DAL.
> If you want to come right down to it, the UI should not be in contact
> with the BLL either.
>
>
>
> > My steps,
> > I create an application in IIS 'e.g., MyAppSite'. (I like to use IIS)
> > I create a new solution in VS2008 and add a class libary project
> > 'DAL'
> > <- is this correct?

>
> You're missing some layers.
>
> > I add thehttp://localhost/MyAppSiteto the solution
> > I change the output of my DAL to point tohttp://localhost/MyAppSite/Bin
> > and everything works fine.

>
> > My problem is debugging DAL project (I'm using LINQ to SQL). Is there
> > way for me to set break points in DAL project and see what the values
> > are? Without creating a unit test project for my .dbml file since it
> > has so many methods?

>
> You don't test the database model. You test the classes/objects of the
> DAL that act upon the database model.
>
> Many call a functional test a unit test. They are two different types of
> tests, which can be done with a test-harness.
>
> A unit test is about the simulation of object behavior within the domain
> for expected results with pre-written test cases against the domain --
> Domain Driven Design and Test Driven Design.
>
> A functional test is about testing functionality, whereas, testing
> involves the database, filesystem, going across a network and special
> configuration like a config file being used to perform the test.
>
> > I might want to add transactions later using
> > stored procedure and my own C# class..etc, I want to test the output
> > of the DAL (data access layer) to make sure it works (where I want to
> > set breakpoints if needed)

>
> You can put the classes/objects in the DAL into a transactional mode
> against the Linq-2-SQL model by using the System.Transaction. You don't
> need spocs.
>
> You need to find out how to use the ADO.NET Entity Framework an ORM
> solution. You can start with Link-2-SQL but where you should position
> yourself is using EF.
>
> > Can you please explain how I can do this? Am I taking the correct
> > approach by creating a Class Project for my data access layer or I
> > should be doing this differently?

>
> UI
> MVP or MVC
> BLL
> WCF
> DAL
> database Model
>
> And yes, you can set breakpoints in each one of the layers and single
> step all the way from the UI to the DAL.
>
> You should get the book and get the DOFactory software and learn.
>
> http://headfirstlabs.com/books/hfdp/
>
> Dofactory *is well worth the price if you're interested in how to
> develop n-tiered solutions.
>
> Head First is in the dofactory.
>
> http://www.dofactory.com/Framework/Framework.aspx
>
> I'll give you the rest of my little take on things, which a is needed to
> develop solid .NET solutions, particularly Web and SOA solutions.
>
> What is Object-oriented-programming?
>
> (OOP) is a programming paradigm that uses "objects" and their
> interactions to design applications and computer programs.
>
> The key concepts of OOP are the following:
>
> Class
> Object
> Instance
> Method
> Message passing
> Inheritance
> Abstraction
> Encapsulation
> Polymorphism
> Decoupling
>
> http://en.wikipedia.org/wiki/Object-...ed_programming
>
> No matter what development platform Java, *.Net or others *OOP is OOP..
>
> http://math.hws.edu/eck/cs124/downlo...Zulu-Natal.pdf
>
> http://www.blackwasp.co.uk/ObjectOrientedConcepts.aspx
>
> What are design patterns?
>
> Design patterns are recurring solutions to software design problems you
> find again and again in real-world application development. Patterns are
> about design and interaction of objects, as well as providing a
> communication platform concerning elegant, reusable solutions to
> commonly encountered programming challenges.
>
> http://www.developer.com/design/article.php/1502691
>
> http://www.dofactory.com/Patterns/Patterns.aspx
>
> <http://computerprogramming.suite101....terns_and_anti...
>
> http://msdn.microsoft.com/en-us/library/ms954638.aspx
>
> http://www.designpatternsfor.net/Pre...px?tid=3&cid=4
>
> What is Domain Driven Design?
>
> (DDD) is an approach to the design of software, based on the two
> premises [1] that complex domain designs should be based on a model, and
> that, for most software projects, the primary focus should be on the
> domain and domain logic (as opposed to being the particular technology
> used to implement the system).
>
> http://en.wikipedia.org/wiki/Domain-driven_design
>
> What is Test Driven Design?
>
> (TDD) is a software development technique that uses short development
> iterations based on pre-written test cases that define desired
> improvements or new functions. Each iteration produces code necessary to
> pass that iteration's tests. Finally, the programmer or team refactors
> the code to accommodate changes. A key TDD concept is that preparing
> tests before coding facilitates rapid feedback changes. Note that
> test-driven development is a software design method, not merely a method
> of testing.
>
> http://en.wikipedia.org/wiki/Test-driven_development
>
> http://weblogs.asp.net/rhurlbut/arch...her-tdd-and-dd...
>
> What is Model-View-Controller?
>
> (MVC) is an architectural pattern used in software engineering.
> Successful use of the pattern isolates business logic from user
> interface considerations, resulting in an application where it is easier
> to modify either the visual appearance of the application or the
> underlying business rules without affecting the other. In MVC, the model
> represents the information (the data) of the application; the view
> corresponds to elements of the user interface such as text, checkbox
> items, and so forth; and the controller manages the communication of
> data and the business rules used to manipulate the data to and from the
> model.
>
> http://en.wikipedia.org/wiki/Model-view-controller
>
> http://msdn.microsoft.com/en-us/library/ms978748.aspx
>
> <http://weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framewo...>
>
> http://cristobal.baray.com/indiana/projects/mvc.html
>
> http://www.devx.com/dotnet/Article/29992/0/page/1
>
> What is Model-View-Presenter?
>
> MVP is a software pattern considered a derivative of the
> Model-view-controller.
>
> http://en.wikipedia.org/wiki/Model_View_Presenter
>
> http://msdn.microsoft.com/en-us/magazine/cc188690.aspx
>
> http://mrrask.files.wordpress.com/20...-presenter.pdf
>
> http://www.mvcsharp.org/Reworking_AS...e/Default.aspx
>
> <http://www.codeproject.com/KB/aspnet/ModelViewPresenter1.aspx?fid=153....>
>
> <http://codebetter.com/blogs/jeremy.miller/archive/2006/02/01/test-dri...>
>
> MODEL-VIEW-PRESENTER
>
> http://www.polymorphicpodcast.com/
>
> click 'Shows'
>
> click 'Design Patterns Bootcamp: Model View * Patterns*
>
> view parts *1-5
>
> What is Object Relational Mapping?
>
> (ORM) is a programming technique for converting data between
> incompatible type systems in relational databases and object-oriented
> programming languages. This creates, in effect, a "virtual object
> database," which can be used from within the programming language. There
> are both free and commercial packages available that perform
> object-relational mapping, although some programmers opt to create their
> own ORM tools.
>
> http://en.wikipedia.org/wiki/O-RM
>
> http://www.objectmatter.com/vbsf/doc...ormapping.html
>
> What is Language Integrated Query?
>
> LINQ is a Microsoft .NET Framework component that adds native data
> querying capabilities to .NET languages.
>
> Microsoft LINQ defines a set of query operators that can be used to
> query, project and filter data in arrays, enumerable classes, XML,
> relational database, and third party data sources. While it allows any
> data source to be queried, it requires that the data be encapsulated as
> objects. So, if the data source does not natively store data as objects,
> the data must be mapped to the object domain. Queries written using the
> query operators are executed either by the LINQ query processing engine
> or, via an extension mechanism, handed over to LINQ providers which
> either implement a separate query processing engine or translate to a
> different format to be executed on a separate data store (such as on a
> database server as SQL queries). The results of a query are returned as
> a collection of in-memory objects that can be enumerated using a
> standard iterator function such as C#'s foreach.
>
> Many of the concepts that LINQ has introduced were originally tested in
> Microsoft's C? research project. LINQ was released as a part of .NET
> Framework 3.5 on November 19, 2007.
>
> http://en.wikipedia.org/wiki/Language_Integrated_Query
>
> What is Linq-to-SQL?
>
> LINQ to SQL, a component of Visual Studio Code Name "Orcas", provides a
> run-time infrastructure for managing relational data as objects without
> losing the ability to query. It does this by translating
> language-integrated queries into SQL for execution by the database, and
> then translating the tabular results back into objects you define. Your
> application is then free to manipulate the objects while LINQ to SQL
> stays in the background tracking your changes automatically.
>
> http://msdn.microsoft.com/en-us/library/bb425822.aspx
>
> What is ADO.NET Entities framework?
>
> ADO.NET Entity Framework is an object-relational mapping (ORM) framework
> for the .NET Framework. This framework is Microsoft's first ORM offering
> for the .NET Framework. While Microsoft provided objects to manage the
> Object-relational impedance mismatch (such as a DataSet).
>
> ADO.NET Entity Framework is included with .NET Framework 3.5 Service
> Pack 1 and Visual Studio 2008 Service Pack 1, released on ...
>
> read more


Hi Arnold,

Thank you for your detail email. Just to get me started with the
concept (zooming out a little). Let's say I just want to create a
class in a separate project to write a string to a file (that's it). I
also want to use this in my web application (.cs file). So that I can
instantiate the object and call the .write("my string"). Do I create
unit tests in the project that's writing to the file first to make
sure it's doing what it's suppose to do? Setting break points if
needed? or is there a way to run my web application and set break
points in my write to file project as well?

Sorry if this sounds really stupid. I just want to start with this to
see how it works and then I'll do more reading.

So far, I've been defining classes in App_Code folder of the same web
app. 'ex. ManageContacts'. Where I instantiate it in ex.
default.aspx.cs to perform update, insert,...etc.. So on button
click,
ManageContacts mc = new ManageContacts();
mc.Insert(record);




Thank again
M.

 
Reply With Quote
 
Mr. Arnold
Guest
Posts: n/a
 
      11-01-2009
mazdotnet wrote:
> On Oct 31, 4:59 pm, "Mr. Arnold" <(E-Mail Removed)> wrote:
>> mazdotnet wrote:
>>> Hi,
>>> I've been doing web development for a long time using a single web
>>> application file (Classes in App_Code folder). However, now I'm
>>> starting a new web application and I want to break all the layers
>>> into
>>> different projects where at least Web Application is one project &
>>> a
>>> data access layer is another project.

>> It should be UI/BLL/DAL. The UI should not be in contact with the DAL.
>> If you want to come right down to it, the UI should not be in contact
>> with the BLL either.
>>
>>
>>
>>> My steps,
>>> I create an application in IIS 'e.g., MyAppSite'. (I like to use IIS)
>>> I create a new solution in VS2008 and add a class libary project
>>> 'DAL'
>>> <- is this correct?

>> You're missing some layers.
>>
>>> I add thehttp://localhost/MyAppSiteto the solution
>>> I change the output of my DAL to point tohttp://localhost/MyAppSite/Bin
>>> and everything works fine.
>>> My problem is debugging DAL project (I'm using LINQ to SQL). Is there
>>> way for me to set break points in DAL project and see what the values
>>> are? Without creating a unit test project for my .dbml file since it
>>> has so many methods?

>> You don't test the database model. You test the classes/objects of the
>> DAL that act upon the database model.
>>
>> Many call a functional test a unit test. They are two different types of
>> tests, which can be done with a test-harness.
>>
>> A unit test is about the simulation of object behavior within the domain
>> for expected results with pre-written test cases against the domain --
>> Domain Driven Design and Test Driven Design.
>>
>> A functional test is about testing functionality, whereas, testing
>> involves the database, filesystem, going across a network and special
>> configuration like a config file being used to perform the test.
>>
>>> I might want to add transactions later using
>>> stored procedure and my own C# class..etc, I want to test the output
>>> of the DAL (data access layer) to make sure it works (where I want to
>>> set breakpoints if needed)

>> You can put the classes/objects in the DAL into a transactional mode
>> against the Linq-2-SQL model by using the System.Transaction. You don't
>> need spocs.
>>
>> You need to find out how to use the ADO.NET Entity Framework an ORM
>> solution. You can start with Link-2-SQL but where you should position
>> yourself is using EF.
>>
>>> Can you please explain how I can do this? Am I taking the correct
>>> approach by creating a Class Project for my data access layer or I
>>> should be doing this differently?

>> UI
>> MVP or MVC
>> BLL
>> WCF
>> DAL
>> database Model
>>
>> And yes, you can set breakpoints in each one of the layers and single
>> step all the way from the UI to the DAL.
>>
>> You should get the book and get the DOFactory software and learn.
>>
>> http://headfirstlabs.com/books/hfdp/
>>
>> Dofactory is well worth the price if you're interested in how to
>> develop n-tiered solutions.
>>
>> Head First is in the dofactory.
>>
>> http://www.dofactory.com/Framework/Framework.aspx
>>
>> I'll give you the rest of my little take on things, which a is needed to
>> develop solid .NET solutions, particularly Web and SOA solutions.
>>
>> What is Object-oriented-programming?
>>
>> (OOP) is a programming paradigm that uses "objects" and their
>> interactions to design applications and computer programs.
>>
>> The key concepts of OOP are the following:
>>
>> Class
>> Object
>> Instance
>> Method
>> Message passing
>> Inheritance
>> Abstraction
>> Encapsulation
>> Polymorphism
>> Decoupling
>>
>> http://en.wikipedia.org/wiki/Object-...ed_programming
>>
>> No matter what development platform Java, .Net or others OOP is OOP.
>>
>> http://math.hws.edu/eck/cs124/downlo...Zulu-Natal.pdf
>>
>> http://www.blackwasp.co.uk/ObjectOrientedConcepts.aspx
>>
>> What are design patterns?
>>
>> Design patterns are recurring solutions to software design problems you
>> find again and again in real-world application development. Patterns are
>> about design and interaction of objects, as well as providing a
>> communication platform concerning elegant, reusable solutions to
>> commonly encountered programming challenges.
>>
>> http://www.developer.com/design/article.php/1502691
>>
>> http://www.dofactory.com/Patterns/Patterns.aspx
>>
>> <http://computerprogramming.suite101....terns_and_anti...
>>
>> http://msdn.microsoft.com/en-us/library/ms954638.aspx
>>
>> http://www.designpatternsfor.net/Pre...px?tid=3&cid=4
>>
>> What is Domain Driven Design?
>>
>> (DDD) is an approach to the design of software, based on the two
>> premises [1] that complex domain designs should be based on a model, and
>> that, for most software projects, the primary focus should be on the
>> domain and domain logic (as opposed to being the particular technology
>> used to implement the system).
>>
>> http://en.wikipedia.org/wiki/Domain-driven_design
>>
>> What is Test Driven Design?
>>
>> (TDD) is a software development technique that uses short development
>> iterations based on pre-written test cases that define desired
>> improvements or new functions. Each iteration produces code necessary to
>> pass that iteration's tests. Finally, the programmer or team refactors
>> the code to accommodate changes. A key TDD concept is that preparing
>> tests before coding facilitates rapid feedback changes. Note that
>> test-driven development is a software design method, not merely a method
>> of testing.
>>
>> http://en.wikipedia.org/wiki/Test-driven_development
>>
>> http://weblogs.asp.net/rhurlbut/arch...her-tdd-and-dd...
>>
>> What is Model-View-Controller?
>>
>> (MVC) is an architectural pattern used in software engineering.
>> Successful use of the pattern isolates business logic from user
>> interface considerations, resulting in an application where it is easier
>> to modify either the visual appearance of the application or the
>> underlying business rules without affecting the other. In MVC, the model
>> represents the information (the data) of the application; the view
>> corresponds to elements of the user interface such as text, checkbox
>> items, and so forth; and the controller manages the communication of
>> data and the business rules used to manipulate the data to and from the
>> model.
>>
>> http://en.wikipedia.org/wiki/Model-view-controller
>>
>> http://msdn.microsoft.com/en-us/library/ms978748.aspx
>>
>> <http://weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framewo...>
>>
>> http://cristobal.baray.com/indiana/projects/mvc.html
>>
>> http://www.devx.com/dotnet/Article/29992/0/page/1
>>
>> What is Model-View-Presenter?
>>
>> MVP is a software pattern considered a derivative of the
>> Model-view-controller.
>>
>> http://en.wikipedia.org/wiki/Model_View_Presenter
>>
>> http://msdn.microsoft.com/en-us/magazine/cc188690.aspx
>>
>> http://mrrask.files.wordpress.com/20...-presenter.pdf
>>
>> http://www.mvcsharp.org/Reworking_AS...e/Default.aspx
>>
>> <http://www.codeproject.com/KB/aspnet/ModelViewPresenter1.aspx?fid=153...>
>>
>> <http://codebetter.com/blogs/jeremy.miller/archive/2006/02/01/test-dri...>
>>
>> MODEL-VIEW-PRESENTER
>>
>> http://www.polymorphicpodcast.com/
>>
>> click 'Shows'
>>
>> click 'Design Patterns Bootcamp: Model View * Patterns*
>>
>> view parts 1-5
>>
>> What is Object Relational Mapping?
>>
>> (ORM) is a programming technique for converting data between
>> incompatible type systems in relational databases and object-oriented
>> programming languages. This creates, in effect, a "virtual object
>> database," which can be used from within the programming language. There
>> are both free and commercial packages available that perform
>> object-relational mapping, although some programmers opt to create their
>> own ORM tools.
>>
>> http://en.wikipedia.org/wiki/O-RM
>>
>> http://www.objectmatter.com/vbsf/doc...ormapping.html
>>
>> What is Language Integrated Query?
>>
>> LINQ is a Microsoft .NET Framework component that adds native data
>> querying capabilities to .NET languages.
>>
>> Microsoft LINQ defines a set of query operators that can be used to
>> query, project and filter data in arrays, enumerable classes, XML,
>> relational database, and third party data sources. While it allows any
>> data source to be queried, it requires that the data be encapsulated as
>> objects. So, if the data source does not natively store data as objects,
>> the data must be mapped to the object domain. Queries written using the
>> query operators are executed either by the LINQ query processing engine
>> or, via an extension mechanism, handed over to LINQ providers which
>> either implement a separate query processing engine or translate to a
>> different format to be executed on a separate data store (such as on a
>> database server as SQL queries). The results of a query are returned as
>> a collection of in-memory objects that can be enumerated using a
>> standard iterator function such as C#'s foreach.
>>
>> Many of the concepts that LINQ has introduced were originally tested in
>> Microsoft's C? research project. LINQ was released as a part of .NET
>> Framework 3.5 on November 19, 2007.
>>
>> http://en.wikipedia.org/wiki/Language_Integrated_Query
>>
>> What is Linq-to-SQL?
>>
>> LINQ to SQL, a component of Visual Studio Code Name "Orcas", provides a
>> run-time infrastructure for managing relational data as objects without
>> losing the ability to query. It does this by translating
>> language-integrated queries into SQL for execution by the database, and
>> then translating the tabular results back into objects you define. Your
>> application is then free to manipulate the objects while LINQ to SQL
>> stays in the background tracking your changes automatically.
>>
>> http://msdn.microsoft.com/en-us/library/bb425822.aspx
>>
>> What is ADO.NET Entities framework?
>>
>> ADO.NET Entity Framework is an object-relational mapping (ORM) framework
>> for the .NET Framework. This framework is Microsoft's first ORM offering
>> for the .NET Framework. While Microsoft provided objects to manage the
>> Object-relational impedance mismatch (such as a DataSet).
>>
>> ADO.NET Entity Framework is included with .NET Framework 3.5 Service
>> Pack 1 and Visual Studio 2008 Service Pack 1, released on ...
>>
>> read more

>
> Hi Arnold,
>
> Thank you for your detail email. Just to get me started with the
> concept (zooming out a little). Let's say I just want to create a
> class in a separate project to write a string to a file (that's it). I
> also want to use this in my web application (.cs file). So that I can
> instantiate the object and call the .write("my string"). Do I create
> unit tests in the project that's writing to the file first to make
> sure it's doing what it's suppose to do? Setting break points if
> needed? or is there a way to run my web application and set break
> points in my write to file project as well?


http://www.artima.com/weblogs/viewpo...?thread=126923

>
> Sorry if this sounds really stupid. I just want to start with this to
> see how it works and then I'll do more reading.
>
> So far, I've been defining classes in App_Code folder of the same web
> app. 'ex. ManageContacts'. Where I instantiate it in ex.
> default.aspx.cs to perform update, insert,...etc.. So on button
> click,
> ManageContacts mc = new ManageContacts();
> mc.Insert(record);
>
>


Your solution should have this as an example.

1) ClassLib project that has your ManageContacts.cs

2) FunctionalTest Project that has a project reference to the ClassLib
project that contains ManageContacts.cs, a reference to a Test framework
like MBUnit and a Test.cs in the project to test ManageContacts via the
Test framework.

3) With a Test.cs method doing a functional test against ManageContacts,
you test for expected results returned with an Assert statement.

http://msdn.microsoft.com/en-us/libr...17(VS.80).aspx

Either the expected results returned based on the Assert for the Test
passed or it failed.

The Assert may not come into play until other testing logic is ran to
test the results of what ManageContacts produced, like reading the file,
the file was there.

If the test failed, then you would go into debug mode and run the test
with breakpoints and single step into Test.cs test method right into
ManageContacts to debug ManageContacts.

You will make your code corrections and test again, until the test is
passed based on expected results.

4) You set project reference to the Classlib project that contains
ManageContacts.cs in the Web Project. You can do a functional test there
too by setting breakpoints and stepping into the code of the Web and
Classlib projects.

The FunctionalTest project is just another Classlib project with the
test framework.

The VS.sln for the solution will have three projects in it using project
reference from Web and FunctionalTest projects to the project that has
ManageContacts.cs

If the functional test has verified that the test of ManageContacts.cs
has passed based on expected results returned, then it should be
expected that results of ManageContacts.cs will be good in the Web
project without testing it, because it has already been tested for
success.

That's what functional testing using a test-harness is about, which is
not a unit test as far as DDD and TDD is concerned using a test-harness.


 
Reply With Quote
 
Mr. Arnold
Guest
Posts: n/a
 
      11-01-2009
mazdotnet wrote:

<correction>

4) You set project reference to the Classlib project that contains
ManageContacts.cs in the Web Project. You can do a functional test there
too by setting breakpoints and stepping into the code of the Web and
Classlib projects.

You don't set reference to the FunctionalTest project from the Web project.
 
Reply With Quote
 
mazdotnet
Guest
Posts: n/a
 
      11-01-2009
On Oct 31, 8:21*pm, "Mr. Arnold" <(E-Mail Removed)> wrote:
> mazdotnet wrote:
>
> <correction>
>
> 4) You set project reference to the Classlib project that contains
> ManageContacts.cs in the Web Project. You can do a functional test there
> too by setting breakpoints and stepping into the code of the Web and
> Classlib projects.
>
> You don't set reference to the FunctionalTest project from the Web project.


Worked. Just out of curiosity. I work on a lot corporate sites (agency
type of work with HTML, CSS, JavaScript, jQuery, asp.net, PHP...etc.).
What I've been doing so far with asp.net

Steps,

Create classes in App_Code
ex to manage campaigns
Create a class CampaignInfo (to hold the campaign info e.g. name,
start and end date, requestor, requestor ip...etc.)
another class ManageCampaign to perform operations such as insert,
update, delete,...etc. (This is the part I want to switch to LINQ to
SQL and thank to you I'll be looking at the ADO.NET Entity Framework)

In my aspx page I have the user controls, master pages...etc. (no
business logic just UI)
and in my code behind I call the proper method to grab for instance
campain information and bind it to the screen.

For this kind of a scenerio is this a bad practise? Do I need to
separate everything into different projects? Or is it ok to separate
the layers and keep them in the same project? It's not an enterprise
level application.



Thank you for all your help
M.
 
Reply With Quote
 
Mr. Arnold
Guest
Posts: n/a
 
      11-01-2009
mazdotnet wrote:
> On Oct 31, 8:21 pm, "Mr. Arnold" <(E-Mail Removed)> wrote:
>> mazdotnet wrote:
>>
>> <correction>
>>
>> 4) You set project reference to the Classlib project that contains
>> ManageContacts.cs in the Web Project. You can do a functional test there
>> too by setting breakpoints and stepping into the code of the Web and
>> Classlib projects.
>>
>> You don't set reference to the FunctionalTest project from the Web project.

>
> Worked. Just out of curiosity. I work on a lot corporate sites (agency
> type of work with HTML, CSS, JavaScript, jQuery, asp.net, PHP...etc.).
> What I've been doing so far with asp.net
>
> Steps,
>
> Create classes in App_Code
> ex to manage campaigns


> Create a class CampaignInfo (to hold the campaign info e.g. name,
> start and end date, requestor, requestor ip...etc.)


Those are business objects that should be in the BLL project. But more
precisely, those are DTO(s) that transfer data from/to the UI and BLL.

And DTO(s) are also used between the BLL and the DAL.

> another class ManageCampaign to perform operations such as insert,
> update, delete,...etc.


The class should be in the DAL as it's a Data access object.

However, the ManageCampaign object should be in a MVC or MVP service
layer that the BLL methods are using to access an object/class's method
in the DAL.


> (This is the part I want to switch to LINQ to
> SQL and thank to you I'll be looking at the ADO.NET Entity Framework)


With working with Link-2-SQL or the ADO.NET Entity Framework, you're
dealing with objects/entities. The database tables on the model are
objects, which forces you to understand the basics of OOP and design
patterns to be successful.
>
> In my aspx page I have the user controls, master pages...etc. (no
> business logic just UI)


The UI should be a dumb UI with only logic in the Web form or
UserControl to work with the UI controls, forms etc, ect.

> and in my code behind I call the proper method to grab for instance
> campain information and bind it to the screen.


The codebehind should only be making calls to methods on the MVC or MVP
layer to access the BLL which in turn access the DAL to persist data to
or receive data from the EF Model.
>
> For this kind of a scenerio is this a bad practise? Do I need to
> separate everything into different projects? Or is it ok to separate
> the layers and keep them in the same project? It's not an enterprise
> level application.


You should follow a best practice scenario whether it's an enterprise
level solution or not.

Multiple projects should be keep in the same solution, not everything in
the same project.

Nothing is hack-proof or bullet-proof, but many others would say that
your method of design leads to the Web application being hacked more
easily, because everything is in one project, as opposed to being
layered or n-tiered.

In enterprise solutions, the layers are across physical boundaries using
n-tier.

In a none enterprise solution where the Web server is acting as the
application server too, then the layers can be kept on the same server
n-tiered.

N-tier applications are more flexible and scalable.

I suggest you take a hard look at the DoFactory stuff I provided.

There is nothing wrong with Linq-2-SQL but MS is putting all of its
efforts towards ADO.NET EF. You should find out what Entity SQL or ESQL
is about, which is not unlike T-SQL but it's against the EF-Model.

The thing with MVP as opposed to MVC, you can run unit tests against MVP.

HTH


 
Reply With Quote
 
mazdotnet
Guest
Posts: n/a
 
      11-01-2009
On Nov 1, 12:43*am, "Mr. Arnold" <(E-Mail Removed)> wrote:
> mazdotnet wrote:
> > On Oct 31, 8:21 pm, "Mr. Arnold" <(E-Mail Removed)> wrote:
> >> mazdotnet wrote:

>
> >> <correction>

>
> >> 4) You set project reference to the Classlib project that contains
> >> ManageContacts.cs in the Web Project. You can do a functional test there
> >> too by setting breakpoints and stepping into the code of the Web and
> >> Classlib projects.

>
> >> You don't set reference to the FunctionalTest project from the Web project.

>
> > Worked. Just out of curiosity. I work on a lot corporate sites (agency
> > type of work with HTML, CSS, JavaScript, jQuery, asp.net, PHP...etc.).
> > What I've been doing so far with asp.net

>
> > Steps,

>
> > Create classes in App_Code
> > ex to manage campaigns
> > Create a class CampaignInfo (to hold the campaign info e.g. name,
> > start and end date, requestor, requestor ip...etc.)

>
> Those are business objects that should be in the BLL project. But more
> precisely, those are DTO(s) that transfer data from/to the UI and BLL.
>
> And DTO(s) are also used between the BLL and the DAL.
>
> > another class ManageCampaign to perform operations such as insert,
> > update, delete,...etc.

>
> The class should be in the DAL as it's a Data access object.
>
> However, the ManageCampaign object should be in a MVC or MVP service
> layer that the BLL methods are using to access an object/class's method
> in the DAL.
>
> > (This is the part I want to switch to LINQ to
> > SQL and thank to you I'll be looking at the ADO.NET Entity Framework)

>
> With working with Link-2-SQL or the ADO.NET Entity Framework, you're
> dealing with objects/entities. The database tables on the model are
> objects, which forces you to understand the basics of OOP and design
> patterns to be successful.
>
>
>
> > In my aspx page I have the user controls, master pages...etc. (no
> > business logic just UI)

>
> The UI should be a dumb UI with only logic in the Web form or
> UserControl to work with the UI controls, forms etc, ect.
>
> > and in my code behind I call the proper method to grab for instance
> > campain information and bind it to the screen.

>
> The codebehind should only be making calls to methods on the MVC or MVP
> layer to access the BLL which in turn access the DAL to persist data to
> or receive data from the EF Model.
>
>
>
> > For this kind of a scenerio is this a bad practise? Do I need to
> > separate everything into different projects? Or is it ok to separate
> > the layers and keep them in the same project? It's not an enterprise
> > level application.

>
> You should follow a best practice scenario whether it's an enterprise
> level solution or not.
>
> Multiple projects should be keep in the same solution, not everything in
> the same project.
>
> Nothing is hack-proof or bullet-proof, but many others would say that
> your method of design leads to the Web application being hacked more
> easily, because everything is in one project, as opposed to being
> layered or n-tiered.
>
> In enterprise solutions, the layers are across physical boundaries using
> n-tier.
>
> In a none enterprise solution where the Web server is acting as the
> application server too, then the layers can be kept on the same server
> n-tiered.
>
> N-tier applications are more flexible and scalable.
>
> I suggest you take a hard look at the DoFactory stuff I provided.
>
> There is nothing wrong with Linq-2-SQL but MS is putting all of its
> efforts towards ADO.NET EF. You should find out what Entity SQL or ESQL
> is about, which is not unlike T-SQL but it's against the EF-Model.
>
> The thing with MVP as opposed to MVC, you can run unit tests against MVP.
>
> HTH- Hide quoted text -
>
> - Show quoted text -


Thank you for all the great information you provided me. Now I have a
good starting point.
Maz
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Layer 2 Data Center Access Layer Redundancy for VMWare Servers crackerman6969 Cisco 2 08-26-2009 11:36 PM
business layer, data access layer , presentation layer for asp.net using C#.net Dhananjay ASP .Net 1 12-18-2006 11:35 PM
The business layer and data access layer java-john Java 0 03-23-2006 07:10 PM
CSS Position Layer relative to bottom of another layer. Dave Smithz HTML 11 01-25-2006 03:01 PM
Using transparent layer for data input (glassPane?) over another layer Wolfgang Java 1 05-01-2004 03:09 AM



Advertisments