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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:11:15+00:00 2026-05-31T08:11:15+00:00

I’m trying to write reusable components for my most common dev scenarios: I have

  • 0

I’m trying to write reusable components for my most common dev scenarios:

I have made a general purpose presentation-layer to present domain-objects and data-objects (dc-serializable) to be encapsulated in the domain-objects. I also have some kind of domainstate/context where I keep all my domainobject-instances referenced. The idea is that the domain-objects have special collections that get populated from the datasource when they are first accessed, on-demand. It’s not exactly “DDD” I think but it seem to work…

Anyway, now I’m stuck on the datacontext and datasource-part. I’ve been thinking a lot on how to store data and interact with the datasource; xml in zip-files, sql-server, sql-lite-files, entity framework, nhibernate, linqtosql, mongodb etc and I can’t decide what to use. It appears I need to abstract away both the datasource and the datacontext and instead decide what to use in each application. The important thing is that I don’t embed any hard dependencies on specific frameworks.

Is it realistic to abstract away the datacontext and datasource and still have it work well and easy with all kinds of existing frameworks out there? Am I thinking about this wrong? Is this a dead end?

All I want and need (I think) is my domainstate to be able to query the datacontext for objects matching certain criterias. I’m not sure if it should be able to work with entire object graphs or only individual data-objects, or not even concrete types but some generic objects only, or if they should be cloned for each request or not. I feel very confused when I start thinking about this…

Gahhh

Update:

I see a DataContext/DatabaseContext (for instance EntityFramework) as a module/layer to keep objects cached in memory, execute queries, fetch and store data from/to whatever datasource and return typed objects to the consumer. Is this right?

Whats the difference of the Repository-pattern (DDD) and my DataContext?

Update 2:

Basically, this is my model (good or bad?):

DataSource->DataContext/DataObject->DomainState/DomainObject->Presenter

  • 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-31T08:11:16+00:00Added an answer on May 31, 2026 at 8:11 am

    It appears I need to abstract away both the datasource and the datacontext and instead decide what to use in each application. The important thing is that I don’t embed any hard dependencies on specific frameworks

    That’s the Repository pattern right there.

    Whats the difference of the Repository-pattern (DDD) and my DataContext?

    The repository is a way to abstract everything related to storage access. It’s designed to serve the app needs and it receives/sends back objects known by the rest of the app. The DataContext is an implementation detail of EF which itself is an implementation detail of the repository.

    The repository has double purpose

    1. to allow you to change how you store data (change db, use xml files etc), by exposing only an interface.

    2. It frees you from the ‘tiranny’ of the db centric approach and let’s you focus on the domain. This is very important, because every time you start to design an app with the db schema first, you inevitably try to fit the rest of the app in it and you’ll have an anemic domain mimicking the database schema.

    DataSource->DataContext/DataObject->DomainState/DomainObject->Presenter

    In any app you basically have queries (reads) and updates (writes). In 99%, the Domain applies only to writes as the reads have no business rules (no behaviour), you just have to select the relevant data to display.

    So for writes I’d suggest this flow

    ViewModel (input)->Domain Processing (Entities, Services etc)-> Domain Repository

    You can get from the view model to the domain entity in many ways depending on the app. If the Domain is very simple, you pretty much won’t need a domain, the view model will be the domain which in many cases will be the same as the db schema.

    For reads

    Query Repository -> ViewModel (Presenter)

    Of course the controller usually calls the query repository and it might assemble the desired view model from the data recevied from the repo (in simple cases the repo returns exactly the view model).

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

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.