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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:01:23+00:00 2026-05-15T23:01:23+00:00

In employing Domain Driven design I often encounter an issue regarding the various perspective

  • 0

In employing Domain Driven design I often encounter an issue regarding the various perspective on a domain object, especially when using NHibernate. Perspectives are essentially ways to view an domain object. For example, a simplified model:

class Transaction
{
  string Id { get; set; }
  string CustomerName { get; set; }
  DateTime Date { get; set; }
  decimal Amount { get; set; }
  decimal Tax { get; set; }
}

class Batch
{
    string Account { get; set; }
    string Number { get; set; }
    DateTime? ClearDate { get; set; }
    IList<Transaction> Transactions { get; }
    decimal Total { get; }
}

The total property on the batch is the sum of the amounts on each transaction. When considering a single batch this model works well and is a proper representation of the domain. The client application however has a screen which displays collections of batches. That screen does not require any details about the transactions within a batch, only the total amount. Utilizing the same object on the listing screen is slow. One option is to make the Total property be settable, another option is to create a new class, such as:

class BatchOverview
{
    string Number { get; set; }
    decimal Total { get; set; }
}

This would have its own repository and its own NHibernate mapping to a database view.

  1. Does this object belong to the domain model, or is it more application/GUI specific?
  2. Should the batch overview object reference the batch object?
  3. Is this a common pattern?
  4. Is there any guidance in relation to this issue?

DDD has the concept of bounded contexts, however in this case the context is the same. Both the Batch class and the BatchOverview class refer to the same ‘actual’ batch – they are different views, or perspectives on it.

  • 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-15T23:01:23+00:00Added an answer on May 15, 2026 at 11:01 pm

    I would keep the new class out of the domain – it is a presentation concern in my book, and i would treat it as such. Normally this new object would be read-only so as not to having two ways of altering data (and one of them not having the full set of business logic contained).

    However, you don’t have to make a setter for the value just because you use nHibernate. Just make it use a backing field and let nHibernate write to that. (use access=”field” in your mapping).

    EDIT:
    I call it a PresentationModel or ViewModel depending on the amount of logic inside.

    I would probably keep a reference to the original object – but might only be an Id.

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

Sidebar

Related Questions

I'm performing streaming reads of an object using BufferedReader. I need to do two
When employing custom attributes to store meta-data, is it best to decorate the interface,
The domain of this question is scheduling operations on constrained hardware. The resolution of
I am employing ThreadPool.QueueUserWorkItem to play some sound files and not hanging up the
I'm employing a custom webpart that is made by an unaffiliated third party. I've
I'm dealing with a design problem that I'm sure has a simple answer and/or
I'm doing some R&D work, and as such am exploring design patterns. I have
Suppose you have an interface like this: public interface IDoSomething<out T> { T DoSomething(object
I'm exploring wxWidgets and at the same time learning C/C++. Often wxWidgets functions expect
I want to work around email addresses and I want to explode them using

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.