Welcome Guest, Not a member yet? Register   Sign In
Grouping up functions for controllers and models.
#4

(10-23-2019, 11:37 PM)dweenator Wrote: This is because i have other projects that i completely abandoned because i couldn't get into them after i stopped for awhile and have a look at my project that is messy(in my opinion) that i would rather restart the whole thing from the groundup than to continue them.

Smile We have all been there!

I have one hobby project that I have written and rewritten about five times now. Still cannot get it right.

The division of what goes in a model or a library, or what purpose your model or library is actually for, is quite an art form. Very much like database design. Get your tables wrong at the outset and your queries can become a nightmare. Get your libraries or models wrong, and your code becomes a mess.

In your example everything is part of a story, so your 'Story' library could contain everything. I would have a story library for creating new stories, getting stories, listing stories, etc. Anything at a 'Story' level. Then a chapters library for getting chapters for a story, adding chapters, reading chapters, editing chapters etc. Anything at a chapter level.

You could have a reading_library, an editing_library and a creation_library too. Then have a chapters model and a stories model that these libraries use.

There are lots of ways to do anything, it all depends on your plans and ambitions.

Good luck with it though, there is no 'right' answer.

Paul
Reply


Messages In This Thread
RE: Grouping up functions for controllers and models. - by PaulD - 10-24-2019, 04:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB