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 6587127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:52:42+00:00 2026-05-25T16:52:42+00:00

Even if I make class member functions public and it is consumed by other

  • 0

Even if I make class member functions public and it is consumed by
other client applications, implementation details of
functions will never get exposed to client. Why make member functions protected or private?

For example, if my class is Math, with public function sum(int, int b) then only interface/declaration part will be exposed to client and not implementation.

public class Math
{
      public int sum(int, int b)
      {
               //Implementation
      }
}


public class Client
{
         Math objMath = new Math();
         objMath.Sum(4,10);//It will not display implementation inside sum than why to avoid
}
  • 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-25T16:52:42+00:00Added an answer on May 25, 2026 at 4:52 pm

    The more public your methods (and types) are, the more code they’re exposed to. That increases the chance that other code (even code under your company’s control) will start depending on that code working the way it currently does… which limits the flexibility to change the implementation later.

    To give a concrete example, I’m working on an open source project called Noda Time. Now admittedly we haven’t had our first public release yet, but I’ve recently been making a load of changes to various internal types – including changing the type hierarchies fairly significantly, and even removing methods. If those had been public types or public methods (and if we’d already gone to v1.0) then we could have broken code which depended on that specific implementation.

    By hiding everything you don’t know to be useful to clients, you buy yourself a lot of flexibility. It’s incredibly important to put a lot of thought into your public API, because that’s really hard to change later – but if you’ve kept a lot of your implementation internal, you can refactor to your heart’s content to make it more elegant, more flexible, or perhaps faster… all without breaking any of the code depending on your library.

    Obviously some things need to be exposed – at least in class libraries – but you should be careful just how much you expose, unless you’re happy to break all callers later on (or live with every decision you make, forever).

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

Sidebar

Related Questions

Does it make sense to use .NET DataSets even in applications that use a
Does the @error line even make sense here? Would it even be hit in
To make my extranet web application even faster/more scalable I think of using some
Even on big-time sites such as Google, I sometimes make a request and the
I want to zip even and odd elements in a list to make a
How do I make Log4net only log Info level logs? Is that even possible?
What CSS should I use to make a cell's border appear even if the
I want to make an indie game for xbox360. Even if it is freeware
I want to hide public methods from the IntelliSense member list. I have created
One of my WCF functions returns an object that has a member variable of

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.