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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:28:21+00:00 2026-05-12T08:28:21+00:00

Possible Duplicate: Properties vs Methods In method you can type some code and in

  • 0

Possible Duplicate:
Properties vs Methods

In method you can type some code and in properties too. For example I have a property Name. When class name changes I would like to get some data from database and change state of my object. I can add this code to set part of my property. Other solution is to change set part to private and add method called SetName and in this method add my code.

So what is the difference? When is the point when it’s not good to put some code to getter / setter and when to create own method that is used to change my property and other parts of my class?

  • 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-12T08:28:22+00:00Added an answer on May 12, 2026 at 8:28 am

    Here is a good set of guidelines for when to use properties vs methods from Bill Wagner (fixed link)

    • Use a Property when all these are true:
      The getters should be simple and thus unlikely to throw exceptions. Note that this implies no network (or database) access. Either might fail, and therefore would throw an exception.
    • They should not have dependencies on each other. Note that this would include setting one property and having it affect another. (For example, setting the FirstName property would affect a read-only FullName property that composed the first name + last name properties implies such a dependency )
    • They should be settable in any order
    • The getter does not have an observable side effect Note this guideline doesn’t preclude some forms of lazy evaluation in a property.
    • The method must always return immediately. (Note that this precludes a property that makes a database access call, web service call, or other similar operation).
    • Use a method if the member returns an array.
    • Repeated calls to the getter (without intervening code) should return the same value.
    • Repeated calls to the setter (with the same value) should yield no difference from a single call.

    • The get should not return a reference to internal data structures (See item 23). A method could return a deep copy, and could avoid this issue.

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

Sidebar

Ask A Question

Stats

  • Questions 195k
  • Answers 196k
  • 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 This works under FF 3.5 and IE7 for me: $(function()… May 12, 2026 at 7:04 pm
  • Editorial Team
    Editorial Team added an answer Well, my solution for now is that I persist each… May 12, 2026 at 7:04 pm
  • Editorial Team
    Editorial Team added an answer I have the solution glPushMatrix(); glRotatef( 180.0f, 1.0f, 0.0f, 0.0f… May 12, 2026 at 7:04 pm

Related Questions

Possible Duplicate: Why are C# collection-properties not flagged as obsolete when calling properties on
Possible Duplicate: How can I specify system properties in Tomcat configuration on startup? What
Possible Duplicate: How to reference another property in java.util.Properties? look at my file.properties: key1=
Possible Duplicate: How costly is .NET reflection? The elegant solution to a problem I

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.