@aliceif That's up there with the errors you can get in Java when you start really messing around with classloaders; things like (paraphrased) “can't call method; expected class a.b.c.Foo but found class a.b.c.Foo”. The first time you see those things, you totally go but the key is that classes in the JVM aren't just distinguished by name, despite what the errors say…
In my first example, the beetle is even created externally. It is requested.
In my second example, the beetle is explicitly created by the parent.
In neither case should the beetle be injected.
In your case, you should probably inject a factory.
public class Beetle
private SingletonService _service;
public Beetle(SingletonService service)
_service = service;
public class BeetleFactory
private SingletonService _service;
public BeetleFactory(SingletonService service)
_service = service;
public Beetle MakeBeetle()
return new Beetle(_service);
public class CreatorClass
private BeetleFactory _factory;
public CreatorClass(BeetleFactory factory)
_factory = factory;
public void DoStuff()
var beetle = _factory.GetBeetle();
// at composition root
var mainObject = IoC.Resolve<CreatorClass>();
Which makes me wonder: I should really check to see if it still fucks the Task Manager reporting of the current clock speed. Last time I enabled it on my laptop and it claimed I magically got almost triple the GHz...
Why does the idea of parsing an error message to fix it sound familiar... oh, I did that once...
Database-sourced errors in general are nasty to deal with. Entity Framework, for example, just tosses you a SqlException and it's up to you to unwrap all the inner exceptions and cross-reference the magic error numbers to find out what exactly the problem is - whether you've violated a PK, a check constraint, or just had the DB crap itself in a myriad of possible vendor-specific ways.
@dkf That's the thing where my brain went "looks OK-ish to me, but not egregious enough to scream ". That's as far as I got though, been ages since I learned German and I wasn't particularly good even then...
@blakeyrat I forget you haven't seen the lounge thread about this where I explain how much of a mess the code base is.
If disk space actually ran out, it would fail much earlier in the process than my recent changes would, in fact pretty much everything would grind to a halt long before my code. We have a code base, even before you factor the PHP evil into it.
@dkf The complaints you raised sound like something someone would do in PHP is what I meant:
PHP cannot overload methods
PHP functions do this return shit a lot. Like, strpos, given how similar it is to C you'd expect 0 or positive integer if substring found, -1 if not found. Nope! It's boolean FALSE in case it's not found. Many functions do this.
@Tsaukpaetra As long as the service they're supposed to provide is OK, who cares about how ugly their UI is? It's not like it's something that most users need; the people who want that sort of service tend to prefer a no-BS get-shit-done interface.
Leave the anti-parallax scrolling BS for the hipster websites…
@blakeyrat Like all "early" checks, there's no point stability-wise, but there's one comfort-wise, especially when the file not existing is not considered an exceptional condition.
Especially useful if you're using the debugger and don't want to fiddle with the debugger's exception settings to get the one exception that interests you and not the meaningless FileNotFoundExceptions that slow you down despite the file not being supposed to be there... Even more fun if the exception you're looking for is also a FileNotFoundException.
No, you give me one! That's what I've been asking this whole time. The old C# compiler was buggy and made closures in foreaches only ever use the first value unless you introduced a local in the foreach and assigned the current iteration to it. It was definitely buggy and wrong, and it's very unlikely that anyone needed that behavior. About all I can imagine using it for is comparing everything against the first value, but that's still a horribly wrong thing to rely on!
Yeah, so SendMessage doesn't actually return until the dispatched message has been processed
Isn't there a PostMessage() API which plonks the message into a deferred queue and then just gets on with its life, none of this synchronous business? Been several years since I had anything to do with Win32...
Having official toolboxes for every single engineering subsubsubfield that contain every single domain specific function you could ever need.
Canned responses and black boxes are only good for well defined academics and professors. If you want to develop an algorithm, you will end up implementing your own secret sauce and those toolboxes worth shit, only you end up paying many grands for an 80s-era scripting language.
Standards, for this company, and those were due to tradition.
It's largely been forgotten these days, but lower case was rarely used on computers prior (in my experience) to 1978. Card punches were upper case. Unit record equipment was upper case. Printer chains were upper case. For that matter, a lot of video terminals could not do lower case.
I even used a computer (CDC 6400) that had a 6-bit character set that originally included no lower case characters (no space in the code set, which had 64 code points of course). By the time I worked on it, they had enhanced the character set to use 76 octal as a shift to mark 12-bit characters for lower case. Weirdest arrangement ever: the basic characters were six bit because words were 60 bits ... 10 characters to the word, null terminated with a kicker. So in octal, "COYNETHEDUP" was:
Why the extra word? Because the rules said there must be 12 bits zero in a row to terminate a string, octal 0000, so in this example, an extra word is needed. With all that complexity and extra memory requirement, oddly enough they still used upper case a lot.
Imagine if they had changed this thing to do Unicode...
At no point have I argued that C error codes are, or should be, considered boolean. Indeed, my post above doesn't even make sense in that respect, because the return value of (for example) fopen() is not an error code, but
Upon successful completion, fopen() shall return a pointer to the object controlling the stream. Otherwise, a null pointer shall be returned, and errno shall be set to indicate the error.
There you go. Most core functions, due in part C's lousy type system, have to put an error code in the global value errno and somehow flag that the they have done so by returning a nonsense value.