Prev | Current Page 272 | Next

Jon Skeet

"C# in Depth: What you need to master C# 2 and 3"

A method returning a bool? can be
used to obtain an initial definitely equal, definitely not equal or unknown result based on the
references, however. The complete code of PartialComparer on this book??™s website
contains the appropriate utility method and examples of its use.
4.5 Summary
When faced with a problem, developers tend to take the easiest short-term solution,
even if it??™s not particularly elegant. That??™s often exactly the right decision??”we don??™t
want to be guilty of overengineering, after all. However, it??™s always nice when a good
solution is also the easiest solution.
Nullable types solve a very specific problem that only had somewhat ugly solutions
before C# 2. The features provided are just a better-supported version of a solution
that was feasible but time-consuming in C# 1. The combination of generics (to avoid
code duplication), CLR support (to provide suitable boxing and unboxing behavior),
and language support (to provide concise syntax along with convenient conversions
and operators) makes the solution far more compelling than it was previously.
It so happens that in providing nullable types, the C# and Framework designers
have made some other patterns available that just weren??™t worth the effort before.
We??™ve looked at some of them in this chapter, and I wouldn??™t be at all surprised to see
more of them appearing over time.


Pages:
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284