SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Addict crabby80's Avatar
    Join Date
    May 2007
    Posts
    387
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Quick question on MVC

    Hi guys

    Part of my application lists all the current members from which you can link to a specific member.

    Would you have a separate view class for each of the views IE;

    controller_members {
    var $view;

    function index() {
    $this->view = new view_members_list_all();
    }

    function byID() {
    $this->view = new view_members_by_id();
    }
    }

  2. #2
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes.

  3. #3
    SitePoint Addict crabby80's Avatar
    Join Date
    May 2007
    Posts
    387
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    quick question quick answer thanks Dr

  4. #4
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "Quick" doesn't always mean "correct", I'm afraid.

    What would be the purpose of having several view classes? You don't need a different class for each template you use, because all templates are handled in the same way.

  5. #5
    SitePoint Addict crabby80's Avatar
    Join Date
    May 2007
    Posts
    387
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so do you just have the one view class then?

  6. #6
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, I don't have a positive answer for you. The question you asked is strongly design-related and in the world of software design there is no place for quick-n-easy yes-or-no answers. Sometimes yes, sometimes no, it depends.

  7. #7
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On what?

    I fail to see how you could in a clean manner, merge two separate views into one, considering that there are two templates. You could put a conditional in the template to use one or the other I suppose but why would you take such an extreme measure as that one?

    Your basically screwed if at some point the business logic changes. For the sake of using a separate class to distinguish those views, your better of doing so. It's not like it's going to break your back, now is it?

  8. #8
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't follow you. What do you mean by this?

  9. #9
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't get this either. You could have separate classes, but sometimes it's as simple as:

    PHP Code:
    controller_members 
    {

        function 
    index() 
        {
             
    $this->view = new Template('view_all_members.tpl');
        }

        function 
    byID($id
        {
             
    $this->view = new Template('view_member_by_id.tpl');
             
    $this->view->id $id;
        }



  10. #10
    SitePoint Addict webaddictz's Avatar
    Join Date
    Feb 2006
    Location
    Netherlands
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston View Post
    Your basically screwed if at some point the business logic changes. For the sake of using a separate class to distinguish those views, your better of doing so. It's not like it's going to break your back, now is it?
    Would you care to eloborate on this? I'm having the same struggle at the moment.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •