IntelliJ Java IDE
The moose likes OO, Patterns, UML and Refactoring and the fly likes Encapsulation,Connascence and Contranascence Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Reply Bookmark "Encapsulation,Connascence and Contranascence" Watch "Encapsulation,Connascence and Contranascence" New topic
Author

Encapsulation,Connascence and Contranascence

Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Let's discuss the difference between the above three OO properties.
-- Sandeep
[This message has been edited by Desai Sandeep (edited July 05, 2001).]


<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
Junilu Lacar
Ranch Hand

Joined: Feb 26, 2001
Posts: 3008
Desai,
I have not encountered the terms "connascence" and "contranascense". What do they mean in the context of OO?

Junilu
[How to Ask Questions] [How to Answer Questions] [MiH]
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Junilu,
I am also looking for some more OO description on "Connascence" and "Contranascence".
This is what I know :
Connascence
It means "having born together" or "having interwined destinies in life".Two software elements that are connascent are born from some related need - perhaps during requirement analysis,design or programming - and share the same fate for one reason.
Connascence between two software elements A and B means either

  1. that you can postulate some change to A that would require B to be changed (or atleast carefully checked) in order to preserve overall correctness,or
  2. that you could postulate some change that would require both A and B to be changed together in order to preserve overall correctness.

  3. An non-OO example of Connascence
    Assume the software element A to be a single line of traditional code :
    <pre>
    int i ; // line A
    </pre>

    and element B to be the assignment:
    <pre>
    i := 7; // line B
    </pre>

    There are atleast two examples of connascence between A and B:

    1. Consider an unlikely situation, when A is changed to "char i;", then B also has to be changed too.This is connascence of type
    2. If A was changed to "int j", then B should be changed to "j := 7;".This is connascence of name


    3. An OO example of Connascence
      <pre>
      We need to work on this!
      </pre>

      Contranascence
      With our above discussions, we have equated connascence with "sameness" or "relatedness".For example, the two lines of code have connascence of name when the variable in each of them bear the same name.
      However Connascence also exists in cases where differences are important.Connasence of difference is called Contranascence
      An non-OO example of Contranascence
      Consider the following two declarations
      <pre>
      int i; // line A
      int j; // line B
      </pre>

      For correctness,i.e.for code to compile - the variable names must differ from each other.There's Connascence at work here.If, for some reason we change the first variable to "j", then we would also need to change the second name from "j" to something else.Thus, two declarations are not independent.
      Hence, in Contranascence, which is a form of Connascence, we see to it that difference instead of equality is preserved.
      An OO example of Contranascence
      This crops up in OO environments with multiple inheritance.If class C inherits from both classes A and B, then the features of A and B should not have the same names : There is contranascence of name between A's features and B's features.
      One of the reasons why Multiple inheritance is not allowed in Java could be to maintain Contranascence of name across all classes because of the risk of name clashes under it.
      We need some more concrete examples to digest these OO terminologies.
      -- Sandeep
      [This message has been edited by Desai Sandeep (edited July 06, 2001).]
Junilu Lacar
Ranch Hand

Joined: Feb 26, 2001
Posts: 3008
IOW, they are about existence or non-existence of dependencies between parts of your application
Jyotsna Clarkin
Ranch Hand

Joined: Jan 26, 2001
Posts: 158
Originally posted by JUNILU LACAR:
Desai,
I have not encountered the terms "connascence" and "contranascense". What do they mean in the context of OO?

Neither had I - did a search the other day after reading Sandeep's post and found links to
Fundamentals of Object-Oriented Design in UML by Meilir Page-Jones. http://cseng.aw.com/book/toc/0,3830,020169946X,00.html
I don't have a access to a copy. Did the author coin these terms?
Anyhow Sandeep's explanation is the first definition I have come across (Thanks). Not sure if I understood it all.
Would like some examples.
regards,
Jyotsna

[This message has been edited by Jyotsna Clarkin (edited July 06, 2001).]
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Jyotsna,
Yes, these terms are there in Meilir Page-Jones book.Infact, the description is not at all sufficient.That is the reason,I posted this question in the first place.
We have always talked about encapsulation and a number of patterns that support it.What about Connascence and Contranascence?Are there any patterns for it?
As of now, as Junilu said, we can think about it as dependencies.My 2 cents...I have a feeling that it would come into picture when we trying to minimize the dependencies between software components/packages.Your views please!
After we have done some research on these terminologies, I will "bombard" you with some more OO terminologies which are not used very often.May be they are useful; may be they are not!But in any case we should atleast know about it.
-- Sandeep
Jyotsna Clarkin
Ranch Hand

Joined: Jan 26, 2001
Posts: 158
Originally posted by Desai Sandeep:

Yes, these terms are there in Meilir Page-Jones book.Infact, the description is not at all sufficient.That is the reason,I posted this question in the first place.
-- Sandeep

Sandeep-
I don't have much to ad to the discussion yet but I did find another reference to a Page-Jones' paper.

Page-Jones, M.: Comparing Techniques by Means of Encapsulation & Connascene, Communications of the ACM Vol. 35, No. 9, Sept. 1992 pp. 147-151.
A brief report for all philosophers of object-oriented programming � including a clean example to illustrate the connascene of polymorphism. Connascene includes the metrics coupling, cohesion, and more.

I would really like to read this, especially the "clean example".
Comm. of the ACM is available on-line (NOT free) to members. I am not one
http://www.acm.org/pubs/contents/journals/cacm/1992-35/#9
I'll have to check the library...
Like I said I don't have much to say now - a bit shaky in OO. I have Larman & am gathering material- a case study to initiate a discussion here. Maybe some people will join in the discussion.
But I'd say you're way ahead of me. I'll be doing some intense studying to catch up
regards,
Jyotsna
 
IntelliJ Java IDE
 
subject: Encapsulation,Connascence and Contranascence
 
Threads others viewed
Anyone that has _passed_ the IBM test?
Open Source Projects
WA #1.....word association
new to uml
Cost of 486
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture