Welcome Guest, Not a member yet? Register   Sign In
Why should I write a library rather than a helper?
#1

[eluser]surfgatinho[/eluser]
I have a few functions that I need to call from various controllers. I have previously written helper for such functions, e.g. to create a dynamic menu.

Now I'm wondering what reasons I'd want to write a library rather than a helper (except to keep the code more OO)?
#2

[eluser]OES[/eluser]
I was told to think of it this way.

If you have one off functions then helpers do the trick like you have said. But lets say you building a app eg a Calander.

It would make sense to add all functions in one library for the calendar. You just have to look at CI Librarys. All functions are for the same thing.

Hope that makes sense!
#3

[eluser]surfgatinho[/eluser]
Thanks for the reply. I think my case might be borderline so it's not going to matter much either way.
I may go for a library just to be puritanical and keep it all OO
#4

[eluser]Rick Jolly[/eluser]
Rule of thumb: If you can use a helper, then do. Only when a helper won't work (you need instance variables), should you use a library.




Theme © iAndrew 2016 - Forum software by © MyBB