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

The Archive Base Latest Questions

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

I have an entity structure as follows: IManager: IDeletable { IEnumerable<IFund> Funds {get;} IFailureNotification

  • 0

I have an entity structure as follows:

IManager: IDeletable
{
IEnumerable<IFund> Funds {get;}
IFailureNotification Delete();
}

IFund : IDeletable
{
IEnumerable<IFundClass> FundClasses
IFailureNotification Delete();
}

IFundClass: IDeletable, IInvestable
{
IFailureNotification Delete();
}

And I have a service which takes an IDeletable and calls Delete on it. Depending on the return value it then either commits the transaction or rolls it back. I’m using NHibernate to persist the classes so can’t put RI in the DB and catch the exception (which I wouldn’t like anyway).

This is a classic case for polymorphism and the Manager loops through its Funds and deletes them before deleting itself, the Fund in turn delete the FundClasses before deleting themselves, so the service can just take any entity implementing IDeletable and know that the deletion will perform the appropriate actions at all levels.

Here’s the problem: The fund classes need to find if they’re being used in a completely separate context using the IInvestable interface which they don’t know anything about. This requires a service – the IInvestmentCalculationService.

Obviously I don’t want to inject the InvestmentCalculationService into the fund class entity constructor and I don’t want to inject it into the delete method as this is on Funds and Managers as well as many other classes so doesn’t make any sense – also means that as soon as we have more requirements we have to change the delete methods on everything.

I’m a bit tempted by the Domain Events model here: http://www.udidahan.com/2009/06/14/domain-events-salvation/ but I’m not confident that it’s right as I’m trying to get data back from the triggered event handler – which would work but smells a little bit wrong, and all the examples only show fire and forget situations.

Does anyone have any suggestions?

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

    Thanks to all for their help, I was really impressed by the audience I attracted! I especially liked mcintyre’s philosophy and it’s genuinely affected my thinking since. In this case though we went for double dispatch. Feels a little more stable.

    Cheers

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

Sidebar

Related Questions

I have a object structure like this: public class Entity { IList<Relationship> Relationships{get;set;} }
I have the following entity structure: public class Party { public Int32 PartyId {
How would one structure a table for an entity that can have a one
I have quite a complex entity structure where several classes inherit from a base
I have a database with the following structure: CREATE TABLE entity ( id SERIAL,
I have a very nested entity structure like this: DataObject > Universities (List) >
Let's say I have the following class structure: /** Boring bits snipped */ @Entity
I have an entity that maps to an external oracle table which is one
I have an entity class that has a property with an underlying db column
Lets say I have an entity Foo, and it contains a list of another

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.