Welcome Guest, Not a member yet? Register   Sign In
Model / Controller names
#1

[eluser]parrots[/eluser]
Hi all. I'm just getting started with CI for my newest projects and so far it's been wonderful. I had a question for everyone though, with regards to how they structure their applications, specifically large ones.

I'm planning on using the active record setup for databases found on the wiki for my next (much larger) project. This requires (or at least encourages) one to name the models the singular name of their database tables. Which means, for example, "Page", "Story", etc.

Now, I had been naming my controllers something similar: "/administration/stories" or "/administration/stories/edit/12" (administration is a folder, stories is a controller, to ensure I don't have an "administration" controller that's huge) and so on. However, sometimes the singular and plural of the name can be the same (ex "art"). If I name both the controller and the model "Art", obviously I get an error since I have two active classes are named the same thing. For the controller I can name it "artwork" or something, but I wanted to see how else people have approached this.

Here is my current layout strategy for one site (trimmed for your reading pleasure):

Code:
application/
    controllers/
        administration/
            artwork.php (methods:edit, delete, view all)
            stories.php (methods:edit, delete, view all)
            welcome.php (methods:login, logout, main admin page)
        artwork.php (methods:view all, show individual)
        stories.php (methods:view all, show individual)
        welcome.php (homepage)
    models/
        administrators.php
        art.php
        stories.php
    views/
        administration/
            artwork/
                all.php
                delete.php
                edit.php
            stories/
                all.php
                delete.php
                edit.php
            login.php
            logout.php
            home.php
        artwork/
            all.php
            view.php
        stories/
            all.php
            view.php
        home.php

I haven't seen much in the way of best practices for controller/view/model layout when you have an admin section, active recod models and the likes, so I was just wondering what everyone else has found works best, with large projects especially. I'd like to avoid going crazy as this site grows Wink


Messages In This Thread
Model / Controller names - by El Forum - 09-28-2007, 10:44 AM
Model / Controller names - by El Forum - 09-28-2007, 10:58 AM
Model / Controller names - by El Forum - 09-28-2007, 12:15 PM
Model / Controller names - by El Forum - 09-28-2007, 09:13 PM
Model / Controller names - by El Forum - 10-02-2007, 07:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB