C# - Proper Implementation Of N-layer Architecture?

Feb 28, 2011

I have been learning C# for the last year or so and trying to incorporate best practices along the way. Between StackOverflow and other web resources, I thought I was on the right track to properly separating my concerns, but now I am having some doubts and want to make sure I am going down the right path before I convert my entire website over to this new architecture.

The current website is old ASP VBscript and has a existing database that is pretty ugly (no foreign keys and such) so at least for the first version in .NET I do not want to use and have to learn any ORM tools at this time.

I have the following items that are in separate namespaces and setup so that the UI layer can only see the DTOs and Business layers, and the Data layer can only be seen from the Business layer. Here is a simple example:


Am I completely off base? Should I also have the same properties in my BLL and not pass back DTOs to my UI? what is wrong and what is right. Keep in mind I am not a expert yet.

I would like to implement interfaces to my architecture, but I am still learning how to do that.

View 4 Replies

Similar Messages:

Architecture :: A Proper DI Implementation?

Feb 27, 2011

I'm fairly new to dependency injection but it seems like a proper DI implementation will be fairly complex.

For example, DI requires a centralized class that manages the configuration and resolves the dependencies at runtime.

DI is also based on the concept of using interfaces. For example, a SpecialLogger should use an ILogger interface.

The centralized DI manager class will need to register types - for example, associate ILogger to SpecialLogger.

SpecialLogger will also need to implement the ILogger interface so SpecialLogger can be used through the DI ILogger interface.

Therefore, it seems like a sln using DI will need multiple projects to support DI. Here is an example for logging:

* MyCompany.MyDivision.Framework.DI.Management - this would have the DI manager where dependency types are registered and resolved at runtime
* MyCompany.MyDivision.Framework.Logging - this would have the implementation of a logging class. The main logging class would need to implement ILogger.
* MyCompany.MyDivision.Framework.DI.Interfaces - this would have the ILogger interface.

Interfaces would need to be stored in a separate class library from the DI manager because both the DI manager and SpecialLogger use the ILogger interface. Since the DI manager associates SpecialLogger to ILogger a circular reference would be encountered without a separate class library to store the ILogger interface.

View 1 Replies

Proper Implementation Of MVP With Complex Controls?

Jan 20, 2010

I'm currently implementing a project using asp.net, c# and the MVP (Model-View-Presenter) pattern. The main purpose of this solution is to deliver a graph to the consumer, to be used by a variety of systems. It is basically a custom graph server.

The view page in this particular case has an MSChart control on it, which has to be dynamically populated and configured based on parameters in the QueryString. This can be as diverse as totally different types of data sets, display modes and so on, using a lot of the properties of the chart control.

Many of these properties are again of types which are particular to the chart control and would require the same dependencies as the chart control itself if they are to be set by the presenter.

I'm trying to figure out the best way to expose the properties to the presenter so it can work its magic.

Should I:

Just expose the whole chart object and live with a system.web type dependency in the presenter project? Make accessor and translation properties for all of the chart control properties so that I don't have the dependency, but add lots of complexity? Other, that I haven't thought of?

To me it seems that it would be against the MVP pattern to bubble a display control up into the presenter, but it seems that trying to map all the properties to DTOs or similar would be a lot of work that would add a lot of complexity, and while the solution would be somewhat more loosely coupled, I'm not sure the gain would be worth it in this case. How would you implement something like this, given MVP?

View 2 Replies

Architecture :: How To Pass The Values From Presentation Layer To Business Logic Layer

Oct 26, 2010

I am new to this .NET what is the difference between N-Tier and 3- Tier Architecture. If they are same. How to pass the values from presentation layer to business logic layer.

For Example

I have 10 controls in presentation layer. I passing values to these controls. How the architecture works.

View 3 Replies

Architecture :: Data Access Layer And Business Logic Layer?

Jun 24, 2010

I am building a web site following the tutorials on asp.net. I am using dataset as data access lay, and writing classes to access the dataset. But the example is just basic ideas, how do I retrieve individual table column value in the business layer?For example, if I have a table called Product, I only want to find out what is the product name by product id. I did this in my ProductBLL:

public ProductBLL
public int GetProductName(string productId)
ProductDataSet.ProductDataTable prodData = Adapter.GetProductById(productId);

Is there a better way, or am I doing this correctly? Can anybody give me a reference to a more complicated business logic model?

View 16 Replies

Architecture :: How The Data Pass From One Layer To Another Layer In Mvc Design Pattern

Apr 1, 2010

how the data pass from one layer to another layer in mvc design pattern...

View 2 Replies

Architecture :: Function Implementation In 3-tier Architecture?

Apr 28, 2010

I have implemented the 3-tier architecture project; DAL, BAL, and presentation layer are three layers in it. I am going to implement the following scenario:

