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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:51:17+00:00 2026-06-17T16:51:17+00:00

Even thought I think I understand Single Responsibility Principle and high/low cohesion principle, the

  • 0

Even thought I think I understand Single Responsibility Principle and high/low cohesion principle, the following questions are still causing me some confusion

1) Assume Planet and Bird properties are put arbitrarily / at random in Car class ( ie. no code within Car needs or operates on the two objects returned by these two properties ) – in other words, Planet and Bird properties don’t belong in Car class

a)

SRP states that object should have only one reason to change.

public class Car
{
    public void StartEngine()
    { ... }

    private Planet Planet
    {
        get { ... }
    }

    private Bird Bird
    {
        get { ... }
    }
}

Is Car class violating SRP? I would say it doesn’t break SRP, since any changes to Planet or Bird instances don’t propagate to the Car class?

b)

Cohesion refers to how closely related methods and class level
variables are in a class. In highly cohesive class all the methods
and class level variables are used together to accomplish a specific
task. In a class with low cohesion functions are randomly inserted
into a class and used to accomplish a variety of different tasks

Assume that even though Car class contains these two random properties, it still accomplishes just a single specific task ( or several closely related task ):

Would we say that Car has low cohesion, even though it still performs a specific task ( or several closely related tasks )?

2) Assume that Planet and Bird properties are used by methods of a Car instance to accomplish a specific task, would then Car have high cohesion, even though conceptually the two properties don’t belong to Car ( and thus it would be better if instead Planet and Bird instances were passed as arguments to a methods of a Car which operate on them )

thank you

HELTONBIKER:

1)

as you encapsulated Bird and Planet inside Car (worse yet if they are
private), so now Car class has THREE reasons to change:

I fail to see how Car has three reasons to change since in my first question Car's methods don’t even operate on the two properties and thus any changes to Planet's and Bird's public API won’t affect Car class?

2)

The problem here has two components:
1.  Bird and Planet are contained (as opposed to aggregated) in Car class;
2.  Bird and Planet are not conceptually related to Car, much less by some containment relationship.

a) This is confusing: aren’t the chances ( at least with my first question ) of Car having to be modified due to modification of Planet or Bird instances exactly the same regardless of whether Planet and Bird instances are contained or aggregated?

b) In second question methods of Car do operate on the two properties in order to perform a single specific task, so aren’t they conceptually at least somewhat related? Would you say that even in second question class has low cohesion, even though it performs only a single task ( and is using the two properties to accomplish the task )?

  • 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-17T16:51:18+00:00Added an answer on June 17, 2026 at 4:51 pm

    The car class does have low cohesion, as it refers to classes wholly dissimilar to it’s set of responsibilities. It also has a higher coupling surface, because since Planet and Bird are public, you’ve provided access to consumers to these properties, meaning that you’re now adding two more “reasons for change” to any consumer, regardless of whether or not Car uses these internally.

    At any rate, SRP has been violated if only because Car now has the responsibility of “a way to get planets or birds”, disregarding any coupling/cohesion arguments.

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

Sidebar

Related Questions

I must admin this is kind of funny even though I think I understand
I can't seem to find this information in other questions, even though I think
I think I'm failing to understand some finer point of C++. I want to
I don't even know if this is even possible, but I thought I'd ask.
I have the following very simplistic implementation for a single linked list in C:
Se original question in the bottom. I think I understand what you guys are
I have the following code: #import <Foundation/Foundation.h> #import ServerRequest.h // works even though this
I think I understand the error message: CoreData could not fulfill a fault, but
I think I understand the difference between ASCII mode and Binary mode on regular
I don't understand, why does the following regular expression: ^*$ Match the string 127.0.0.1?

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.