There are several posts and other contents in the internet that claims against naming classes ending with "er" (like manager, controller, helper...). I personally agree with that, but what alternative names could be given to MVC controllers in the scope of web development? I came up with "entry points" or "end points" (like "UsersEntryPoints", for example) but I'm not sure if it reflects exactly what it does.

有帮助吗?

解决方案

The point about avoiding "smurf naming" is not to think of synonyms for "smurf", but to not use the term. So the thinking goes that if you have a user controller in a folder called Controllers, then just call the class User, rather than UserController.

However, the problem with that is then you end up with a User class in views and in controllers and in models, which makes it hard to distinguish between them.

The point about avoiding "er" classes is that they upset hardcore OO folk who see them as a sign of procedural code masquerading as OO code. Just ignore them and they might get bored and go away one day. Seriously; it's an inane argument.

The term "controller" has a special meaning for MVC. The convention for those controllers is to call them thus. So stick to UserController. Readers of your code will thank you for it.

许可以下: CC-BY-SA归因
scroll top