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

  • SEARCH
  • Home
  • 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 424591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:17:43+00:00 2026-05-12T19:17:43+00:00

So I’ve been dealing with several APIs recently provided by different software vendors for

  • 0

So I’ve been dealing with several APIs recently provided by different software vendors for their products. Sometimes things are lacking, sometimes I just want to make the code more readable, and I’m trying to avoid a ton of static methods where they don’t belong to “get what I need” from the APIs. Thus, I’ve found myself writing quite a few extension methods.

However, because there are many methods, and in the interest of keeping “my” methods separate from those of the API objects in terms of code readability, I came up with this little tidbit:

public class MyThirdPartyApiExtensionClass {

    public static MyThirdPartyApiExtensionClass MTPAEC(this ThirdPartyApiClass value) {
        return new MyThirdPartyApiExtensionClass(value);
    }

    private ThirdPartyApiClass value;

    public MyThirdPartyApiExtensionClass(ThirdPartyApiClass extendee) {
        value = extendee;
    }

    public string SomeMethod() {
        string foo = value.SomeCrappyMethodTheProviderGaveUs();
        //do some stuff that the third party api can't do that we need
        return foo;
    }

    public int SomeOtherMethod() {
        int bar = value.WowThisAPISucks(null);
        //more stuff
        return bar;
    }

}

Then I can do things like:

string awesome = instanceOfApiObject.MTPAEC.SomeMethod();

and I have a clean separation of my stuff from theirs.

Now my question is.. does this seem like a good practice, improving code readability… or is this a bad idea? Are there any harmful consequences to doing this?

Disclaimer:
The code above is just to demonstrate the concept. Obviously there is better sanity checking and usefulness in the real thing.

I suppose the same level of separation could simply be done like this:

public static class MyThirdPartyApiExtensionClass {

    public ThirdPartyApiClass MTPAEC(this ThirdPartyApiClass value) {
        return value;
    }

    public string SomeMethod(this ThirdPartyApiClass value) {
        string foo = value.SomeCrappyMethodTheProviderGaveUs();
        //do some stuff that the third party api can't do that we need
        return foo;
    }

    public int SomeOtherMethod(this ThirdPartyApiClass value) {
        int bar = value.WowThisAPISucks(null);
        //more stuff
        return bar;
    }

}
  • 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-05-12T19:17:43+00:00Added an answer on May 12, 2026 at 7:17 pm

    To answer your direct question, I think that going through the extra trouble to separate out your functionality from the basic functionality is a bad code smell. Don’t worry about having your code separate from their code from a usage perspective. First it makes it that much harder to find what you’re looking for since now there’s two places to look for the same functionality and secondly the syntax makes it look like your extensions are operating on the MTPAEC property and not the core object (which they are).

    My suggestion is to use actual Extension methods which allow you to have that but without having the additional constructor.

    public static class ApiExtension
    {
        public static string SomeMethod(this ThirdPartyApiClass value)
        {
            string foo = value.SomeCrappyMethodTheProviderGaveUs();
            //do some stuff that the third party api can't do that we need
            return foo;
        }
    }
    

    used by

    var mine = new ThirdPartyApiClass();
    mine.SomeMethod();
    

    C# will do the rest.

    Looking at your above suggestion you’ll have to split the two classes out I think. One for providing extension groups using the extensions mechanism and another for providing each group of logic.

    If you need to separate out yours from a glance then use a naming convention to make your look unique. Though upon hovering and through intellisense it will tell you that it is an extension method.

    If you just want the separation of content like you have, then you’ll need two classes.

    public static class ApiExtensionder
    {
        public static MTPAEC(this ThirdPartyApiClass value)
        {
            return new MtpaecExtensionWrapper(value);
        }
    }
    
    public class MtpaecExtensionWrapper
    {
        private ThirdPartyApiClass wrapped;
    
        public MtpaecExtensionWrapper(ThirdPartyApiClass wrapped)
        {
            this.wrapped = wrapped;
        }
    
        public string SomeMethod()
        {
            string foo = this.wrapped.SomeCrappyMethodTheProviderGaveUs();
            //do some stuff that the third party api can't do that we need
            return foo;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 225k
  • Answers 225k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You might want to look at MySql Membership and role… May 13, 2026 at 12:56 am
  • Editorial Team
    Editorial Team added an answer have you looked at lsof May 13, 2026 at 12:56 am
  • Editorial Team
    Editorial Team added an answer There is some good information in this post, so I… May 13, 2026 at 12:56 am

Related Questions

I want use html5's new tag to play a wav file (currently only supported
this is what i have right now Drawing an RSS feed into the php,
I have text I am displaying in SIlverlight that is coming from a CMS
I have a French site that I want to parse, but am running into
In order to apply a triggered animation to all ToolTip s in my app,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.