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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:23:57+00:00 2026-05-31T10:23:57+00:00

While designing a class ( in c#, or any oop lang) i always get

  • 0

While designing a class ( in c#, or any oop lang) i always get confused with shall i have property defined in a class and use it in methods of class , or it’s good to simply have method parameters.

One problem i found in first way is that it creates dependancy (like , what if caller has forgotten to assign the value to the property etc..).

e.g. I am designing a class “myexcel” which does “export to cvs” , “Get XML” , “format excel and save”

Here shall i have “ExcelPath” as property of myexcel or shall i pass it as parameter to GetXml , export , format 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-31T10:23:58+00:00Added an answer on May 31, 2026 at 10:23 am

    Properties should define the state associated with object – the state information that qualifies say one instance from other instance. It does not make sense to store a temporal information that is valid for a single function invocation into the object state. In other words, if you make something a object property because its get used in some method then it would only make sense if the same property value is used across multiple invocation or the property get used in multiple methods.

    So in your particular case, filePath should be a parameter for all save/export methods because from usage perspective, the object instance represent some data and save/export is a just a way to serialize it. The file path would be valid for that call only – it will likely to change over multiple invocations.

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

Sidebar

Related Questions

While designing the class, I always get confused what to put in Constructor and
While designing an interface for a class I normally get caught in two minds
Possible Duplicate: Syntax error while defining an array as a property of a class
While I'm designing a MySQL database for a dating website, I have come with
Alright, while designing a site, I came across a thought... I have a few
I have questions about a couple techniques I'm using in designing a class. I've
I've been designing websites for a while now and haven't had any complaints, surprisingly.
I have been trying different techniques while designing this application, which to me is
While designing a service class should it be singleton in java? Generally DAO is
When I use count while defining a private variable in a php class, It

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.