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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:30:01+00:00 2026-05-16T22:30:01+00:00

I was reading Robert Martin’s Clean Code and in that he mentions about the

  • 0

I was reading Robert Martin’s Clean Code and in that he mentions about the code being highly cohesive:

Classes should have a small number of
instance variables. Each of the
methods of a class should manipulate
one or more of those variables. In
general the more variable a method
manipulates the more cohesive that
method is to its class. A class in
which each variable is used by each
method is maximally cohesivemethod is maximally cohesive

But when we are trying to write concurrent code, we strive to limit the scope of variables to a single method to avoid race conditions. But this results in code which is least cohesive.

When designing an application/class, what should you prefer – Cohesion or Concurrency?

  • 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-16T22:30:01+00:00Added an answer on May 16, 2026 at 10:30 pm

    I like quite a few of Martin’s concepts, but your code needs to execute correctly and if it doesn’t, all the beautiful metrics in the world aren’t going to make you look better.

    Add to that that threading issues are among the worst there are to debug, and you should not compromise your design for concurrency to conform with your idea of what someone wrote in a book about cohesion. Again, I’m not knocking Martin… I’m sure he’d tell you the same thing. After all, he recognizes that almost everything is on a continuum in most of his writing.

    I’m not sure you’re putting the emphasis in quite the right place though (could just be the way I’m reading your question). Martin’s not saying you should make as many variables live at the class level as possible. He’s saying that of the class level variables, how many are you using? If you promote variables you don’t need to, you might not be getting higher cohesiveness… you might be getting tighter coupling.

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

Sidebar

Related Questions

Reading this question I found this as (note the quotation marks) code to solve
Reading MSDN (and other sources) about custom report items (CRI) for reporting services 2005.
Reading source code of sample projects, such as Beast and Bort, are recommended as
I am reading the Foundations of F# by Robert pickering. When I try to
After reading another question about the use of macros, I wondered: What are they
I have an xml document like this, <Customer ID = 000A551 Name = Robert
Reading an article called Increase LINQ Query Performance in July's MSDN magazine, the author
Reading over the responses to this question Disadvantages of Test Driven Development? I got
Reading through the Flickr API documentation it keeps stating I require an API key
Reading on another forum I've came across the world of CSS Frameworks. The one

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.