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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:21:20+00:00 2026-05-30T02:21:20+00:00

Introduction Let’s say I have three Domain Objects: Proposition Phase Task A Proposition can

  • 0

Introduction

Let’s say I have three Domain Objects:

Proposition
Phase
Task

A Proposition can have one or more Phases. A Phases can have one or more Tasks.

If I completed the last Task in the last Phase, the Proposition must be set to ‘Closed’.

In code I’ve created something like this to complete the last Task of a Phase

//My Business Layer does this:
--------------------------------------
pseudo:
var phase = _phaseRepository.GetById(id);
phase.LastTask.SetComplete();


// My Domain Entities look like this:
------------------------
public class phase()
{
   public Task LastTask { get; set; } // not real code of course
}

public class Task()
{
   public Phase Phase { get; set; }

   public void SetComplete()
   {
      Phase.IsFinished = true;
   }
}

Question

Where do I put the code to set the Proposition to ‘Closed’?

Options

I think have a few options:

1) In the Domain Entity: Task.SetComplete

public class Task()
{
   public Phase Phase { get; set; }

   public void SetComplete()
   {
      Phase.IsFinished = true;
      Phase.Proposition.IsClosed = true;
   }
}

2a) In the Business Layer

var phase = _phaseRepository.GetById(id);
phase.LastTask.SetComplete();

var proposition = _propositionRepository.GetById(phase.PropositionId);
proposition.IsClosed = true;

2b) In the Business Layer, maybe a bit nicer way:

var phase = _phaseRepository.GetByIdIncludingProposition(id);
phase.LastTask.SetComplete();
phase.proposition.SetClosed();

3) Let everything pass thru Proposition:

//My Business Layer:
var proposition = _propositionRepository.GetById(id);
proposition.CompleteTask(taskId);

// Domain Object:
public class Proposition()
{
   public List<Phase> Phases { get; set; }

   public void CompleteTask(long taskId)
   {
      var task = // psuedo: select relevant task from Phases.Tasks, using taskid
      task.SetComplete();
      task.Phase.SetFinished();

      //psuedo: if task.Phase is last phase in proposition
      Phase.Proposition.IsClosed = true;
   }
}

About the options

Option 1 is problematic on the line

Phase.Proposition.IsClosed = true;

because Proposition doesn’t have to be loaded, and if it’s not loaded we get an exception.

Option 2a is problematic because after phase.LastTask.SetComplete() is executed the proposition is not in the correct state. And everywhere in code where one has access to Phase, “phase.LastTask.SetComplete()” can be executed without doing the relevant operations on Proposition.

Option 2b has the same problem as 2a.

Option 3 gives the Proposition class too much responsibilities.

Do you guys 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-30T02:21:22+00:00Added an answer on May 30, 2026 at 2:21 am

    I’m guessing that Proposition is the aggregate root.A task is part of a proposition in the end and I think that the Tssk should notify that is completed i’d try this approach (basically option 3 a bit modified)

    public class Proposition()
    {
      public Task GetTask(int taskId)
      {
          //find and return task
      } 
    }
    
    //in business layer 
    var p= _repository.GetProposition(id);
    p.GetTask(taskId).SetComplete();
    
    public class Task
    {
      public event Action<Task> Completed;       
    
    
       public void SetComplete()
       {
            if (Completed!=null) Completed(this);
        }
    

    The Phase should handle the completed event of Task and when it is triggerd, chek if it’s the last task and notify the proporisiton to closeitself. NOw maybe using events is not the best implemetnation, probably the Observer pattern is better, but the main ideas are:

    • You get a task via a Proposition method (as Proposition is an AR)
    • Tasks notifies phase when it’s finished
    • Phase notifies proposition when the last task is completed
    • Proposition should check if there aren’t any phases in progress and close itself.
    • save Proposition in the repository

    Come to think of it, this is basically the domain event pattern.

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

Sidebar

Related Questions

Let's start from simple introduction. For better understanding my problem I have drastically simplifield
Let's say I have written a Class Library (dll) in .Net and now I
Introduction : I have this path in my CakePHP : app/webroot/storage/5/C/_demo/omar.txt , this one
Introduction In my current organisation, we have many desktop and web applications all feeding
Introduction I have been so annoyed by applications that have a startup dialog which
Introduction We have an OpenID Provider which we created using the DotNetOpenAuth component. Everything
every introduction and sample that I can find seems to use GLUT or some
Introduction I have a ListView and want to format only the second column. The
(If someone needs more information, or a better description let me know) Hello i
First, a little introduction. I have to functions: static class C { static void

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.