Categories
Technology

An Assumption Makes…

Assumptions are wonderful. They allow you to fly ahead without needing to fuss over any time-consuming details… until, at least, the assumption fails you. Like the “ref” keyword, for example.

A data type is a value type if it holds the data within its own memory allocation [Eg. numeric types, bool, any struct types]. A reference type contains a pointer to another memory location that holds the data [Eg. String, any class types].

So, when it comes to argument passing in .Net, by default, all value types are passed by, well, value 🙂 and reference types too are also passed by value. But value in the case of the reference type, is the value of the reference. This little nuance [nuisance, at first] popped up quite late in my project simply because the implemented design didn’t call for any dynamic re-allocating, until one particular test started failing during what was supposed to be routine “refactoring”. I say “supposed to be” because the refactor ended up changing the behaviour hence no longer a refactor… anyhoooo…

My assumption [reference types = raw pointer, ala C++] allowed me to gloss over an entire section of the C# specification. Had i paid any real thought to this little abstraction way back then, i would probably still have forgotten about it when i had to call upon that knowledge for the first time, months later. Or not. At least now i know i won’t *ever* forget about it 🙂

Any which way, i still think assumptions are good. Even better though if you can change them. And best if you can constantly challenge them or have them challenged. And yes, an assumption can lead you off into the wrong direction, but hey! At least it’s a direction. Could have indulged the specification in depth before hand and told my employer to wait n months while i read all about C#… don’t think that would have worked too well either.

As always, some tempering between the extremes is a refreshing welcome…

One reply on “An Assumption Makes…”

Comments are closed.