Solved

Help with properties

Posted on 2006-07-11
4
195 Views
Last Modified: 2010-04-23
What case(s) would I need to use
ReadOnly or WriteOnly
properties?

I may have a follow-up or two on this, so I'll start it low and increase it if I need further explanation(s0>
Thanx!
0
Comment
Question by:sirbounty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 125 total points
ID: 17086794
Hi sirbounty,

A often use ReadOnly properties for values that are read from the database and which the application cannot change. For example a tax rate.

Another example where a ReadOnly property is useful is for calculated values. Say for example you have a FirstName and a LastName property, you could create a ReadOnly FullName property which would be FirstName + " " + LastName.

I never use WriteOnly properties. About the only place where I can it could make sens (and even there I am not 100% convinced) is for properties like password. You need a way to set the value but you cannot read from it.

Cheers!
0
 
LVL 67

Author Comment

by:sirbounty
ID: 17086810
a ReadOnly property is useful is for calculated values

This may be what I need then...

Say I have
Person.Age
along with today's date.

If wanted to have
Person.BirthDate

could that be a ReadOnly property?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 17086815
sirbounty,

Yes but you should probably better have the BirthDate field in your database (read/write property) and a ReadOnly Age property.
0
 
LVL 67

Author Comment

by:sirbounty
ID: 17086838
Yeah - just the quickest example I could come up off the top of my head... ;^)

Thanx, as always.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question