The Artima Developer Community
Sponsored Link •

Design Forum
OOP Concepts

4 replies on 1 page. Most recent reply: Oct 7, 2002 8:00 AM by Karthicraja

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
richard lockwood

Posts: 1
Nickname: rich
Registered: Aug, 2002

OOP Concepts Posted: Aug 16, 2002 7:32 AM
Reply to this message Reply
Advertisement
Could anyone tell me the Advantages & Disadvantages & if possibel a brief description of each of the following:
Encapsulation
Polymorphism
Inheritance
Abstract Classes

I've looked all over the web and find nothing (well, no ads or disads) so if anyone can help, respect!

Richard


Janu

Posts: 8
Nickname: janu
Registered: May, 2002

Re: OOP Concepts Posted: Aug 17, 2002 2:07 AM
Reply to this message Reply
ENCAPSULATION
Encapsulation is the mechanism that binds together code and the data it manipulates,abd keeps bothe sage from outside interreferences and misuse.
One way to think about encapsulation is as a protective wrapper that prevents the code andd data from being arbitrarily accessed by other code defined outside the wrapper

Abstraction:
Breaking the complex things in manageable pieces to make it more flexible.

Ana

Posts: 12
Nickname: anika
Registered: Aug, 2002

Re: OOP Concepts Posted: Sep 19, 2002 3:43 AM
Reply to this message Reply
I recommend Thinking in Java by Bruce Eckel at www.BruceEckel.com to look up these and some other concepts.
Regards
Ana

bree vanoss

Posts: 9
Nickname: bree
Registered: Sep, 2002

Re: OOP Concepts Posted: Sep 30, 2002 2:14 PM
Reply to this message Reply
Inheritance:
Pro: If you have multiple "things" that are all a type of something, (farmers and fishermen are both people) you can place common logic/attributes in the "parent" class. This allows for code reuse.
Con: It is possible to over-rely on inheritance, the result of which may be a tall, unweildy object model. This type of model could lead to problems if it is possible that an ancestor may need to be moved about or broken down. That doesn't make a whole lot of sense; let's say that you have this really tall model and then you find that one attribute MUST NOT BE AVAILABLE in one of the child classes, if this happens there may be quite a bit of work to refactor the super tall oblect model. Hint: use assocaition instead of inheritance.

Abstract Classes:
Pro: Marking a class as Abstract basically forces it to be extended before it is a valid class that can be instantiated. They can also sorta function as an interface, in that an abstract class may be a return type from a method, so that the underlying implementation can vary based on some criteria. For example

<java>
Calendar myCal = Calendar.getInstance();
</java>

could return a Calendar object that is valid for the current locale. This means that if the system's current locale is US, it would get a GregorianCalendar whereas if the current locale was JA, it may get some sort of Japanese calendar.

Con: People often get confused about when to use an interface vs. an abstract class.

Encapsulation:
Pro: Encapsulation allows developers/designers to use "things" instead of having to write all the application logic from scratch.

Con: This may sounds stupid, but if people use crappy names, encapsulation can actually be a pain because you have to actually look at the class to figure out what the hell it's supposed to do.

enjoy,

-=bree

Karthicraja

Posts: 3
Nickname: alice
Registered: May, 2002

Re: OOP Concepts Posted: Oct 7, 2002 8:00 AM
Reply to this message Reply
* Encapsulation
Encapsulation in OOAD terms means hiding all the details of an object that do not contribute to its essential characteristics. Encapsulation hides the implementation details of the object and the only thing that remains externally visible is the interface of the object.

+Ve
A good program should encapsulate or hide a single design decision. - Peter Coad and Edward Yourdon
It helps in exposing only the essential behavior to the outside world.
The data will be secure under one object.

-Ve
is there any ????

* Inheritance

Inheritance provides a natural classification for kinds of objects and allows for the commonality of objects to be explicitly taken advantage of in modeling and constructing object systems.

+Ve
This reduces the complexity of structuring while designing the system.
Through the use of inheritance, programmers can reuse the code in the super class many times.

-Ve
Immature use of inheritance will lead to a clumsy code.
It couples implementation with the parent class. Trouble starts if i have to change the base class.

* Polymorphism
polymorphism means that some code or operations or objects behave differently in different contexts.

+ve
the most powerful concept. That contributes reusability in a greater extent.
It simplifies the programming by facilitating proper abstraction

- Karthicraja

Flat View: This topic has 4 replies on 1 page
Topic: Design Resources Previous Topic   Next Topic Topic: Caching of data in a cluster

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use