CodeIgniter Forums
Can I duplicate class names? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Can I duplicate class names? (/thread-32931.html)



Can I duplicate class names? - El Forum - 08-09-2010

[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


Can I duplicate class names? - El Forum - 08-10-2010

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