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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:55:59+00:00 2026-05-22T21:55:59+00:00

very simple problem, but i want to see how experts look at it. This

  • 0

very simple problem, but i want to see how experts look at it.

This is just imaginary software just to understand OOP.
I have a school administration software. So I have classes

  • Student
  • ClassRoom
  • Teacher

Now I assign a teacher as class-teacher for a particular classroom. Thus
ClassRoom contains

Teacher classTeacher; 
Student[] students; 

Now the complete program is written and everything works fine …

Problem:

Now what If the principal puts a new rule, that there should not exist a student to whom the Teacher is the Parent.
Now we need to bring more parameters and lot of changes in our code for a small requirement.
How should the design be in order for future changes in requirements (which will inevitably come) to only require minor changes in the code?

  • 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-22T21:55:59+00:00Added an answer on May 22, 2026 at 9:55 pm

    This should not be a big code change, this should be a validation change.

    Psuedo-Code:

    Class ClassRoom {
        List<Student> students
        Teacher teacher
    
        ClassRoom(Teacher _teacher, List<Student> students) {
            teacher = _teacher;
            SetStudents(students);
        }
    
        void SetStudents(List<Student> _students) {
             foreach (Student s in _students) {
                 if (validate(s)) {
                     students.add(s);
                 } else {
                     // error handling logic
                 }
             }
        }
    
        void validate(Student student) {
            if (student.parent == teacher) {
                return false;
            }
            return true;
        }
    }
    
    class Student : Person {
        Person parent
    }
    
    class Teacher : Person { }
    

    Sure you are going to have to go into the database and the codebase and add “Parent” properties to all your students. But that also shouldn’t be too hard.

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

Sidebar

Related Questions

I have a very simple problem but cannot find a nice solution. I have
I have a very simple problem, but I can't seem to solve it. I
This is a very simple code in place of a bigger problem, but I'm
This may sound simple but i am stuck up at a very strange problem.
Probably a very simple problem and I have been looking for the answer but
So, I essentially have what I want already, very simple, but there are some
My problem is very simple but I don't really know its name and therefore,
The problem is simple, but I'm looking for a creative solution. We meet very
I have a very simple problem. I have a data frame with multiple rows
I have a very simple C# DataTable problem that I cannot seem to wrap

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.