Presentation layer calls to a function in the BAL layer which returns 2 string variable, and in turn this function from BAL layer calls to a DAL layer function which also returns 2 string variable. How can I implement the above scenario?

View 2 Replies

Architecture :: How To Pass The Data Between Data Access Layer And Business Acces Layer

Jun 3, 2010

here i have in 3-tier architecture , how to pass the data between DAL and BAL. i am using grid view to edit the data,when ever i click on the edit button all the corresponding fields should come to textboxes. i tried for delete ,it works fine bt not working to EDIT.

View 7 Replies

C# - Proper Implementation Of Nested API Calls Using Connection Pool And Nested Transactions?

Jan 4, 2010

I need to know the best way to do the following. I have nested business level APIs (say level 1 & level 2). L1 needs to call L2. Both APIs use the database layer directly at their own nesting levels.

Now, in the database layer, I fetch the db connection from the pool each time as follows:

SqlConnection conn = new SqlConnection(connString);

Is it proper to fetch the db connection each time on every DB level call as above? I know it will return a connection from the ASP.NET connection pool. However, wouldn't it be better to maintain the same DB connection throughout the nested calls (or throughout the current http request lifetime)? Will fetching a connection from the pool each time cause issues with nested TransactionScopes?

View 1 Replies

Architecture :: Exception Layer In N-tier Architecture?

May 13, 2010

I'm developing a n-tier architecture... I'm confused with handling exception in the layers... Is it a good practise to add a Exception Layer to the architecture.

View 3 Replies

Website Translation Architecture And Implementation?

Mar 18, 2011

I'm conducting a project in which a website should have multi-language support.Now, this website is supposed to serve about 500K+ visitors a day, so it must be super-efficient.

I've created a table of parameters {[ID],[Name]} AND a linkage-table {[objectID],[parameterID],[languageID],[value]}. I think it's the best way to deploy multi-language support while having the privilege to translate different parameters for each language.

As far as I know, server's memory is much faster than a physical HDD. Therefore, I'm planning to store ASP.NET Application State objects for my translation architecture.[URL]

View 3 Replies

Architecture :: Implementation Of User Authentication In C#?

Feb 15, 2011

I am working on a web application project with a layered architectural style having DAL, BLL, Service Layer and Presentation Layer. It's going to be a Web forms application.

My intent is to try using some of the new features of .Net 3.5 or 4.0.

Currently, I am thinking through different approaches for implementing Authentication in this project.

I have a query regarding the design of the application, particularly Authentication.

In which layer should I have Authentication class? BLL? If I implement the Authentication class in BLL, should I be having an app.config in the same class library project to contain the Database connection string and all.

View 7 Replies

Architecture :: Key, Value Pairs Implementation In Class?

Feb 16, 2010

In a project im working on there are many sql tables containing different ID, Name pairs. Those are represented as Enums in classes that need them however that requires casting since tables contain ID only.Also when serialize the Enum contains the ID not value.

View 3 Replies

Architecture :: Search Engine Implementation?

Jul 22, 2010

not sure if I'm posting to the right thread or not.. but here is the questiondoes anyone know how to implement a best pratice on SEO?One of the example is: if the user types "brand new canon camera" then I want the system to find a sequence of string in the database that contains "new", "cannon", "camera". It is ok with or without the word "brand". However if the user types "HP laptop DV1000" and i want the system to find all HP laptop whether new or not but limited to specific series.

View 3 Replies

Architecture :: What's The Advantages / Disadvantages Of Explicit Interface Implementation

Jul 19, 2010

I am searching for the advantages and disadvantages of the explicit interface implementation

View 1 Replies

Architecture :: Generic Comments Module (Database Design And Implementation)

Feb 10, 2010

I am in the process of redesigning our main product, a knowledge database system for clients to access clinical and specialist advice articles. There is a requirement to add "Social Networking" to this allowing users to connect and post remarks etc...

This is somewhat similar to the Facebook wall scenario - where Articles, Photos, Groups, Products, Events, ActivityFeed can all have comments. I am at a lose as to the database design I would need to implement this. All comments must allow for Moderation/Approval/Spam Reporting etc...

I originally thought a individual table for each Comments entity ex: ArticleComment, ProductComment would work as the comments themselves are not all directly related. Each table having the same exact columns. But this makes life abit awkward as then this creates a separation between something that for all purposes is the same i.e. They are all comments.

The other design idea was to have a single Comment table with an "arc" type relationship to related tables with FK references back to the source.

The other option was to have a single Comment table with an Object Type and XID but this breaks the rules of relation and does not all for referential integrity.

I am at a lose and don't know what to do. I have asked over at SQLCentral.com and all I have done is raised more questions than answers about what to do.

