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

  • Home
  • SEARCH
  • 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 5947479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:58:12+00:00 2026-05-22T16:58:12+00:00

I have a project with 3 layers. UI, Business Layer and Data Layer. UI

  • 0

I have a project with 3 layers. UI, Business Layer and Data Layer.

UI calls BL. BL Calls DL. DL does the database operations. its that simple.

I wanted to unit test my BL methods so i changed it a bit and now i am accepting DL as a parameter in the BL constructor so that i can create Mock object of DL.

This makes me change my UI layer as my UI calls my BL and as per architecture rules i think its not a good design if i add reference of my DL to my UI.

Can someone suggest a better way? Do i need to change the architecture or am i doing something wrong here? May be i can introduce Facade Manager here? An example of your suggestion will be highly appreciated.

–Edit–

Here is the code:

in BL:

    public MyBusinessLayer()
    {

    }
    //To pass mock object of WCF Service
    public MyBusinessLayer(ISomeServices svc)
    {
        someServiceRef = svc;
    }

    //To pass mock object of Data Layer.
    public MyBusinessLayer(ISomeDataLayer dl)
    {
        someDlRef = dl;
    }

in UI:

//To do this i have to add DL reference to UI
MyBusinessLater b = new MyBusinessLayer(new ISomeService());
  • 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-05-22T16:58:13+00:00Added an answer on May 22, 2026 at 4:58 pm

    IoC would be perfect for this job. Your BL should only rely on an interface that can get the data it needs. Then, using IoC, register the actual DB implementation with the interface. The UI should then get injected with an interfaced BL. Therefore, when the app starts up, you register all the dependencies, and just inject the BL interface into the UI, so the UI has no knowledge of the fact that the actual BL implementation relies on a DL interface.

    Here’s just on example I found on the net. Just google for C# IOC or C# Dependency Injection.
    http://www.dotnetspark.com/kb/266-inversion-control-ioc-and-dependency-injection.aspx

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

Sidebar

Related Questions

In a visual studio project I have three layers, Data Layer, Business Layer and
I have a project of business objects and a data layer that could potentially
I'm working on a project in which we have a database, data layer (entity
I have split my .NET project into three different layers Facade Layer, Business Layer
I have a project with a formidable data access layer using LinqtoSQL for just
I have a project called Data which is a data layer. In this project,
I have a project that in those i draw some shape from some layer.
I have inherited a project that uses LLBLGen Pro for the DB layer. The
Here's the setup I have in a vs2008 solution: Data layer in a project
I have to create website with business layer and data access layer. I want

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.