Welcome Guest, Not a member yet? Register   Sign In
Libraries or Models, favouritism?
#1

[eluser]Hyra[/eluser]
Hey hey,

So i'm (still) in the progress of porting my existing community site to CI. Big fun (actually, it is, really!)

Although i'm running into some issues and decided to take a step back and think things over.

Currently i'm having 2 issues which, i think, cover all related bottlenecks.

First up .. controllers.

Let's take an example .. At the site people can visit other users and see, for example, their Profile, Gallery and Blog. In return, people can maintain their own Profile and Blog.

Following set of controllers with methods could be used:

For the users (artists) people can visit:
Code:
artist.php -> index() (profile)
           -> blog()
           -> blog_entry($id)
           -> gallery()
           -> artwork($id)
.. more for adding comments on an artwork, comment the profile page, etc. etc.

Then, for the user himself, to maintain his blog:
Code:
my_blog.php   -> index() (profile)
              -> add()
              -> edit($id)
              -> delete()
Many more controllers like above, for maintaining artworks (my_artwork.php) and so on.

Now, this seems, and in fact is, a bit cumbersome. Lots of repetive tasks within the controllers, but for other parts of the site. I.e. add a comment to an artwork, or on a blog entry.

Of course, an option would be to group all those methods into one controller, but this would make the code even less maintainable/overviewable.


Extending on this, there's "issue" number 2: Models or Libraries.

Let's take the blog entries as the same example. Would it be wise to create a library "blog" which has methods for just about anything? Meaning: create an entry, handle editing and comments by other visitors, etc. Or would that classify as a model. Or even a combination? I'm not sure what the best way to go is.

I'm finding it hard to define the difference between a model and a library other than what i can find throughout the documentation that a model would handle all the database actions, and a library is used for (complicated) tasks. But this would mean I would have to go with a combination of the 2, ending up with:

controller my_blog.php
library blog.php which handles business logic called from the controller
model blog.php (in fact not possible due to name conflicts) which handles database actions.

A library could do both database and "thinking" tasks, thus making the model obsolete. But .. wouldn't this be wierd?


So yes, I'm rambling now Smile

I could do with a chatroom on IRC (alas, the ports are closed at work) or someone to MSN with to discuss these things. Or maybe someone can make sense of the above and give me some pointers?


Messages In This Thread
Libraries or Models, favouritism? - by El Forum - 02-25-2008, 08:28 AM
Libraries or Models, favouritism? - by El Forum - 02-25-2008, 10:41 AM
Libraries or Models, favouritism? - by El Forum - 02-25-2008, 10:46 AM
Libraries or Models, favouritism? - by El Forum - 02-25-2008, 02:59 PM
Libraries or Models, favouritism? - by El Forum - 02-25-2008, 04:54 PM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 01:33 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 01:43 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 02:13 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 02:24 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 03:05 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 03:20 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 03:34 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 03:42 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 03:50 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 04:26 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 08:08 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 08:40 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 10:23 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 10:33 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 11:34 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 01:01 PM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 01:41 PM
Libraries or Models, favouritism? - by El Forum - 03-29-2008, 10:14 PM
Libraries or Models, favouritism? - by El Forum - 03-29-2008, 10:26 PM
Libraries or Models, favouritism? - by El Forum - 03-29-2008, 10:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB