CodeIgniter Forums

Full Version: Can I duplicate class names?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]kimp[/eluser]
Hi,

I'm aiming to use the full MVC pattern, and adhere to the DRY principle.

I've got several different types of users including Public and Admin, and I've set up a directory for the controllers for each user type.

In some cases I want them to be able to do similar - but not identical - things. For example, in the case of user CRUD:

- Public can Add a user; while
- Admin can Add, List, Edit and Delete users.

I would like to name the controllers (and therefore the classes) the same. i.e.:

- controllers/public/users.php
- controllers/admin/users.php

Does this violoate any design principles?

I am making the controllers as light as possible, so any duplication (and DRY violation) will be minimal.

Your comments are much appreciated!

Kim

El Forum

[eluser]danmontgomery[/eluser]
They can be named the same thing, they just can't both be instantiated at the same time.