Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

realization relationship

 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I was going through UML Distilled by Fowler and was not being able to properly interpret the realization relationship he was talking about. The following is what Fowler said in the book -
"Realization is deliberately similar to generalization; it indicates that one class implements behaviour specified by another. It is permissible for one implementation class to realize another; this means that the realizing class must conform to the interface, but need not use inheritance"

This is what i understand from his explanation, in my own words -
" A class can subclass an abstract class and thereby realize that it is implementing a particular interface, eventhough it is not in inheritance with the interface( not like -- for example classA implements interfaceXX)". Is this interpretation correct? Please correct for any mistakes. Where is this kind of realization useful?
Thanks,
Jayadev.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my understanding:
- Generalization/Specialization: class conforms to the same interface and inherits implementation from the superclass
- Realization: class conforms to the interface as defined by the realized Interface, it doesn't inherit any implementation
Therefore in Java "extends" would mean Specialization for classes, Realization for interfaces; "implements" would always mean Realization.
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was very clear explanation. Thanks.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jayadev Pulaparty:
That was very clear explanation.

Hopefully it was also correct...
Thanks.

You're welcome!
 
Vikrama Sanjeeva
Ranch Hand
Posts: 760
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Originally posted by Ilja Preuss:
.. Realization for interfaces; "implements" would always mean Realization.

Yups! Put another way, Realizing an interface means confirming an agreement!
Interface is a contract between interface designer and interface implementor. By implementing an interface means implementor is realizing the rules of contract. I believe there is another good word in place of rule, which is not coming in my mind right now.
Bye,
Viki.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic