Results 1 to 6 of 6

Thread: Differentiation between Containment and Inheritance

  1. #1
    Join Date
    Dec 2009
    Posts
    67

    Differentiation between Containment and Inheritance

    Hello friends,

    I am IT student with lots of confusion about the programming concept. I am not able to find what is the difference between the Containment and Inheritance. I am aware that inheritance implements the idea of code reusability. But don't know about the Containment. Is anybody know the difference between Containment and Inheritance? If yes then please let me aware about that. Your any help would be appreciable.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Differentiation between Containment and Inheritance

    In the Java programming language, each class is allowed to have one direct superclass, and each superclass has the potential for an unlimited number of subclasses. The inheritance is nothing but Exposing the managed object as the outer object. OOPs enables the classes of programs to inherit commonly used state and behavior from other classes. In this example, Bicycle now becomes the superclass of RoadBike, MountBike and TandmBike.

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Differentiation between Containment and Inheritance

    Please refer following two examples of Containment and Inheritance. From these two you will get the exact idea about the Containment and Inheritance. See below:
    Inheritance:
    Code:
    // Inheritance
    
    interface Entity1 
    {
      public Object getData();
    }
     
    interface PersistedEntity1 extends Entity1 
    {
      public PersistedEntityPK getPK();
      // all other Entity methods inherited from super interface
    }
    Containment :
    // Containment:

    interface Entity1
    {
    public Object getData();
    }

    interface PersistedEntity1
    {
    public PersistedEntityPK1 getPK1();

    // must call getEntity() method to call any of Entity's members...
    public Entity getEntity();
    }

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Differentiation between Containment and Inheritance

    Hi,

    The Inheritance is normally recommended for new sites because it's simpler. While the Containment approach is better for servlets which are already exists. Containment concept also used for to embed a discussion forum table at the bottom of a web page. The difference is that in the Inheritance, template object is the servlet, while in the Containment, the servlet is not a template but merely uses template for portion of its work.

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Differentiation between Containment and Inheritance

    Hi friend,

    The concept of inheritance is of "IS A" ==> Base class relationship with derived classes. While the concept of containment of is of "IS A" ==> Base class relationship with derived classes. Containment allows the outer object of class for to modify the behavior of the inner object. Use containment concept only when the outer object of class needs to modify the behavior of the inner object. I hope this information will help you to understand the Containment and Inheritance.

  6. #6
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Differentiation between Containment and Inheritance

    Hello friend,

    When inheritance concept is exposed to the COM , they extends IDispatch as well as IUnknown. The same rule applies to the class interfaces that are generated for the managed classes. The valid base class must be be creatable, defined as a metadata as well as aggregatable. While the derived class is able to expose all the properties & methods of the COM object as well as properties & methods implemented in managed code.

Similar Threads

  1. Replies: 3
    Last Post: 08-01-2011, 06:32 AM
  2. What is the Bean Context : Containment Only?
    By NGV BalaKrishna in forum Software Development
    Replies: 4
    Last Post: 17-02-2010, 06:47 AM
  3. Differentiation between Inheritance and Aggregation
    By Sonam Goenka in forum Software Development
    Replies: 5
    Last Post: 30-01-2010, 02:48 PM
  4. newfolder.exe containment procedure
    By Derek in forum Windows Security
    Replies: 2
    Last Post: 03-12-2009, 04:17 AM
  5. Differentiation between WAN and LAN
    By Dolsy_bendal in forum Networking & Security
    Replies: 4
    Last Post: 30-11-2009, 10:46 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,676,748.07857 seconds with 17 queries