The Artima Developer Community
Sponsored Link

.NET Buzz Forum
To ReadOnly or not to ReadOnly?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jeff Key

Posts: 481
Nickname: jeffreykey
Registered: Nov, 2003

Jeff Key is legally sane, but questionably competent.
To ReadOnly or not to ReadOnly? Posted: Feb 6, 2004 12:41 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Jeff Key.
Original Post: To ReadOnly or not to ReadOnly?
Feed Title: Jeff Key
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/jkey/Rss.aspx
Feed Description: Topics revolve around .NET and the Windows platform.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Jeff Key
Latest Posts From Jeff Key

Advertisement

BradA occasionally posts API design questions on his blog and the flood of comments never disappoint.  Yesterday's question was regarding read-only collections:  Should a potentially read-only collection be derived from a read-only class, or should it have a ReadOnly property that indicates whether it's read-only. 

I think it depends whether it's a class whose context is within an application versus a library.  If it a class in an application, then the latter is fine.  The behavior is known and expected.  However, if it's in a library such as the FCL, I prefer the latter.  Imagine if there was a read-only flag on ArrayList or Hashtable.  Before adding/removing any members you'd always have to check it's ReadOnly property.  Completely unnecessary.  If it extended a ReadOnlyArrayList, then there is no question what it supports.  If you need read-only, you type your param/variable/whatever as ReadOnlyArrayList; if you need to write to it, you type it as ArrayList. 

Regardless, it's worth a read.  Everyone has valid comments.

Read: To ReadOnly or not to ReadOnly?

Topic: NCoverViewer Previous Topic   Next Topic Topic: Sign of life

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use