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 487679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:37:48+00:00 2026-05-13T01:37:48+00:00

So I’m working on making a draft of my program. This is my plan:

  • 0

So I’m working on making a draft of my program.

This is my plan:

GUI
---
Business Logic
---
Data

You should be able to replace either GUI or the Data layer without issues.
Every layer watches itself. So GUI will call methods from Business logic and the methods will always return a status and perhaps some data. How the GUI should respond to the data, should always be decided in the GUI layer. Business logic should have no influence over this.
So the relations with GUI and business logic has been solved.
I hope you can follow me.

Now for something more concrete.
My plan for the data layer, is to use an database.
Now, how should Business Logic call methods from the data layer?

Perhaps I should make an enum, that corresponds to different hardcoded SQL queries, which the data layer is aware of?

E.g.

Datalayer.GetResults(Queries.GetAllCustomersIDs);

Queries being an enum.

If this is the right way, what should GetResults return? a string array? but what if the query has multidimensional data?

Should I then have 2 generic methods instead?

Datalayer.GetSingleDimensionResults(SingleDimensionQueries.GetAllCustomersIDs);
Datalayer.GetMultipleDimensionResults(MultiDimensionQueries.GetAllCustomers);

Or should I perhaps have a query for each kind of data request?

Datalayer.GetAllCustomerIDs;
DataLayer.GetAllCustomers;

etc.

  • 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-13T01:37:48+00:00Added an answer on May 13, 2026 at 1:37 am

    In general, what I use to do is:

    Data layer:

    For data access, I create an Interface, for each object. Each interface lists all the public data access methods for the object in question. To hold the data, I create container types, for each object as well, which can be structs or simple classes only with data. I also rely on language data set, like lists, to hold my data, so I not linked to a particular database type. After that, I create a class that implements the data interfaces, this class has all SQL and access the database, so in case of change in the data storage technology, this is the only class that will be changed.

    Business layer:

    Does all the logic with data, how to validate, wich methods from the data interfaces should be called and in which order. This class receives and “send” data to the data storage or GUI, using containers (lists for example) where the data types are my containers mentioned above.

    GUI:

    Calls business logic methods and show / format data presentation. There’s no logic here other than call the right methods of the business logic.

    Small code example of a container (C#)

        //Interface for Department class data access. DataStorage assembly
    
        namespace DataStorage
        {
            public interface IDepartmentDS
            {
                void Open();  //Open data conection
                void Close(); //Close data conection
                List<Repositories.Department> List(); //Gets all departments (from data base)
            }
        }
    
    
        //This class holds all data regarded a department. There's no logic here. Repositories assembly
    
        namespace Repositories
        {
            public class Department
            {
                [Browsable(false)]
                public Department()
                {
                }
    
                [Browsable(false)]
                public Department(String Symbol, String Name)
                {
                    this.Symbol = Symbol;
                    this.DeptName = Name;
                }
    
                public Department(Department department)
                {
                    this.Symbol = department.Symbol;
                    this.DeptName = department.DeptName;
                }
    
                [Browsable(false)]
                public String Symbol { get; set; }
    
                public String DeptName { get; set; }
            }
        }
    
    
        //This class implements the data manipulation itself, accessing the real database.
        //However the data exchange outside this class is done via repositories classes and 
        //Generics - Lists mainly
    
        public class DataStorage : IDepartmentDS
        {
           //Here I use to put generic functions to connect with the database, format stored
           //procedure parameters list etc.
    
           //Implementation of the List method declare in the Department Interface
               List<Repositories.Department> IDepartmentDS.List()
                {
                    String query = String.Format("SELECT * FROM {0}", DepartmentTable);
                    int rows = 0;
                    DataSet ds = ExecSqlCommand(query, out rows); //this method is private to this class
    
                    if (ds == null)
                        return null;
    
                    List<Repositories.Department> list = new List<Repositories.Department>();
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        list.Add(new Repositories.Department((String)row[DepFN_Symbol], (String)row[DepFN_DepName]));
                        //DepFN_Symbol and the others are just const variables representing the column index
                    }
    
                    return list;
                }
    
        }
    
    public class DepartmentLogic
    {
       public DepartmentLogic()
       {
          .....
       }
    
       public List<Repositories.Department> GetAllDepartments()
       {
          //Here I create an Instance of the DataStorage but using the Department interface
          //so I restrict the access to Department data methods only. It could be a good 
          //idea here to use the factory pattern.
    
          IDepartmentDS department = (IDepartmentDS) new DataStorage();
          department.Open();
    
          List<Repositories.Department> departments = department.List();
    
          department.Close();
    
          return departments;
       }
    
    }
    

    This Business logic example is, indeed, very simple, just shows how to retrieve data from Storage layer, but as long as you have access to data, you can manipulate it in the way you want. Just a comment here: maybe this solution should be re-thinked if implemented in a very busy server with thousands of requisitions because it can use lots of memory.

    For the business logic and also UI point of view, all data are communicated between modules using general purpose containers like Lists. The link point between all those modules are the containers classes so all the classes are more less well decoupled.

    UI makes requisitions to the Business logic classes, so it acts like a service provider. Doing in that way, changing the UI will not affect the classes below to it.

    The Business logic requests and send data to the Data storage classes using general purpose data, so changing the data base / storage technology should not affect it.

    That’s the way I use to do and I’m trying to improve it 😉

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

Sidebar

Related Questions

No related questions found

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.