egghead Posted July 6, 2011 Share Posted July 6, 2011 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') Quote Link to comment https://forums.phpfreaks.com/topic/241221-should-i-develop-the-model-view-or-controller-first/ Share on other sites More sharing options...
xyph Posted July 6, 2011 Share Posted July 6, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/241221-should-i-develop-the-model-view-or-controller-first/#findComment-1239076 Share on other sites More sharing options...
AbraCadaver Posted July 6, 2011 Share Posted July 6, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/241221-should-i-develop-the-model-view-or-controller-first/#findComment-1239140 Share on other sites More sharing options...
egghead Posted July 6, 2011 Author Share Posted July 6, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/241221-should-i-develop-the-model-view-or-controller-first/#findComment-1239148 Share on other sites More sharing options...
xyph Posted July 6, 2011 Share Posted July 6, 2011 You shouldn't need to focus on multiple things at once if you don't want to. If you're forgetting what arguments are used in what methods, use http://www.phpdoc.org/ and a compatible environment such as http://www.phpeclipse.com or http://www.eclipse.org/pdt/ Quote Link to comment https://forums.phpfreaks.com/topic/241221-should-i-develop-the-model-view-or-controller-first/#findComment-1239168 Share on other sites More sharing options...
AbraCadaver Posted July 6, 2011 Share Posted July 6, 2011 You might consider an MVC framework, especially one that can generate the generic MVC files and CRUD (create/retrieve/update/delete) actions for you. I prefer CakePHP. Quote Link to comment https://forums.phpfreaks.com/topic/241221-should-i-develop-the-model-view-or-controller-first/#findComment-1239205 Share on other sites More sharing options...
egghead Posted July 6, 2011 Author Share Posted July 6, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/241221-should-i-develop-the-model-view-or-controller-first/#findComment-1239307 Share on other sites More sharing options...
KevinM1 Posted July 6, 2011 Share Posted July 6, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/241221-should-i-develop-the-model-view-or-controller-first/#findComment-1239315 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.