Design 1: This would require exact copies of this table for all the entities.

-- Photo Comments --
CREATE TABLE dbo.PhotoComment
CommentID int IDENTITY(1,1) NOT NULL,
PhotoID int NOT NULL,
Body ntext NOT NULL,
ReportedAsSpam bit NOT NULL CONSTRAINT [DF_PhotoComment_ReportedAsSpam] DEFAULT (0),
IsSpam bit NOT NULL CONSTRAINT [DF_PhotoComment_IsSpam] DEFAULT (0),
IsApproved bit NOT NULL CONSTRAINT [DF_PhotoComment_IsApproved] DEFAULT (1),
CreatedDate datetime NOT NULL,
CreatedBy uniqueidentifier NOT NULL,
UpdatedDate datetime NOT NULL,
UpdatedBy uniqueidentifier NOT NULL,
IsDeleted bit NOT NULL CONSTRAINT [DF_PhotoComment_IsDeleted] DEFAULT (0),
CONSTRAINT [FK_PhotoComment_PhotoID] FOREIGN KEY (PhotoID) REFERENCES dbo.Photo(PhotoID),
CONSTRAINT [FK_PhotoComment_CreatedBy] FOREIGN KEY (CreatedBy) REFERENCES dbo.aspnet_Users(UserId),
CONSTRAINT [FK_PhotoComment_UpdatedBy] FOREIGN KEY (UpdatedBy) REFERENCES dbo.aspnet_Users(UserId)

Design 2: The "Arc" relationship

CREATE TABLE dbo.Comment
CommentID int IDENTITY(1,1) NOT NULL,
CommentType char(1) NOT NULL CHECK(CommentType IN ('A','I','E','G','U','P')),
Body ntext NOT NULL,
ReportedAsSpam bit NOT NULL CONSTRAINT [DF_Comment_ReportedAsSpam] DEFAULT (0),
IsSpam bit NOT NULL CONSTRAINT [DF_Comment_IsSpam] DEFAULT (0),
IsApproved bit NOT NULL CONSTRAINT [DF_Comment_IsApproved] DEFAULT (1),
CreatedDate datetime NOT NULL,
CreatedBy uniqueidentifier NOT NULL,
UpdatedDate datetime NOT NULL,
UpdatedBy uniqueidentifier NOT NULL,
IsDeleted bit NOT NULL CONSTRAINT [DF_Comment_IsDeleted] DEFAULT (0),
CONSTRAINT [FK_Comment_CreatedBy] FOREIGN KEY (CreatedBy) REFERENCES dbo.aspnet_Users(UserId),
CONSTRAINT [FK_Comment_UpdatedBy] FOREIGN KEY (UpdatedBy) REFERENCES dbo.aspnet_Users(UserId),
CONSTRAINT [UC_Comment_CommentID_CommentType] UNIQUE (CommentID, CommentType)

-- Article Comments --
CREATE TABLE dbo.ArticleComment
ArticleID int NOT NULL,
CommentID int NOT NULL,
CommentType char(1) CONSTRAINT [DF_ArticleComment_CommentType] DEFAULT 'A', CHECK (CommentType = 'A'),
CONSTRAINT [FK_ArticleComment_ArticleID] FOREIGN KEY (ArticleID) REFERENCES dbo.Article(ArticleID),
CONSTRAINT [FK_ArticleComment_CommentID] FOREIGN KEY (CommentID) REFERENCES dbo.Comment(CommentID),
CONSTRAINT [FK_ArticleComment_CommentID_CommentType] FOREIGN KEY (CommentID, CommentType) REFERENCES dbo.Comment(CommentID, CommentType)

Design 3: The one that breaks the rules

CREATE TABLE dbo.Comment
CommentID int IDENTITY(1,1) NOT NULL,
ObjectType char(1) NOT NULL, /* A = Article, P = Photo etc... */
XID int NOT NULL, /* Would be the ID of the main entity being queried. */
Body ntext NOT NULL,
ReportedAsSpam bit NOT NULL CONSTRAINT [DF_Comment_ReportedAsSpam] DEFAULT (0),
IsSpam bit NOT NULL CONSTRAINT [DF_Comment_IsSpam] DEFAULT (0),
IsApproved bit NOT NULL CONSTRAINT [DF_Comment_IsApproved] DEFAULT (1),
CreatedDate datetime NOT NULL,
CreatedBy uniqueidentifier NOT NULL,
UpdatedDate datetime NOT NULL,
UpdatedBy uniqueidentifier NOT NULL,
IsDeleted bit NOT NULL CONSTRAINT [DF_Comment_IsDeleted] DEFAULT (0),
CONSTRAINT [FK_Comment_CreatedBy] FOREIGN KEY (CreatedBy) REFERENCES dbo.aspnet_Users(UserId),
CONSTRAINT [FK_Comment_UpdatedBy] FOREIGN KEY (UpdatedBy) REFERENCES dbo.aspnet_Users(UserId),
CONSTRAINT [UC_Comment_CommentID_ObjectType_XID] UNIQUE (CommentID, ObjectType, XID)
-- Ex: Get all comments for article ID 23.
SELECT * FROM Comment Where ObjectType ='A' and XID = '23'

