SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist perpetual_dream's Avatar
    Join Date
    Nov 2005
    Location
    Jerusalem
    Posts
    542
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is 3-tier architecture = MVC?

    Hello,

    Since nobody has so far answered my long thread questions , I thought it would be best to break my questions into pieces:

    1- Is 3-tier architecture= MVC ?

    M = DL

    V = Presentation / UIL

    C = Business Layer

    2- I don't want to use any of the application frameworks .... Can I start my own project by following a 3-tier architecture?

    P.N: I welcome any replies on my original thread.

    Thanks
    Tanzeelnet - Best arabic downloadsite
    Linux Hosting |Free Downloads |

  2. #2
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by perpetual_dream View Post
    Hello,

    Since nobody has so far answered my long thread questions , I thought it would be best to break my questions into pieces:

    1- Is 3-tier architecture= MVC ?

    M = DL

    V = Presentation / UIL

    C = Business Layer
    No. For an explanation why they are not the same things, see the following links.

    http://forums.asp.net/p/1020216/1379168.aspx

    http://en.wikipedia.org/wiki/Three-tier_(computing)
    http://en.wikipedia.org/wiki/Model-view-controller

    Quote Originally Posted by perpetual_dream View Post
    2- I don't want to use any of the application frameworks .... Can I start my own project by following a 3-tier architecture?
    Yes.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Paraphrasing wikipedia :

    In 3-tier the link between layers is linear, whereas in mvc it is triangular.

    I like that one. Thanks for the link.

  4. #4
    SitePoint Evangelist perpetual_dream's Avatar
    Join Date
    Nov 2005
    Location
    Jerusalem
    Posts
    542
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I personally cannot still see the difference between MVC & ntier architecture. What I have found out that the model in MVC contains both the business and database tiers and that the View can communicate with database layer (through the model) directly in an MVC architecture.

    2- Does usage of 3tier architecture means that I am using OOP?

    3- Can someone present me an example which implements the three tier architecture in PHP. Let's say I have a class student with the fields ID and Name. I want to enter the student ID and Name through a web form and save it to the database. Could someone show me or provide me with a link to a PHP code example which shows the usage of the presentational, business and database layer in such a sitauation?

    Thanks
    Tanzeelnet - Best arabic downloadsite
    Linux Hosting |Free Downloads |

  5. #5
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Read the content of the links thoroughly. Then you will know the difference.

    OOP isn't defined by using a certain technique (other than OOP, of course). MVC can be used procedurally or object-oriented, however the latter is the most elegant by far.

    OOP is just creating objects based on classes you've written.

    i.e.
    PHP Code:
    class Person{
        Protected 
    $Name$Age;
        Public Function 
    __Construct($Name$Age){
            
    $this->SetName($Name);
            
    $this->SetAge($Age);
        }
        Public Function 
    SetName($Name){
            
    $this->Name $Name;
        }
        Public Function 
    SetAge($Age){
            
    $this->Age $Age;
        }
        Public Function 
    SetName($Name){
            Return 
    $this->Name;
        }
        Public Function 
    GetAge($Age){
            Return 
    $this->Age;
        }
        Public Function 
    __toString(){
            return <<<DETAILS
                Name:  {$this->Name}
                Age:    
    {$this->Age}
    DETAILS;
        }
    }
    $Dave = new Person('Dave'32);
    $John = new Person('John'40);
    $Jake = new Person('Jake'17);
    echo 
    $Dave;
    echo 
    $John;
    echo 
    $Jake
    That's OOP...Just. OOP should more be defined by the patterns in it, but if you don't know if you are using OOP, chances are you're not.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  6. #6
    SitePoint Evangelist perpetual_dream's Avatar
    Join Date
    Nov 2005
    Location
    Jerusalem
    Posts
    542
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a problem understanding the importance of the Buisness layer.

    Do I always need the business layer?

    Person.php

    Code PHP:
    Public Function Save() {
    $Query=mysql_Query('insert into Person(name,age) 
    values ($Name,$Age)';
    Return $query;
    }

    PersonForm.php

    Code PHP:
    $Dave = new Person('Dave', 32); 
    $Dave.Save()

    How can I use the business layer in the mentioned example? Does the validation takes place in the business layer? Does using a 3 tier architecture means that I have to always communicate with the database layer through the business layer?

    Eventhough that I have repeatedly read the links I couldn't find the difference. Why does the frameworks use MVC and not ntier architecture? I am planning a relatively big project with my partner and we are willing to start things the right way. We took a look at CakePHP but we found that is burdensome with strict convention and we decided to start designing the project from scratch. Why would you prefer MVC over ntier or Ntier over MVC or they just cross each other? Is it just an issue of the communication between the layers.

    Thanks
    Tanzeelnet - Best arabic downloadsite
    Linux Hosting |Free Downloads |

  7. #7
    SitePoint Addict
    Join Date
    Nov 2005
    Location
    Germany
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by perpetual_dream View Post
    Do I always need the business layer?
    Of course not. But even the simplest application will have some business logic. You can move that into the presentation, but as your application grows you will regret it. It's hard to understand the consequences in theory - just start coding a simple application and you will run into problems. And some of the answers to those problems will mention 3-tier or MVC or other patterns.

    Quote Originally Posted by perpetual_dream View Post
    How can I use the business layer in the mentioned example? Does the validation takes place in the business layer? Does using a 3 tier architecture means that I have to always communicate with the database layer through the business layer?
    In my opinion, tiered architectures are only useful when there's no skipping layers. In 3-tier that would mean that the presentation may never talk to the database directly.

    Quote Originally Posted by perpetual_dream View Post
    Eventhough that I have repeatedly read the links I couldn't find the difference. Why does the frameworks use MVC and not ntier architecture?
    Unless I have a wrong understanding of 3-tier I very much doubt that there's an MVC application that's not also a 3-tiered.

    Please correct me if I'm wrong.

    Quote Originally Posted by perpetual_dream View Post
    I am planning a relatively big project with my partner and we are willing to start things the right way. We took a look at CakePHP but we found that is burdensome with strict convention and we decided to start designing the project from scratch. Why would you prefer MVC over ntier or Ntier over MVC or they just cross each other? Is it just an issue of the communication between the layers.
    Thanks
    If you are unexperienced it is very hard to chose between architectures and patterns. You should just start coding, if something is difficult or doesn't feel right there's probably a good solution for that (sitepoint is a great place to ask and read). You must have encountered the problems of software architecture before you can begin to understand the benefits of some of the more advanced techniques.


Tags for this Thread

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
  •