c# - Is wrapping System.Math a bad idea? -


I have my Math library and I call it "mathematics" (I call it "mathematics"). It's in its own name space, but the class name "Math" is still a struggle with the system. Math What I did to solve it, to add the cover for everything in the system. That's just the system in my library. The Math function explicitly calls, and then I have to add

  to use Math = Yushuite .Libraries.Math;  

In every file that uses math. * Functionality I do not think that is the best way to do this, and I also fear that wrapping will cause additional upper part, and there is nothing like where you want it upwards ..

Advice? Is there a better way of "extension" system? Math? Is this just a bad idea and should I go back to "math"? Any suggestions at all? : P

Example of the wrapped method:

  Public Fixed Decimal ABS (decimal value) {return System.Math.Abs ​​(value); }  

This answer is now in three separate parts.

While the use of the Usage statement approach is no different from an additional line in your source code, the wrapper method will overhead in several ways.

  1. There are a large number of methods in system.Math . Certainly it would be best to reproduce wrappers.
  2. The performance overhead at runtime can be from asynchronous to severe, depending on how JIT has internally called math functions, according to both the implementation and the platform can vary. .
  3. The compiled code for your class will be large.
  4. It will be difficult to understand which functionality is new functionality in your math class, and which is a cover around some of the things already present.

All of the above can be stopped using a different strategy.


This is quite common, to avoid name conflict deliberately my name is new class NameEx , where name is the original name for example , You are interested in creating class MathEx


You can use anything like the following to handle disputed names.

  Math = Yusutac Libraries Use of Math; Using SystemMath = System.Math;  

It often occurs in Visual Studio extension development, especially constant and IServiceProvider with named sections.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -