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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:48:42+00:00 2026-06-18T07:48:42+00:00

So I have a scenario like this with classes Student and Course Student A

  • 0

So I have a scenario like this with classes Student and Course

Student A is enrolled in Course 1, 2

Student B is enrolled in Course 1, 2, 3

Student C is enrolled in Course 2

So there are two kinds of events:

Student A is deleted -> need to notify two objects: Course 1 and Course 2

Course 1 is canceled -> need to notify two objects: Student A and Student B

I know that the Observer pattern can work if each Student can be only enrolled in 1 Course, in which case I have a list of Student for each Course object in the Observer Pattern.

I am wondering if I should do some two way Observer Pattern (Student keeps a list of Courses and the Course also keeps a list of students). So would be a good way to deal with this problem? Main concern is speed/space tradeoff (what I can think of at best now is a two way hash/tree from 1 Student to 1 set of Courses and 1 Course to 1 set of Students). Any pointer will be appreciated!!

  • 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-06-18T07:48:43+00:00Added an answer on June 18, 2026 at 7:48 am

    What you are really asking about is cascade semantics in a domain model. For instance, if a Course is deleted, should the students be deleted? Of course not. If a Student is deleted, should the Course be deleted? No.

    I think what you might want to consider is another class: Enrollment. That says Student A enrolled in Course X on Date Y. Then if a course is Canceled, you cascade delete the Enrollments and then when you go to that Student to see what he’s enrolled in, you don’t see that Course anymore.

    The additional benefit of this strategy is that if you want to retain the information (that he was enrolled and the Course was cancelled), that is there in the Enrollment class (which is an Association class).

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

Sidebar

Related Questions

I have a scenario like this: I need to pass @id to the stored
Say I have two classes like this: class A{ private static Random random =
I'm confused with the following scenario, we have a set of classes like this
I have a pair of classes that look something like this. There's a Generator
I have a scenario like this: form = MockRepository.GenerateMock<IAddAddressForm>(); mediator = new AddAddressMediator(form); The
I have a scenario that looks like this: #include <algorithm> using namespace std; //
If I have a simple cucumber feature and scenario , like this (example code
In a multithreaded scenario, I have a method like this: bool WaitForChange( time_duration WaitTime
I have this scenario where I would like to redirect my domains using the
I have one scenario where I need to select all files having aliencoders.numeric-digits like

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.