Jump to content

Should i develop the Model, View or Controller first?


egghead

Recommended Posts

hi, first time here, not the last thats for sure.. i've been learning oop php with the mvc architecture, just getting into coding my own stuff... question is:

 

What do i do first!?!!

 

With procedural i just sort of sit down and GO until i fall asleep... with this MVC thing, i am stuck not knowing how to begin, or even how to plan or map my applications.

 

Any help would be so greatly appreciated.  How do you plan/where do you begin?

 

(am NOT using a framework until i learn the right way without a 'crutch')

Link to comment
Share on other sites

Depends on how your head works.

 

You should pretty much have the other two in mind no matter where you start, because in some way or another they will interact.

 

Start wherever is most comfortable. It'll be a long time before you don't have to worry about going back to make changes.

 

I've been using design patterns for quite some time, and there's hardly ever a feature or interaction I forget about or have to re-implement to some extent.

Link to comment
Share on other sites

Here is my opinion.  I would do it MVC.  Your database and business logic should be the first thing that you design and go in the Model.  How you present and collect the data and actions would be the next consideration and it goes in the View.  The Controller would then determine what data is sent from the view to what model and what data is retrieved from the model and sent to what view.  You should have a "fat" model (business logic) and "skinny" controller (hand-off between view and model).

 

Of course a case can be made for doing the controller second and using it as a blueprint for what views you create since it may control multiple models with relations etc. As xyph said, it depends on how your head works, but I would start with the model in any case.  You can then decide whether you what to do the view or the controller.

 

Just my 2 cents.

Link to comment
Share on other sites

I was thinking of doing the model and view on the same page, then splitting them up as need be, then writing the controller to bring it back together... i think whats pissing me off is having to do so much switching between different files in general, its breaking my concentration.

Link to comment
Share on other sites

OK, i have been doing things like the idea i had earlier and it's working for me great... so far.

 

i ended up with the model on top, view on bottom, controller in the middle, and i must say it took me <1/2 the time it does moving from file-to-file....i much rather scroll up and down than tab around, (my brain cannot remember from one tab-to-the-next i think! it's like it resets)

 

i tried Ci and i tried Netbeans, but jeezus as a long-time handcoder i just prefer working in php text editor without all the helper and wizard stuff...

 

explain to me... i tried CI, and tried working with the 'pagination class'.. after 10 minutes of feeling stupid, i asked why not write my own bloody pagination class, and that took me all of 5 minutes... so what exactly is the use of the framework for people who already know how to write code? Compared with jquery or other javascript frameworks? Now THERE are a bunch of time/effort savers! But the php frameworks? I am not sold on them for any other reason than working in teams, or for companies, where the classes need to be uniform.

 

 

Link to comment
Share on other sites

explain to me... i tried CI, and tried working with the 'pagination class'.. after 10 minutes of feeling stupid, i asked why not write my own bloody pagination class, and that took me all of 5 minutes... so what exactly is the use of the framework for people who already know how to write code? Compared with jquery or other javascript frameworks? Now THERE are a bunch of time/effort savers! But the php frameworks? I am not sold on them for any other reason than working in teams, or for companies, where the classes need to be uniform.

 

MVC frameworks fulfill the same niche as other frameworks - to get you up and running doing what you need to do quickly.  The time I could spend writing and testing a front controller, route tables, ORM, a bunch of utility classes (form validation, file handling, etc.) is, instead, spent on writing code which will make me money.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.