Idea 1: Numeric.ANumber
In .net 4.0 Microsoft is introducing the BigInteger Type. Why didn't they also add the an arbitary precision type as well?
They have shown previous they capability to implement one, as shown in the XP Powertoy PowerCalc. (Upto 512 digits).
My reasoning is this, if it as extracted and available, coders wouldn't have to worry about parsing into a particalur type.
To a end user; they enter a number, they ain't fussed wether it's a byte, a double or an integer.
Namespace: Numerics.Number / Numerics.ANumber ← My Preference
VB.Net Code Example:
Dim x As ANumber=123.567
Dim NewPrice As ANumber = ANumber.FromText(ProductPriceChange.NewPrice)
Note: Number.FromText can accept strings, or any control that has text propertity, etc,
ThisNumber.Increment
ThisNumber.Decrement
While ThisNumber.IsPositive (Note: IsPositive, Zero is classified as a positive.)
To me this further enhances the readabilty of the codesource.
For it to be as useful as the standard base class types, it would require to have the full functionality of System.Math.
Or its own NameSpace: Numeric.ANumber.Math / Numerics.Math
Idea 2: "Branded" Types
To have the ability to "brand" an instance of a numeric type (BaseClass & Numeric) as of belong to a particular user-define "collection" or unit.
Think of it as an opposite to Generics but a type gets "Branded".
Then Functions, Methods, etc. that take "branded" type only accept those "branded types".Saving the coder have to implement explicitly as new class. Also it would let enable the capabilty of being checked at design / compile time. Minimising and catching some of the basic human errors. I.e. Confusing Feet & Inchs with metres.
VB.Net Code Example:
Dim CarSpeed As Double [Velocity] Note: Using Square Braces
← My Preference
Dim CarSpeed As Double {AsA Velocity} Note: Keyword "AsA"
Function ImpactSpeed(ByRef v1 As Double[Velocity], ByRef v2 As Double[Velocity] ) As Double[Velocity]
Dim Vi As Double[Velocity]
Vi=v1+v2
Return Vi
End Function
Intellisense could then be extended to have the capabilty show the coder all the "Branded" types.
Dim MassOfThisPerson As Double[→Velocity ?]
In addition to letting the coder create a "brand" Microsoft could supply a predefined list of "Branded" types for example, covering SI units of measurement (Mass, Velocity)
What are your thoughts on these ideas?
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.