Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. CO“You could also use Code Contracts to make things even more explicit.” But using types instead of contracts is more explicit still and gives better compiler support. If you regard the type system as a proof system that allows you to formulate assertions and invariants about your code (and really, that’s the *definition* of a type system) then adding units makes a lot of sense. Apart from the fact that code contracts on the callee site require more code duplication by far.
      singulars
    2. CO@Konrad Rudolph - When I suggested Code Contracts, I was referring to the bounds checking logic and validation. Using Code Contracts would allow him to better define the range of expected values and allow the compiler to warn the developers when their values may be out of range. I agree that a Type is more explicit, but in this case it's a simple wrapper around Int32 which doesn't add value in my opinion.
      singulars
    3. CO“it’s a simple wrapper … which doesn’t add value” betrays a misunderstanding of what types are there for. Types don’t have to bundle data, or add a lot of action. The mere fact that *different* types exist is an important purpose of types. Why else are there different units in physics? Any physicist will tell you that when you do a calculation (on paper or in the computer) and the units at the end agree, the calculation is most probably also correct. The same argument applies to fact checking (= compiling with strong types). Consider: why else does the `TimeSpan` class exist?
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload