Find out how to take advantage of the generics capability introduced with .NET 2.0, which provides an elegant solution to performing range checks within your applications.
by Jean-Paul S. Boodhoo
March 7, 2006
am a big fan of objects. It's so convenient to work with programming entities that you can ask to do something and they just do it. The shift that we developers have made from procedural style to OO style allows us to express ideas in much richer ways than were possible using procedural methods. Knowing how to identify areas where a new object can be introduced to simplify the code in your application is a talent that many spend years improving (I can't say perfect, because software development is truly an evolutionary process).
How many times in your applications do you write logic that deals with ranges of values? For example, consider an order entry system that allows "special" orders to be processed only on certain weekdaysand then only between certain hours. Systems such as this make heavy use of range checks to ensure that accepted orders meet validity constraints. It's not uncommon to see code such as this, which is an NUnit test that checks whether a date lies within a specified range:
It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com. Already a member?
To become a member of DevX.com create your Member Profile by completing the form below. Membership is free!