Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7730449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:13:37+00:00 2026-06-01T06:13:37+00:00

How to decide when to use object adapter and when to use class adapter?

  • 0

How to decide when to use object adapter and when to use class adapter?

Problem statement:
To create social networking web site and provide import functionality from facebook, google plus and orkut. I am unable to decide whether to use object adapter or class adapter.

I have had look at Adapter Pattern: Class Adapter vs Object Adapter, but could not understand the essence of the difference.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:13:38+00:00Added an answer on June 1, 2026 at 6:13 am

    The main difference:

    • Class Adapter uses inheritance and can only wrap a class. It cannot wrap an interface since by definition it must derive from some base class.

    • Object Adapter uses composition and can wrap classes or interfaces, or both. It can do this since it contains, as a private, encapsulated member, the class or interface object instance it wraps.

    The difference is subtle. Usually the later approach (favoring composition over inheritance) is the preferable as explained in the link which I’ll quote here:

    Object-Oriented Programing (OOP) has too well known candidates for the
    reuse of functionality: Inheritance (whitebox reuse) and Composition
    (blackbox reuse). If you try to reuse code by inheriing from a class
    you will make the subclass dependent on the parent class. This makes a
    system in many cases unnecessarily complex, less testable and makes
    the exchange of functionality at run time unnecessarily hard. As a [Clean Code Developer]
    you should follow the Liskov Substitution Principle (LSP) when you
    need to decide if inheritance is appropriate.

    Composition means that one class uses another. You will further
    promote decoupling by defining the interfaces clearly. That will also
    give you the advantage that implementations can be easily replaced. So
    before you start applying the Liskov Substitution pronciple, think
    about the Favour Composition over Inheritance concept and ask
    yourselve why you shouldn’t prefer composition right away.

    "Because inheritance exposes a subclass to details of its parent’s
    implementation, it’s often said that ‘inheritance breaks
    encapsulation’". (Gang of Four 1995:19)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to decide whether to use threads or create separate process altogether in your
Suppose I create a custom object/javascript class (airquotes) as follows: // Constructor function CustomObject(stringParam)
Please help me decide whether I should use a function's prototype object and the
How do you decide what to choose: use mock objects for a test OR
I want to encode and decode Bitmap object in string base64 . I use
if i decide to use the 'publish' option for my ASP.NET website, instead of
Before I decide to use DetailView , I had a url redirect using this
Why did some processor manifacturers decide to use Little endian Big endian Middle endian
From the documentation of UITableView / UITableViewController: If you decide to use a UIViewController
I'm aiming to write an application for galaxy tab and decide to use platform

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.