I see it quite regularly, maybe it’s even some sort of code style. I’m talking about the AppDelegate class that is found in every iPhone App. It’s a generic class that gets notifications such as resuming the App after a phone call or simply notifying when the App has finished starting up.
So why is it then that people name their AppDelegate class “MyCoolProjectAppDelegate”? I think this is bad practice. Your app delegate has nothing to do with your project in particular (or at least it shouldn’t have). I can only recommend to name it simply “AppDelegate” from now on. Once you switch projects you’ll thank me for it.
The rationale behind it is very simple: usually you start programming one app, then you make another, or a derivative work of that. And so on and so forth. In most cases you’ll just copy the project and continue using it. Unless you are very disciplined you’ll find yourself on your fourth or fifth application whose AppDelegate class is still called “MyCoolProjectAppDelegate”. Some old, long gone project you might not even have completed. Still, that name sticks around because the app delegate class is imported in so many source files you did not want to bother going back and changing all those lines of code.
The AppDelegate is not specific to your App, it serves a common purpose across all your apps. Hence you do not want to give your app delegate your project’s or any specific name unless you need to have several in your project for some reason. And if you’re not convinced about project re-use – keep in mind that most projects will change their name sooner or later during development, at least one significant name change is quite common in any project.
This advice also goes for almost every class, method or variable that you will ever create. Do not use your project’s name in your code, the more generic the class, method or variable is the less likely it should be considered to be named after your project’s name. The only exception should really be things that are absolutely undeniably specific to your current project, such as the flux compensator debugging overlay analytics module. You can name that “BackToTheFutureDebuggerOverlay” if you wish because it is so special and will never be used again.
Or will it?






Gaming Horror - 






Or could it just be that the XCode new project template automatically prefixes the AppDelegate with the project name and no-one can see a great reason to change it?
Could be. I don’t use that, so i didn’t even know it does that.