Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Am I setting up my architecture correctly?

Am I setting up my architecture correctly?

Scheduled Pinned Locked Moved C#
csharpdatabasebusinessarchitecturehelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xdavidx
    wrote on last edited by
    #1

    Im a begining C# programmer and was hoping you guys could help me. Im working on my first real project and I am a little confused on how exactly to set it up. I've read so many articles on this, but they all seem to be saying different things. Here is a psuedo code example of my current setup: //Data Access Layer class EmployeeDA { public void Insert(Employee emp) { //code to add employee to db } //similar methods for Load, Delete, Update, etc } //Business Logic Layer class Employee { private int id; private string name; private EmployeeDA = new EmployeeDA(); //here would be the code for the properties and constructors public void Insert() { EmployeeDA.Insert(this); } //similar methods for Load, Delete, Update, etc } class Employees : List { public void AddEmployeesToTable() { foreach(Employee emp in this) emp.Insert; } //similar methods for Load, Delete, Update, etc } Is this correct? I know there are many different ways to do it, so maybe "correct" isnt the right word. I guess what I want to know is if there is a "better" way of doing it. Are there any glaring issues with the way I am doing it currently? Thanks

    C B 2 Replies Last reply
    0
    • X xdavidx

      Im a begining C# programmer and was hoping you guys could help me. Im working on my first real project and I am a little confused on how exactly to set it up. I've read so many articles on this, but they all seem to be saying different things. Here is a psuedo code example of my current setup: //Data Access Layer class EmployeeDA { public void Insert(Employee emp) { //code to add employee to db } //similar methods for Load, Delete, Update, etc } //Business Logic Layer class Employee { private int id; private string name; private EmployeeDA = new EmployeeDA(); //here would be the code for the properties and constructors public void Insert() { EmployeeDA.Insert(this); } //similar methods for Load, Delete, Update, etc } class Employees : List { public void AddEmployeesToTable() { foreach(Employee emp in this) emp.Insert; } //similar methods for Load, Delete, Update, etc } Is this correct? I know there are many different ways to do it, so maybe "correct" isnt the right word. I guess what I want to know is if there is a "better" way of doing it. Are there any glaring issues with the way I am doing it currently? Thanks

      C Offline
      C Offline
      CooperWu
      wrote on last edited by
      #2

      I think the architecture must depend on the project design. If your project is not a complicated one, may be two layers would be a better one. I mean 'the data layer' and 'the business layer'.

      1 Reply Last reply
      0
      • X xdavidx

        Im a begining C# programmer and was hoping you guys could help me. Im working on my first real project and I am a little confused on how exactly to set it up. I've read so many articles on this, but they all seem to be saying different things. Here is a psuedo code example of my current setup: //Data Access Layer class EmployeeDA { public void Insert(Employee emp) { //code to add employee to db } //similar methods for Load, Delete, Update, etc } //Business Logic Layer class Employee { private int id; private string name; private EmployeeDA = new EmployeeDA(); //here would be the code for the properties and constructors public void Insert() { EmployeeDA.Insert(this); } //similar methods for Load, Delete, Update, etc } class Employees : List { public void AddEmployeesToTable() { foreach(Employee emp in this) emp.Insert; } //similar methods for Load, Delete, Update, etc } Is this correct? I know there are many different ways to do it, so maybe "correct" isnt the right word. I guess what I want to know is if there is a "better" way of doing it. Are there any glaring issues with the way I am doing it currently? Thanks

        B Offline
        B Offline
        beatles1692
        wrote on last edited by
        #3

        Hi As you mentioned there is no correct architecture.When you are designing a solution you should consider the domain of the problem that you are solving. There are lots of patterns that you can choose from ( for example Data Access Objects and Active record) If you are working on a small project ( and you don't expect it to become a large application in future) you can mix up the Data Access and the business layer or if you prefer you can have both in your project (It's not very hard to split them afterwards) Be careful not to mix up your user interface layer with your business layer since it's very hard to refactor them afterwards. Take a look at Martin Fowler's articles at his site (www.matinfowler.com) and specially take a look at his Enterprise patterns. Good Luck

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups