Re: static class inheritance, generalized
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Sat, 9 Jun 2007 17:11:33 +0100
Frans Bouma [C# MVP] <perseus.usenetNOSPAM@xxxxxxxxx> wrote:
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.
Sure, though if the language has the construct of static methods, the
class name becomes part of the method name (IMHO), in such a way that
the scope in which the method operates is described by the class name
so it's not necessary to add that description in the method name itself.
FOr example, String.Copy(). It's a static method. Using the proposed
mechanism, I end up with code like:
myVar = Copy(myOtherVar);
Only if you abuse the feature though. There's nothing to force you do
static using System.String;
and indeed I wouldn't recommend it.
In a procedural language, one wouldn't use 'Copy'. One would use
CopyString() for example as it copies a string. But because the method
is statically defined on String, CopyString is redundant, Copy is
enough information, as 'String' is already specified.
Right - so where it's not clear, you don't use the feature.
<snip>
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.
We use a similar API, to get compile time checked queries (without
having Linq around ;)). Like:
IPredicate p = (CustomerFields.CompanyName == "BigCorp Inc");
The perfect DSL for querying is SQL, it's however set oriented, not
procedural nor OO. That friction has to be overcome somehow, if you
want to specify what you want in C# if you can't use SQL. IMHO the same
with mathematical procedures in an OO environment. Cutting up the
target language to become a language for another paradigm is IMHO
making the language very weak and open for abuse. Better is to enable
interoperability in a transparent form so you can write a complex
formula in the DSL which does that best, evaluate it with that DSL and
refer to the result in normal C#. And back, refer to values in the C#
program in the formula.
In this case it doesn't make the language "very weak" but enables a
fluent interface which reads quite naturally. (It doesn't particularly
read like SQL, but that's okay.)
It would get you what you want, and in the best possible form. However
I'm not sure if we'll see it in a short timeframe in C#, unless things
like JRuby will get that much traction that MS has to act upon it. (For
the JRuby impaired readers: JRuby is an enviroment which allows you to
write ruby code and java code and let them interoperate on eachother:
call java code from within ruby, call ruby code from within java and
refer to elements living in the other language space).
Have you not heard about DLR and IronRuby?
http://blogs.msdn.com/hugunin/archive/2007/04/30/a-dynamic-language-
runtime-dlr.aspx
http://www.iunknown.com/2007/04/introducing_iro.html
--
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]
- 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: Getting the default printer in 64-bit Vista
- Next by Date: Re: Getting the default printer in 64-bit Vista
- Previous by thread: Re: static class inheritance, generalized
- Next by thread: Re: static class inheritance, generalized
- Index(es):
Relevant Pages
|