views:

31

answers:

0

Aim

To implement a proper and efficient view architecture for my project (with maximum reuse of repeated units)

About my project

My project involves classes taken by tutors and packs published by tutors. No framework has been used but object orientation and class hierarchies are present for model, controller part.

I have the following modules -

  1. Search->Class listings - list of classes displayed in search results.
  2. Student room->Class listings - List of classes a student has purchased

  3. Search->Class Details - Details page of a class in search module

  4. Student room->Class Details - Details page of a class in Student room

and similarly for packs -

  1. Search->Pack listings - list of packs displayed in search results.
  2. Student room->Pack listings - List of packs a student has purchased.

  3. Search->Pack Details - Details page of a pack in search module

  4. Student room->Pack Details - Details page of a pack in Student room.

My current plan

I am planning to have classes like these:-

Class Name                               Contents



commonListingDisplay                     paginationHtml()
                                         smallRatingHtml()
commonDetailsDisplay                     commentsHtml()
                                         largeRatingHtml()

commonClassPackListingDisplay extends commonListingDisplay   
                                         abbreviatedDetailsHtml()

                                         (abbreviated  class/pack                    
                                          details html (class/pack details
                                          ending with ... and a link to the
                                          Class/pack details page).

commonClassPackDetailsDisplay extends commonDetailsDisplay
                                         currently empty

commonClassDisplay                       classDateTimeHtml()
                                         classReminderHtml()

classDetails extends commonClassPackDetailsDisplay,commonClassDisplay

Now taking the example of a module - While in Search->Class details- - From the search_class_details.controller.php file, initiate an object of class classDetails, so all the reusable functions are accessible. - Pass all the variables and the classDetails object to a class_details.view.php (which is the view file of class_details module). The file will look something like:-

<div class="class_details">
<h2><?php echo $className ?></h2>
<div><?php echo $classDetails ?></div>
<?php  $classDetailsObj->largeRatingHtml($ratingValue) ?>

<?php $classDetailsObj->commentsHtml($commentsArray) ?>

</div>

How does the approach look like? Suggestions from experienced people wanted.

Thanks