Welcome Guest, Not a member yet? Register   Sign In
how do you organise your code so you can re-use things?
#2

[eluser]Sumon[/eluser]
Lets say we have two controller named song and composer.Moreover, both have different properties and functionalities. so that we have a number of different methods for song and composer. In addition, song and composer have different model as well(to handle database operations).

Well at this point lets think, we need a list of songs by singer SUMON in performance controller. so what we should do? if we use song model then we have only data from database without having good amount of logics. But if we call song::SongsByArtist('SUMON') function then it cotain data with some logic applied.

Make sure you have not call any view file in SongsByArtist() function. This function only read data from database and apply some logic and return some data.

Finally pass these values into your view. Same approach can be applied by you for view file. Break down the main view file into sub views and then pass necessary values into sub view.

I am also looking for a better reply then mine.


Messages In This Thread
how do you organise your code so you can re-use things? - by El Forum - 09-14-2008, 01:11 AM
how do you organise your code so you can re-use things? - by El Forum - 09-14-2008, 02:54 AM
how do you organise your code so you can re-use things? - by El Forum - 09-14-2008, 03:27 AM
how do you organise your code so you can re-use things? - by El Forum - 09-19-2008, 12:27 AM
how do you organise your code so you can re-use things? - by El Forum - 09-19-2008, 07:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB