• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Realization and Generalization in Java / Object Oriented Programming

 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have found these two definitions of online:

Realization : means Implementing an Interface.
Generalization : means Extending a Class

which means Realization is not Extending an Abstract class, and extending an abstract class is Generalization

and it is written that these concepts are basically used in UML, as i have not studied this Language
still i wanted to know that:
does it really not used in JAVA

We are using these two daily or may be i am unable to understand term properly

Please explain terms in context with Java, thank you
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Those two words are not really common words that Java developers use, as far as I know. At least, I've never heard people calling implementing an interface "realization", and extending a class is really the opposite of generalization; a subclass is a specialized version of its superclass, not a generalized one.
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:Those two words are not really common words that Java developers use, as far as I know. At least, I've never heard people calling implementing an interface "realization", and extending a class is really the opposite of generalization; a subclass is a specialized version of its superclass, not a generalized one.



Specialized means specific to Super class right?

Yupz, i found that Specialization means creating new subclasses from an existing class.

but i also read

Generalization is the process of extracting shared characteristics from two or more classes,
and combining them into a generalized superclass <------- Don't we use this in JAVA ?


 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Azrael Noor wrote:
but i also read

Generalization is the process of extracting shared characteristics from two or more classes,
and combining them into a generalized superclass <------- Don't we use this in JAVA ?



Let's understand with examples.

My name is Gaurangkumar Khalasi (Firstname Lastname).

So, for my fullname:

"Khalasi" is a Generalization for me and others having this surname.
and
"Gaurangkumar Khalasi" is specialization i.e. specialized version of "Khalasi".

In the same way, for Java both concepts are used.
For example,
Car IS-A Vehicle --> Specialization --> class Car extends Vehicle
But if you think above case in reverse, i.e. "Vehicle" is a Generalization for Car,Scooter,Bicycle,etc... than it is a Generalization.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would agree with Jesper and say not to use realisation or generalisation at all.
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Azrael Noor wrote:Generalization is the process of extracting shared characteristics from two or more classes,
and combining them into a generalized superclass <------- Don't we use this in JAVA ?


This is not specific to Java and it's not so much a feature of the language as it is a design adjustment (refactoring). It's something that a developer/designer does when he realizes that there is some kind of common behavior between two or more classes that can be consolidated to eliminate duplication. If you use an IDE that has refactoring utilities like Eclipse, this is pretty easy to do: in the editor, you would highlight the method you want to move to a superclass, right click, then select Refactor -> Pull Up. See http://www.ibm.com/developerworks/library/os-ecref/ for more on refactoring in Eclipse (kind of old article but it gives you a good idea of the motivations for doing these things).
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To make the point about specialization more clear:

Suppose you have a class named Animal. Now you can create subclasses of Animal - for example Dog extends Animal, Cat extends Animal. Dogs and cats are specific types of animals. So, if you create a subclass of Animal, you're creating a class that represents a specialized kind of Animal.

The other way around: Suppose that you didn't have the class Animal at first, but you did have different classes for different animals, such as Dog and Cat. Now you decide to take the parts that are common to dogs and cats and you put them in a common superclass Animal (you make Dog and Cat extend Animal). You could call that generalization. But that's the opposite of what you said in your post:

Azrael Noor wrote:Generalization : means Extending a Class


 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Azrael Noor wrote:

Jesper de Jong wrote:
Generalization is the process of extracting shared characteristics from two or more classes,
and combining them into a generalized superclass <------- Don't we use this in JAVA ?




A superclass is a generalized form of one or more sub-classes. The examples above are good enough to explain the theory.

 
praveen murali
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote: If you use an IDE that has refactoring utilities like Eclipse, this is pretty easy to do: in the editor, you would highlight the method you want to move to a superclass, right click, then select Refactor -> Pull Up.



That was helpful, thanks, didn't know that.
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all.
Facts are quite cleared
about Generalization and Specialization

but Realization part is not understood till yet.
Mr. Jong said that It is not used in Java but it is still parts of OOPS

If anyone continue with this part, i shall be thankful .
 
Bartender
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Realization is basically a UML term used to denote a semantic relationship between two entities where one of them specifies a contract that another one guarantees to fulfill.
Since UML is Java-independent (actually any-technology-independent) it is basically just the difference in terminology. What is called realization in UML, you can refer to as interface implementation in Java.
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:The other way around: Suppose that you didn't have the class Animal at first, but you did have different classes for different animals, such as Dog and Cat. Now you decide to take the parts that are common to dogs and cats and you put them in a common superclass Animal (you make Dog and Cat extend Animal). You could call that generalization.



I'd say that is the common meaning of generalization - it's fairly standard usage when talking about object-oriented concepts, though possibly not so much when specifically applied to Java. For instance, it's the term that the UML specification uses. I teach on a course on object-oriented software development, and it uses the terms generalization/specialization as opposites in exactly this way.
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could we say Generalization, Specialization and Realization , the design principles ?
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No
 
And then the flying monkeys attacked. My only defense was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic