Solved

Help with properties

Posted on 2006-07-11
4
196 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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

707 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