Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8161563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:31:32+00:00 2026-06-06T18:31:32+00:00

Trying to implement 3-layer (not: tier, I just want to separate my project logically,

  • 0

Trying to implement 3-layer (not: tier, I just want to separate my project logically, on one machine) architecture I’ve found so many different approaches that I’m confused, what’s the best way (if there’s any) to make that in WinForms app.

Now I have no doubts only about 3 layers that should be present in the project:

  • UI (Presentation Layer)
  • BLL (Business Logic Layer)
  • DAL (Data Acces Layer)

In UI I put all the WinForms. There must be also some logic to fill the object with data from controls and pass it to BLL layer.

In DAL I want to put classes and methods for data manipulations using ADO.NET, like:

public class OrderDAL
{
    public OrderDAL()
    {
    }

    public int Add(Order order)
    {
        //...add order to database
    }

    public int Update(Order order)
    {
        //...update order in database
    }

    //...etc.
}

The problem is with BLL and the question – should I use Data Transfer Objects to pass data between layers, or should I pass the whole Class?

If I choose to use DTO, then I’ve to create additional common class, Order, that reference to UI, BLL and DAL:

public class Order
{
    public int Id { get; set; }
    public DateTime Date { get; set; }
    public string Number { get; set; }
    public string CustomerName { get; set; }

    public Order ()
    {
    }
}

and put the logic separated into BLL:

public class OrderBLL
{
    public OrderBLL()
    {
    }

    public int Add(Order order)
    {
        OrderDAL orderDAL = new OrderDAL();
        return orderDAL.Add(order);
    }

    public int Update(Order order)
    {
        OrderDAL orderDAL = new OrderDAL();
        return orderDAL.Update(order);
    }

    //...etc.
}

This approach, under different names, is used among others: here or here.
On the other hand, some “wise guys” and their followers (like here) call it Anemic Domain Model and complain it’s a bad design and anti-pattern that should not be used.

The pros:

  • DTO can easily by design to represent Database table,
  • it’s light and clear, contains only fields needed for database,
  • DAL doesn’t have to reference BLL,

The cons:

  • anti-pattern (sounds scary ;P),
  • violation of OOP (separated properties from methods),
  • because logic is in different class, it may be more difficult to maintain when something changes.

So, the opposite approach is to pass the whole object between layers, like here: no DTO, just BLL looking like that:

public class Order
{
    public int Id { get; set; }
    public DateTime Date { get; set; }
    public string Number { get; set; }
    public string CustomerName { get; set; }

    public Order()
    {
    }

    public int Add()
    {
        OrderDAL orderDAL = new OrderDAL();
        return orderDAL.Add(this);
    }

    public int Update(Order order)
    {
        OrderDAL orderDAL = new OrderDAL();
        return orderDAL.Update(order);
    }
}

The pros:

  • it’s a nicely encapsulated object, following OOP rules (I suppose ;)).
  • both logic and properties are in one place, easier to maintain and debug.

The cons:

  • to use the object, DAL has to reference BLL (that’s not how the 3-tier layer should do, isn’t it?).
  • class may contain some fields that are not used in Database, as well as some fields from Database (like Id) do not represent “real life” object.

So, it looks like whatever I choose, I’ll violate some rules. What’s better way then, which should I choose? Maybe there is other approach I haven’t found?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:31:33+00:00Added an answer on June 6, 2026 at 6:31 pm

    I don’t like DTOs, because they mean creating a dual hierarchy with little or no value.

    I also don’t like the idea of making model objects responsible for their own persistence. I prefer a separate persistence layer. Why? Model objects don’t always need to be persisted to be useful. Business logic and functionality are orthogonal to persistence.

    If you have two layers it’s possible to keep a one way dependency graph: persistence knows about model, but model does not know about persistence. You end up with a cyclic dependency if model objects are responsible for persistence. You can never test or use model objects without persistence.

    My advice? Don’t do DTOs. Break out a separate persistence layer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we are trying to implement an application using the Service Layer Pattern cause our
I'm just trying to implement a really really small RTSP Client with Boost Asio.
We’re trying to implement a data layer with ORM between our domain entities and
I’m trying to reevaluate our n-layer architecture and would love to get some suggestions
I'm working with an MVC project, trying to implement IoC and DI. Both these
I'm trying to implement a Hibernate persistence layer in a Java application and I'm
I am trying to implement SSO using SAP logon tickets in a 3 tier
I am trying to implement some MVC-style UI components in Flex 4. I want
I've seen many tutorials but not similar with what I'm trying to build... Creating
I'm trying implement A* Start path finding in my games(which are written with JavaScript,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.