Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

High Cohesion and Low Coupling in C++

9 views
Skip to first unread message

Pallav singh

unread,
Jun 1, 2009, 1:25:35 AM6/1/09
to
Q How to get High Cohesion and Low Coupling, while designing in C++ ?

nick_keigh...@hotmail.com

unread,
Jun 1, 2009, 4:49:15 AM6/1/09
to
On 1 June, 06:25, Pallav singh <singh.pal...@gmail.com> wrote:

> Q How to get High Cohesion and Low Coupling, while designing  in C++ ?

use OO. Refactor mercilessly. Read Constantine and Yourdon.

Alf P. Steinbach

unread,
Jun 1, 2009, 4:49:05 AM6/1/09
to
* Pallav singh:

> Q How to get High Cohesion and Low Coupling, while designing in C++ ?

Be intelligent.

Cheers & hth.,

- Alf

--
Due to hosting requirements I need visits to <url: http://alfps.izfree.com/>.
No ads, and there is some C++ stuff! :-) Just going there is good. Linking
to it is even better! Thanks in advance!

alasha...@gmail.com

unread,
Jun 1, 2009, 5:00:31 AM6/1/09
to
On Jun 1, 7:25 am, Pallav singh <singh.pal...@gmail.com> wrote:
> Q How to get High Cohesion and Low Coupling, while designing  in C++ ?

Hello,

I believe a complete reply to the above question would require a small
essay. I think therefore that it would be more appropriate for you to
go through some reference material, and then, if needed,ask specific
questions - such as: 'how to reduce local coupling - when one module
modifies or relies on the internal workings of another module'.

http://en.wikipedia.org/wiki/Coupling_(computer_science)
http://en.wikipedia.org/wiki/Cohesion_(computer_science)
http://www.aui.ma/personal/~H.Kabaili/Publications/csmr-2001.pdf

Regards.
A.S.

Phlip

unread,
Jun 1, 2009, 8:56:45 AM6/1/09
to

Note that "refactor" means to run all unit tests between each tiny change. Any
other definition for it is just "churn" or "rework".

Phlip

unread,
Jun 1, 2009, 8:56:02 AM6/1/09
to
Alf P. Steinbach wrote:
> * Pallav singh:
>> Q How to get High Cohesion and Low Coupling, while designing in C++ ?
>
> Be intelligent.

Or just use Test Driven Development. Tests work better when their targets are
easy to set-up. They make decoupling more convenient.

Phlip

unread,
Jun 1, 2009, 8:59:02 AM6/1/09
to
alasha...@gmail.com wrote:

> http://en.wikipedia.org/wiki/Coupling_(computer_science)

Does it say "coupling means to change A you must also change B"?

> http://en.wikipedia.org/wiki/Cohesion_(computer_science)

Does it say "A and B share legitimate reasons to change, together"?

Defining those words in terms of change makes their definitions simple and
obvious, but WikiPedia probably cites sources who just go the long route...

alasha...@gmail.com

unread,
Jun 1, 2009, 9:36:37 AM6/1/09
to
On Jun 1, 2:59 pm, Phlip <phlip2...@gmail.com> wrote:
> >http://en.wikipedia.org/wiki/Coupling_(computer_science)
>
> Does it say "coupling means to change A you must also change B"?

Yes, four lines below the main title.

> >http://en.wikipedia.org/wiki/Cohesion_(computer_science)
>
> Does it say "A and B share legitimate reasons to change, together"?

Actually no. It is more concerned with responsibilities of a single
module of code, I believe along the line that 'each module should do
one main thing and do it well'.

> Defining those words in terms of change makes their definitions simple and
> obvious, but WikiPedia probably cites sources who just go the long route...

Who knows? The OP could be a student studying the theory or a
practitioner looking for best practice, but you may be right.

Regards,
A.S.

Phlip

unread,
Jun 1, 2009, 10:00:20 AM6/1/09
to
alasha...@gmail.com wrote:

>>> http://en.wikipedia.org/wiki/Coupling_(computer_science)
>> Does it say "coupling means to change A you must also change B"?
>
> Yes, four lines below the main title.

Confucius say, when you go to flame WikiPedia, first dig two graves. (-:

>>> http://en.wikipedia.org/wiki/Cohesion_(computer_science)
>> Does it say "A and B share legitimate reasons to change, together"?
>
> Actually no. It is more concerned with responsibilities of a single
> module of code, I believe along the line that 'each module should do
> one main thing and do it well'.

I didn't say A and B were different modules. Yet the Single Responsibility
Principle is indeed more specific than "cohere"...

Jorgen Grahn

unread,
Jun 14, 2009, 10:58:56 AM6/14/09
to
On Sun, 31 May 2009 22:25:35 -0700 (PDT), Pallav singh <singh....@gmail.com> wrote:
> Q How to get High Cohesion and Low Coupling, while designing in C++ ?

When you have found out how, also consider if you *need* them in the
specific case. In my opinion, C++ programmers (at least in the past)
have spent too much effort in this area.

/Jorgen

--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.se> R'lyeh wgah'nagl fhtagn!

0 new messages