Have you heard of static classes, coming in C# 2.0 (Whidbey)? These are classes which are not intended to be instantiated. They can contain only static members. Ie:
publicstaticvoid swap<T>(ref T left, ref T right)
T temp = left;
left = right;
right = temp;
publicstatic T max<T> (T left, T right) where T : IComparable
if (left.CompareTo(right) > 0)
Wait a minute! Classes are supposed to be patterns from which objects are instantiated. If you can't instantiate an object from a class, well it is not a class, is it? Why not simply allow non-member methods and group them in namespaces?
I can think of only one reason: marketing. It simply does not look "OO" enough. Although static members of static classes are for all practical purposes non-member methods (with an extra inconvenience that the class' name must be typed each time you invoke them), by keeping them in "static classes" the ilusion of "pure OO" is better preserved.
<a href = http://www.codeproject.com/script/profile/whos_who.asp?id=14112#Blog> My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
Last Visit: 31-Dec-99 19:00 Last Update: 21-Jan-17 2:47