Welcome Guest, Not a member yet? Register   Sign In
OOP Best practice tips? :)
#1

[eluser]Unknown[/eluser]
Hi Guys,

I'm new to CI and new to OO programming, but am having a very smooth and enjoyable experience putting it all together in codeigniter... love it!

Just a question about Object oriented programming and instantiation practice...


OK So I'm coding a task management app..

I have objects setup in libraries like user, task, task items etc..

I am just wondering, how MUCH of that should I instantiate in one go? For example; My user object (on construct) will then instantiate objects for all the tasks for that user, those tasks will also instantiate their associated items etc..

Which is great, because then I get a massive multi-dimensional array which I can pass and create a whole series of views based on that data.

Is this good or bad practice? because it means that upon visiting the site, the server will basically BUILD the user in it's entirity with everything belonging to them. Is that a waste of resources?

Or should I JUST build the user? then have a "getjobs" function for getting the jobs for that user ONLY when required?

Also, if I DO instantiate everything in one go as I previously said... is there a way of keeping this in the session or memory? Because otherwise I'll have to create this massive USER object everytime the user hits a different URL (controller) on the site.

Really appreciate any info Smile

Ta!




Theme © iAndrew 2016 - Forum software by © MyBB