c# - Is wrapping System.Math a bad idea? -
i have own math library , want called "math" (i'd been calling "maths"). it's in own namespace, class name beingness "math" still conflicts system.math. did solve add together wrapper in system.math library calls system.math function explicitly, , have add
using math = yushatak.libraries.math;
to every file uses math.* functionality. don't sense best way this, , fear wrapping cause overhead, , that's not someplace want overhead either..
advice? there improve way "extend" system.math? bad thought , should go "maths"? suggestions @ all? :p
example of wrapped method:
public static decimal abs(decimal value) { homecoming system.math.abs(value); }
this reply has 3 distinct parts.
while using
statement approach not have overhead aside 1 line in source code, wrapper methods have overhead in number of ways.
system.math
. accurately reproducing wrappers tedious @ best. the performance overhead @ runtime range insignificant severe, depending on how jit handles calls math functions internally. vary both implementation , platform. the compiled code class larger. it harder understand functionality in math class new functionality, , wrapper around existed. all of above can prevented using different strategy.
it mutual practice intentionally avoid name conflict naming new class nameex
, name
original name. example, interested in creating class mathex
.
you can utilize next handle conflicting names.
using math = yushatak.libraries.math; using systemmath = system.math;
this happens in visual studio extension development, in particular classes named constants
, iserviceprovider
.
c# math
No comments:
Post a Comment