Re: static class inheritance, generalized
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Fri, 8 Jun 2007 19:08:49 +0100
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
.
- Follow-Ups:
- Re: static class inheritance, generalized
- From: Frans Bouma [C# MVP]
- Re: static class inheritance, generalized
- References:
- static class inheritance, generalized
- From: Ben Voigt [C++ MVP]
- Re: static class inheritance, generalized
- From: Frans Bouma [C# MVP]
- Re: static class inheritance, generalized
- From: Christof Nordiek
- Re: static class inheritance, generalized
- From: Frans Bouma [C# MVP]
- Re: static class inheritance, generalized
- From: Ben Voigt [C++ MVP]
- Re: static class inheritance, generalized
- From: Frans Bouma [C# MVP]
- Re: static class inheritance, generalized
- From: Jon Skeet [C# MVP]
- Re: static class inheritance, generalized
- From: Frans Bouma [C# MVP]
- static class inheritance, generalized
- Prev by Date: Re: Casting to double in C#
- Next by Date: Re: MSDN help in in pdf/doc format?
- Previous by thread: Re: static class inheritance, generalized
- Next by thread: Re: static class inheritance, generalized
- Index(es):
Relevant Pages
|
Loading