c# - Instance vs Static methods for multiple variable methods -
If you have a Point3 class and the distance is a method , Should you be stable like this:
point 3 Distance (P1, P2); Or as an example method:
this.Distance (p); I know that legacy and overriding can be correct by using static methods?
Which is better, and why?
I like the stable version. (And we have done something across the board in Slimdex, save for some "special" tasks.) The reasoning is that distance is an approximation of a function that processes two points, and the result is. You are not running "distance" operation on P1 as value.
In short, I think that there is a practice to force the example of examples to force a particular example. For some, it goes in any way. For example, in SlimDeX both the stable and nonstandard version of the vector 3 normal function are included because both constructions are quite easy. For example, one modifies its object, and gives a new one steady.
[edit] Another answer mentions a "distance" function which will be an example ceremony. Although it is not necessarily inappropriate, it is a design direction that makes me uncomfortable. The problem is orthogonity. Once you add more weight to these - some static, some examples, maybe in some mathhalper class, who knows - you end up with more ways to do the same thing, library complexity, test complexity Bad news for bug area, etc. We have chosen to place it in places in Slimdex, but this has been done in many sections (and each team has been reviewed). It can help to the extent of the usefulness of a library, but ending on the wrong side of the line is really dangerously easy.
Comments
Post a Comment