Why do I listen to my sleep coding self?
-
In bed last night, I dreamt a wonderful improvement to the design of some software I'm working on. It would clean it up, move the code into it's appropriate classes, make it all beautiful. So I have just coded it. Or at least, I coded 3/4 of it. That was the point when I thought "Hang on a moment, you can't have
abstract static
methods in C#". :doh: Bugger. Note to self: don't listen to me when I'm sleepy. Anyone else done this? Constructed a massive edifice of beautiful code in your mind, only to find when you have got sufficient caffeine in your system that it has a fatal, fundamental, flaw?Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
-
In bed last night, I dreamt a wonderful improvement to the design of some software I'm working on. It would clean it up, move the code into it's appropriate classes, make it all beautiful. So I have just coded it. Or at least, I coded 3/4 of it. That was the point when I thought "Hang on a moment, you can't have
abstract static
methods in C#". :doh: Bugger. Note to self: don't listen to me when I'm sleepy. Anyone else done this? Constructed a massive edifice of beautiful code in your mind, only to find when you have got sufficient caffeine in your system that it has a fatal, fundamental, flaw?Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
-
In bed last night, I dreamt a wonderful improvement to the design of some software I'm working on. It would clean it up, move the code into it's appropriate classes, make it all beautiful. So I have just coded it. Or at least, I coded 3/4 of it. That was the point when I thought "Hang on a moment, you can't have
abstract static
methods in C#". :doh: Bugger. Note to self: don't listen to me when I'm sleepy. Anyone else done this? Constructed a massive edifice of beautiful code in your mind, only to find when you have got sufficient caffeine in your system that it has a fatal, fundamental, flaw?Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
Never happened to me (YET), however, what has happened and more frequently that what I would like is to spend an entire day trying to fix something to no success but the minute I step outside, I know the answer :doh:
-
It's actually a reasonable concept if you allow static inheritance (i.e. static virtual in C# speak), and that's a really useful concept that is missing in C#. How many times have you had to create an instanced service class, even though it has no state (so should be static), because you can't have static members in an interface or virtual static members in a base class?
-
Never happened to me (YET), however, what has happened and more frequently that what I would like is to spend an entire day trying to fix something to no success but the minute I step outside, I know the answer :doh:
That's actually part of why I spend time here: it breaks my concentration on a problem and lets me think about other things. That means I don't get "fixated" on "this must be why" and my subconscious is free to "bing" me and say "Try this, not that". Improves my creativity no end, just not concentrating on a problem! :laugh:
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
-
That's actually part of why I spend time here: it breaks my concentration on a problem and lets me think about other things. That means I don't get "fixated" on "this must be why" and my subconscious is free to "bing" me and say "Try this, not that". Improves my creativity no end, just not concentrating on a problem! :laugh:
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
I agree and I try to do something similiar at times, trying to find a distraction but that would still be related to work, just to "unfocus" while still focused :-D But not always seen w/ good eyes around here :sigh:
-
It's actually a reasonable concept if you allow static inheritance (i.e. static virtual in C# speak), and that's a really useful concept that is missing in C#. How many times have you had to create an instanced service class, even though it has no state (so should be static), because you can't have static members in an interface or virtual static members in a base class?
0 times. I've wished that interfaces could contain static methods so that T.someFunction could exist for generics (constrained to that interface), but that's a completely separate issue. (that can't work in C# of course) How is "static virtual" even a reasonable concept? No instance = no vptr = no dynamic dispatch.
-
I agree and I try to do something similiar at times, trying to find a distraction but that would still be related to work, just to "unfocus" while still focused :-D But not always seen w/ good eyes around here :sigh:
:laugh: I work for myself, so I give myself special permission to "goof off". :laugh:
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
-
0 times. I've wished that interfaces could contain static methods so that T.someFunction could exist for generics (constrained to that interface), but that's a completely separate issue. (that can't work in C# of course) How is "static virtual" even a reasonable concept? No instance = no vptr = no dynamic dispatch.
You're thinking too much about the C++ style implementation. There's actually no reason why you can't have vtable entries for static methods, though, even using that model – they'd just get passed nothing for the instance parameter. You just have to choose a different way of determining the type that should get dispatched, instead of using the instance's dynamic type, for example the declaration type of the method which was originally called. Delphi goes some way towards this but it doesn't really work well because it doesn't sort out the dispatch properly.
-
In bed last night, I dreamt a wonderful improvement to the design of some software I'm working on. It would clean it up, move the code into it's appropriate classes, make it all beautiful. So I have just coded it. Or at least, I coded 3/4 of it. That was the point when I thought "Hang on a moment, you can't have
abstract static
methods in C#". :doh: Bugger. Note to self: don't listen to me when I'm sleepy. Anyone else done this? Constructed a massive edifice of beautiful code in your mind, only to find when you have got sufficient caffeine in your system that it has a fatal, fundamental, flaw?Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
Well, sorry to say this to you, but you don't get paid for work done in your sleep, and theres a good reason for that :laugh:
-
That's actually part of why I spend time here: it breaks my concentration on a problem and lets me think about other things. That means I don't get "fixated" on "this must be why" and my subconscious is free to "bing" me and say "Try this, not that". Improves my creativity no end, just not concentrating on a problem! :laugh:
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
OriginalGriff wrote:
That means I don't get "fixated" on "this must be why" and my subconscious is free to "bing" me and say "Try this, not that".
And that's how I defend smoking a pack a day :laugh:
The console is a black place
-
In bed last night, I dreamt a wonderful improvement to the design of some software I'm working on. It would clean it up, move the code into it's appropriate classes, make it all beautiful. So I have just coded it. Or at least, I coded 3/4 of it. That was the point when I thought "Hang on a moment, you can't have
abstract static
methods in C#". :doh: Bugger. Note to self: don't listen to me when I'm sleepy. Anyone else done this? Constructed a massive edifice of beautiful code in your mind, only to find when you have got sufficient caffeine in your system that it has a fatal, fundamental, flaw?Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
Usually the code I dream about is good but occasionally I waste time on a bomb, depends what I had been drinking the night before? :)
If first you don't succeed, hide all evidence you ever tried!
-
You're thinking too much about the C++ style implementation. There's actually no reason why you can't have vtable entries for static methods, though, even using that model – they'd just get passed nothing for the instance parameter. You just have to choose a different way of determining the type that should get dispatched, instead of using the instance's dynamic type, for example the declaration type of the method which was originally called. Delphi goes some way towards this but it doesn't really work well because it doesn't sort out the dispatch properly.
BobJanova wrote:
There's actually no reason why you can't have vtable entries for static methods
Ok fair enough, obviously you can put anything in there, including random bytes, but that then brings us to:
BobJanova wrote:
You just have to choose a different way of determining the type that should get dispatched, instead of using the instance's dynamic type,
I don't really see any options there, but that might be because I don't understand exactly what you mean by this:
BobJanova wrote:
the declaration type of the method which was originally called.
-
Usually the code I dream about is good but occasionally I waste time on a bomb, depends what I had been drinking the night before? :)
If first you don't succeed, hide all evidence you ever tried!
Quote:
I waste time on a bomb
Perhaps this is an indication of a flatulence problem in your sleep? :laugh:
-
OriginalGriff wrote:
That means I don't get "fixated" on "this must be why" and my subconscious is free to "bing" me and say "Try this, not that".
And that's how I defend smoking a pack a day :laugh:
The console is a black place
That's what I used to do - take a cigarette break every hour. When I gave up, I realized I wasn't getting as much work done, because I wasn't taking a break! :laugh: So rather than take up smoking again (and having seen the price they are charging for them these days, I can think of much, much better things to do with the money) I take a break without the cancer-stick.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
-
Quote:
I waste time on a bomb
Perhaps this is an indication of a flatulence problem in your sleep? :laugh:
Kenneth Haugland wrote:
Perhaps this is an indication of a flatulence problem in your sleep?
When I can't sleep I don't count sheep I count... :)
If first you don't succeed, hide all evidence you ever tried!
-
BobJanova wrote:
There's actually no reason why you can't have vtable entries for static methods
Ok fair enough, obviously you can put anything in there, including random bytes, but that then brings us to:
BobJanova wrote:
You just have to choose a different way of determining the type that should get dispatched, instead of using the instance's dynamic type,
I don't really see any options there, but that might be because I don't understand exactly what you mean by this:
BobJanova wrote:
the declaration type of the method which was originally called.
Ok so let's have an example.
public static class BaseService {
public static void LoadData() {
Console.WriteLine(GetDataSource());
}protected virtual static string GetDataSource();
}public static class FileService : BaseService {
protected override static string GetDataSource() { return "file.dat"; }
}public static class DatabaseService : BaseService {
protected override static string GetDataSource() { return "database"; }
}... and calling code
void Run() {
DatabaseService.LoadData();
FileService.LoadData();
}This would print "database" and "file.dat", because the class used for the vtable lookups would be taken from the data type used for the call (i.e. DatabaseService.LoadData). That would be resolved at compile time and based on the static declaration type used in the call, not dynamic object type lookups as with instance dispatch. A related good idea is the ability to pass service classes around and dispatch off them:
void Run(Class<BaseService> service) {
service.LoadData();
}... called like Run(DatabaseService) which would bake in the type for dispatch.
-
Ok so let's have an example.
public static class BaseService {
public static void LoadData() {
Console.WriteLine(GetDataSource());
}protected virtual static string GetDataSource();
}public static class FileService : BaseService {
protected override static string GetDataSource() { return "file.dat"; }
}public static class DatabaseService : BaseService {
protected override static string GetDataSource() { return "database"; }
}... and calling code
void Run() {
DatabaseService.LoadData();
FileService.LoadData();
}This would print "database" and "file.dat", because the class used for the vtable lookups would be taken from the data type used for the call (i.e. DatabaseService.LoadData). That would be resolved at compile time and based on the static declaration type used in the call, not dynamic object type lookups as with instance dispatch. A related good idea is the ability to pass service classes around and dispatch off them:
void Run(Class<BaseService> service) {
service.LoadData();
}... called like Run(DatabaseService) which would bake in the type for dispatch.
-
:laugh: I work for myself, so I give myself special permission to "goof off". :laugh:
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
Lucky you! Allowed to give yourself some special permissions :laugh:
-
Lucky you! Allowed to give yourself some special permissions :laugh:
The down side is the Christmas party is a little lonely... ;)
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)