Kohana is my poison of choice at the moment, though I'm still supporting a raft of Laravel 4.2 and CodeIgniter apps. I'd take CoeIgniter as a second if I can't use Kohana and Laravel 5 reluctantly if I have no other choice.
I found Symfony pretty pleasant. Very comparable to doing an ASP.MVC app or whatever the equivalent is in Java land. Very OOP, very good tooling, lots of modules / plugins. Some clunky crap too, and events are hard to debug.
I bet it's a matter of time before someone points out your first conditional and branch is redundant given the second conditional and its branch.
Hush you! I was just trying to keep the code simple while still providing an example of where there was only one conditional statement in the parentheses, which is a case in which I am okay with there being no spaces within or around the parentheses.
And that, kids, is why distinguishing nullable references from non-nullable ones in the type system is a good thing.
I don't see how that would actually affect this. If I understand the code correctly it's attempting to retrieve the member from a service of some kind. Which means that you would have to always have a nullable reference returned from that method, since you could be attempting to retrieve an object that isn't there. The only reason I assume the code says that it should never happen is that the author of the code either assumed that nothing would remove the member between calls, or was assuming some sort of transactional guarantee that is no longer true.
Which is why the error should be a custom exception type, with a description of what's actually wrong. Everything is wrong with the branch of logic that throws this exception.
@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!