Re: static class inheritance, generalized



Frans Bouma [C# MVP] <perseus.usenetNOSPAM@xxxxxxxxx> wrote:
Do you really have no idea, in real life rather than in theory?
Would you not guess that it was in System.Math, given no other
information, and considering the context?

I don't want to 'guess', Jon. That's the whole point. Of course, any
math method likely will be in Math, though the world is bigger than the
set of methods in Math. Of course, with 'Sqrt' it's pretty obvious
where that method might be located, however Validate(myCustomer) is a
bit less clear.

Which is why it would be a bad idea to use it for Validate.

Here's another example, without changing anything. If I write a method
called "DoSomething" then wherever I use it, I've either got to guess
what it does or consult the documentation (which would usually be via
Intellisense).

What's my answer to this? Naming methods sensibly.

So, IMHO the example you're pushing is actually an incredibly narrow
scope, but the feature required to use that example as discussed won't
be used solely for very narrow scoped methods, but for a lot more
methods. I then say: it will give more problems than it solves.

To which I say: only if used incredibly stupidly.

We apparently view clarity differently. If I'm working on something
which I know from the context uses trigonometry, then formulae which
just have things like:

double x = Pow(Sin(alpha)+Cos(theta), 2);

have more clarity for me than formulae such as:

double x = Math.Pow(Math.Sin(alpha)+Math.Cos(theta), 2);

Sure, though is that in general the case with any random method, or is
it just more clear because the methods in the example are clearly math
related routines so there could be just one place where they'd be
located?

It's because it's clear, certainly - and I wouldn't recommend using it
in any cases *other* than where it's clear.

Have you read much C# code that requires extensive use of System.Math?

No, last time I did geometry related code was in C++ some years ago.

I suspect you'd be more in favour of the feature if you had had to
experience the nastiness which requiring "Math." presents.

It's horrible currently, and would greatly benefit from this. The
ambiguity due to the possibility of Cos/Sin/Pow etc is greatly
dwarfed by the guaranteed extra cruft of having to prefix everything
with "Math".

In THIS particular example, I see your point, but IMHO it's also the
only example or perhaps one of the very few examples which would make
this feature worth having. IMHO, what the cause of this problem is is
that a piece of logic has to be formulated in language L1 which uses
paradigm P1, but the piece of logic is far better expressed in language
L2 which uses paradigm P2. Because L1 is the language of choice, the
logic has to be written in a way which is less expressive.

Absolutely. But this feature would help things enormously.

I.o.w. a way to have any DSL D inside C# and where context awareness
is possible inside D and C# would be very welcome. But that's not going
to happen, see the way how they added Linq instead of adding a DSL
awareness and WITH that Linq. That same DSL awareness then would have
given you the ability for formulate the formulas in a language much
more expressive for that than C# and at the same time wouldn't butcher
C# with features which are actually a big burden for a lot of other
situations than the situation it would be handy for.

Well, the situation I was thinking of is actually Hibernate and its
Criteria API, but I can't find the page that gives a nice example at
the moment.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Re: Cantors Theory: Mathematical creationism
    ... Science is just another religion in that sense in that it's just another ... It came from mathematics. ... a big part of the foundation of math. ... what is said with language? ...
    (sci.math)
  • Re: ? understanding the world by math
    ... to the behavior of the math beyond sign three. ... In what way can an algebraic system "contain" a "spacetime ... to accept the polysign numbers snipped] ... You Mariano insist on applying the old language to a new language and ...
    (sci.math)
  • Re: Relative merits of Lisp-1 vs. Lisp-2?
    ... If reading data that might be ill-formed, defining your language to ... to dismiss my concern about this issue as irrelevant and unimportant, ... This argument would apply to *any* proposed new feature, ... incompatibilities were simply the result of someone doing something ...
    (comp.lang.lisp)
  • Re: Graphic GUI C
    ... features in C99) is also a feature of C++. ... expect the C language and the C standard library to do everything; ... nothing is more commonplace than the need for one or more libraries in ... The same is true inside of WSH where all of the functionality ...
    (comp.lang.c)
  • Re: Cantors Theory: Mathematical creationism
    ... language to correctly explain yet. ... about any language you can create to explain what the mind is doing can be ... SATs, I scored 780 in math, but only 450 on verbal. ... So when I started to think more about this business of Cantor recently, ...
    (sci.math)

Loading