View 1 Replies

Architecture :: Differences Between MVC And 3-Layer?

May 11, 2010

In my opinion, these architectures have some differences, such as:

1. 3-layer is a linear architecture, but MVC is a triangle architecture.

2. Presentation Layer of 3-layer includes View and Controller of MVC? And Model of MVC includes Business Layer and Data Access Layer of 3-layer

I think 2 differences above are not obvious or are incorrect!

View 3 Replies

How To Use Of Business Layer In 3-tier Architecture

Jan 27, 2011

I am implementing 3-tier architecture. I just wanted to know the role of business layer in 3-tier architecture.

I am developing application in using entity framework. So I have entity object which is accessiable in PL,BL & DL. My question is whether input assignment to entity object should be in PL OR BL.(Consider there is save method)

View 2 Replies

Architecture :: Performance Between 3 Or 2 Layer With Linq

Mar 13, 2011

i build online course selection for a university now i want to make it layering and i dont know to make it 2 layer or 3 layer i mean mix business layer and database layer because i use linq so it is not require to check request data that in sql from client in business layer because linq check it autimatically to preent injection and etc.is it right?can i put my class and DB class in same place or layer?if i make it 2 layer the performance becom better?

View 5 Replies

Difference Between Three Tier And Three Layer Architecture?

Feb 12, 2011

whats is the difference three tier and three layer architecture. I need three tier architecture which is fulfill the object oriented requirement. and database change flexibility.

View 4 Replies

Architecture :: Set Images In Business Layer?

Dec 17, 2010

I am creating an ASP.NET MVC application and want to display an icon in the view based on a value of a property in the model. I guess I want to have the logic deciding which image to show in the business layer (which is in a separate class library project) but the actual images files in the web application's "Content" folder. Should I set the url of the image in the business layer? I don't want the business layer to know that is serves a web application, it can be a Windows Form or WPF application as well. If I set the url with System.Web.HttpContext.Current.Server.MapPath it feels like I am getting an unwanted dependency on System.Web, right? What are the options here?

View 1 Replies

Passing XML Document Among 3-tier Architecture Layer?

Oct 31, 2010

I am making use of 3-tier architecture.In UI layer, i am getting user input and converting it into XML document. But now question arises that how can i pass this xml document to business and data access layer?

View 2 Replies

Architecture :: Passing Entities To Business Layer?

Mar 30, 2011

I am working on implementing a web application in ASP.Net by following the MVC design pattern (Not ASP.Net MVC). As part of the design, we have entity objects that has only properties as per the corresponding table structure and the idea is using these entity objects in the view layer and the same entity objects are passed to Persistence Layer for saving the data to the database. Business Objects in the business layer are responsible for interacting with the database.

As view creates the entity objects and passes to next layer, what would be the best practice to pass the entity objects to the business layer? Should the business objects accept data objects as parameters and interact with the persistence layer? Is there any other best practice to pass the required objects from the view layer to the next layer? As business objects also need to access the properties of the entity objects passed from the view layer, do we need any "translation" from entity objects to business objects?

the best practices to pass entity objects from view layer to the next layer and also how the entity objects created by the persistence layer can be used by business objects?

View 6 Replies

Architecture - A Modern N-layer Web Application Sample?

Jul 18, 2010

So my asp.net is very very rusty, and i'm trying to get back into best practices and what not. So, I whip out google and start looking for examples and samples and tutorials, but what do I find? Old crusty stuff that tends to be written even before "the latest" technology was released back in the stone age.Sure, the concepts may still hold up. But the actual implementations are basically useless. I'm looking for something using Linq, n-layers (not tiers. Tiers can be a layer, but a layer is not necessarily a tier) some kind of current ORM (L2S, EF, etc..) and some real-world stuff, not abitrary and useless examples.

View 3 Replies

SQL Server :: Stored Procedure In 3 Layer Architecture?

Sep 17, 2010

I am using stored procedure in my Web application. I am creating SQL Command binding this command with Stored procedure name and parameters and executing.

The problem is for each Stored procedure i need to create separate function for each stored procedure defined.

Is there any way that I can define a single function for n number of stored procedure.

View 4 Replies

Copyrights 2005-15 www.BigResource.com, All rights reserved