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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:27:01+00:00 2026-05-22T18:27:01+00:00

I am trying to figure out how to setup a clean architecture for my

  • 0

I am trying to figure out how to setup a clean architecture for my shopping cart without over architecting it or ending up with a anemic domain model. Right now I just want to use standard ADO database logic without any ORM framework. (I am also learning EF4.1, but not good enough yet to use in production)

Ideally I would just have a POCO for each Business object/entity and a repository/data class that will handle persistence. To keep things simple, I am thinking to tightly couple the POCOs to the data layer and it will return POCOs. If I add DTO to the mix as well, then I end up having 5-6 class files for each area (gc, order, items, payments, etc) which just seems like too much for a simple app. I can always refine later.

The first class I am working on is for gift certificates. One of the methods is to create a new GC. In this method I will need to query the database to ensure the new code does not already exist in the system. Is it ok to just call the data layer/repo inside this method?

Should the data layer/repo be static? Should I only expose it through the POCO itself?

Should I drop the data layer altogether and just have the data calls directly in my POCOs (active record style)?

I need a simple architecture which will allow me some separation of concerns without over complicating things. The database provider and table structures will not change for at least the next few years.

Here is some code.. just need to figure out where the parts go.

public GiftCertificateModel
{
    public int GiftCerticiateId {get;set;}
    public string Code {get;set;}
    public decimal Amount {get;set;}
    public DateTime ExpirationDate {get;set;}

    public void Redeem(string code, decimal amount)
    {
        //need to validate the input
        //need to insert a record to the transaction log table (call the repo or does this entire method need to be in the repo?)
    }

    public void GetNewCode()
    {
        //need to create random alpha num code
        //need to make sure the code is unique in the db... (again, (call the repo or does this entire method need to be in the repo?
    }

}




public GiftCertificateRepo : DALBase (DALBase has methods for connecting, etc)
{

    //mapping code here to map SQLDataReader values to GiftCertificateModel properties
    //i can also setup separate DTOs if it makes more sense...

    //should the repo be static?
    public static GiftCertificateModel GetById(int GiftCertificateId)
    {
        //call db to get one and return single model

    }

    public static bool IsUnique(string code)
    {
        //call db to see if any records exists for code

    }

    public static List<GiftCertificateModel> GetMany()
    {
        //call db to get many and return list

    }

    public static void Save(GiftCertificateModel gc)
    {
        //call db to save

    }
}

Calling code:

GiftCertificateModel gc = new GiftCertificateModel();
gc.Code = gc.GetNewCode(); //do i call the is unique here or in the GetNewCode method?
gc.Amount = 10;
gc.ExpirationDate = "1/1/2012";
GiftCertificateRepo.Save(gc);
  • 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-22T18:27:02+00:00Added an answer on May 22, 2026 at 6:27 pm

    By keeping the POCOs (representations of data) separate from the repository objects (representations of how data gets stored/retrieved) you will be able to much more easily switch from ADO to a more advanced ORM system in the future – those code changes will be isolated to one place.

    Better yet, define an IRepository interface and have your ADO repostiory class implement it. Then, your app should work only with IRepository thus making it even easier to test or switch repository implementations in the future.

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

Sidebar

Related Questions

I am trying to figure out what is going on. Here is our setup:
I'm trying to setup python fabric for postgresql, but can't figure out how to
I am new to iPhone development trying to figure out how to setup a
I'm trying to figure out the best practice to setup hierarchy data that i
I'm trying to figure out the best way to setup some tables in my
I have a slightly nasty setup which I am trying to figure out a
I'm trying to figure out how to setup CarrierWave to work with Fog and
I am trying to figure out how I would setup a group of images
I'm working in a quite uncomfortable setup and I'm trying to figure out how
I am trying to figure out how to setup android development with Visual Studio.

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.