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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:24:43+00:00 2026-06-04T23:24:43+00:00

I am cleaning up some code in a class that has a settable property,

  • 0

I am cleaning up some code in a class that has a settable property, with a local variable holding the value.

Some parts of the code currently call externally to get the value rather than using its own property, other parts sometimes use the property itself whilst in others the local variable is used.

In this case the property is simply set by the factory method that creates an object of this class, so the property always is the same as the variable. However I am not sure that I should be assuming this is the case in the code I am writing as that makes it harder in the future to add logic behind the getter method.

Is this something where either might be right, or am I forgetting something basic in my OO principles?

  • 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-04T23:24:45+00:00Added an answer on June 4, 2026 at 11:24 pm

    To reduce complexity and increase maintainability.

    First thing you should do is reduce the number of places an item exist (which you seem to be doing).

    Next you should use any language tricks to reduce the size of the code. For exmaple in some versions of c# you don’t need to declare fields to hold values of properties.

    Once you done this you can chooses either method – there is not performance optimisation that comes from one over the other. But to be consistent. That is will increase maintainability.

    Personally I prefer to always use properties where I can.

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

Sidebar

Related Questions

I'm cleaning up some code, and I have a class with an entity that
currently I'm cleaning up some code which creates a lot of php warnings. I've
I am cleaning up some code in a C# app that I wrote and
I'm cleaning up some pretty complicated code that I didn't write and I'm looking
While cleaning some code today written by someone else, I changed the access modifier
I'm running some code through FxCop and am currently looking at clearing all of
I'm cleaning some of the Python code I wrote when I was...not as knowledgeable.
I am cleaning up some old code converting it to work asynchronously. psDelegate.GetStops decStops
I've recently seen some code similar to that outlined below. public void someMethod() {
Today, I was cleaning up some of my code with FXCop and it complained

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.