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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:03:53+00:00 2026-05-14T05:03:53+00:00

I understand it is a very basic concept in the oops. But still I

  • 0

I understand it is a very basic concept in the oops. But still I cannot get my head around. I understood why member variables are private, so class user cannot abuse it by setting up invalid values.

But how can this apply to the methods ?

  • 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-14T05:03:54+00:00Added an answer on May 14, 2026 at 5:03 am

    Lot of good answers, but maybe one more from a self-taught Java programmer as I went through all that by myself with a lot of pain 😉

    Think about a Class as something seen from the outside, not as something you see internally. If you look at a Class from the outside, what you see?

    Taking the clock as an example again, a clock can give you info about the current time and it can be set up to show the right time.

    So looking at things from the outside, a clock is a machine that can do those two things; public methods we call them.

    But we as constructors of this clock we know that before any time operation we have to switch from 23 to 11 on our display (it’s that kind of clock), so we have to rearrange things internally a bit to do so. Changing from 23 to 11 works just fine for us in both cases – setting the clock and showing the current time – but we do it “on the side” as the user doesn’t have to know about all that complicated math. These are private methods!

    So our Clock Class could have two public methods (showTime and setTime) which are all that the user wants to see, and a private method (recountTime) that provides functionality for these public methods and are something that the user doesn’t want to see.

    So on the one hand, you should keep in mind that private is what won’t be reimplemented and accessed by future programmers using your code (as was pointed at in the answers above). But private also means things done on the side, so the user don’t see it. That’s why we call the public methods a public interface – it’s all the user will see from the outside.

    For me it is helpful (I’m self-taught, so maybe it’s not a very popular methodology…) to write down everything the users (real users and other Classes) will do with my Class (public interface with just public methods’ signatures), then to write the signatures of private methods that I-the-implementer will use to accomplish the public goals that promised to provide to my users and then just fulfill it with code.

    It can be helpful to keep in mind that the old C rule is still valid (as was expressed in 97 Things Every Programmer Should Know): a function/method should be just a few lines long, really!!

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

Sidebar

Ask A Question

Stats

  • Questions 356k
  • Answers 356k
  • 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 I after asking this question I figured it out how… May 14, 2026 at 8:49 am
  • Editorial Team
    Editorial Team added an answer If you're using ActiveRecord, you can do something like <%… May 14, 2026 at 8:49 am
  • Editorial Team
    Editorial Team added an answer Use this in your document ready function when initialising the… May 14, 2026 at 8:49 am

Related Questions

In my free time I like polishing my algorithm / programming skills (well, my
I am writing a Facebook application that is a simple board game which I
I've been trying to learn about Neural Networks for a while now, and I
Question As stated, have you any tips to help grok / understand / get-your-head-around
I am losing my mind here. Im looking at a beginners OAuth php package

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.