About class naming over-simplification

Naming a class as ProductProperties, instead of simply Properties despite the namespace refer it to be in the Product namespace, does NOT defeat the purpose of the namespaces.

Namespaces are supposed to prevent clashes in class naming, to prevent ambiguity at a auto-loading level. They do not prevent ambiguity at a development level.

If at development I see a class named Properties, I will assume it to be Properties. Would any dev go look at the top of the file for the “use bladibla” to make sure about what class it is? I dont think so. However, that Properties class might actually be the ProductProperties, or the CategoryProperties, or something else. So a class name should be as accurate and unambiguous as possible, independently of the namespace.

Bottom line: If its a Properties class, name it Properties, but if it is a ProductProperties class, name it ProductProperties!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s