Part of the EllisLab Network
   
1 of 2
1
Insanely clear tutorial to fully understand the MVC design pattern.
Posted: 31 July 2008 03:53 AM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  64
Joined  01-12-2007

Hi guys!

I’m nemetral, CI addict willing to share the basics of MVC with all the newcomers joining the CI community!

The 3-part tutorial is available at:
Part 1 : http://nemetral.net/2008/07/31/a-gentle-introduction-to-mvc-part-1/
Part 2 : http://nemetral.net/2008/08/06/a-gentle-introduction-to-mvc-part-2/
Part 3 : http://nemetral.net/2008/08/13/a-gentle-introduction-to-mvc-part-3/

Go check it out and leave comments to discuss some points should you have any remark or question related to MVC! When it reaches the perfect stage, why not making a wiki page out of it?

Cheers
nemetral

 Signature 

http://nemetral.com
http://nemetral.net

Profile
 
 
Posted: 31 July 2008 05:49 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  756
Joined  03-20-2006

That’s a coincidence, i was reading your “persuit of APIness” when i saw this post.

Nice work.

Profile
 
 
Posted: 31 July 2008 06:10 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  64
Joined  01-12-2007

I hope you enjoyed this series of posts as well!

The idea of the blog is to explain webdev concepts and patterns, and in a second time I’ll move on to substantial CI examples.

There’s more to come..

 Signature 

http://nemetral.com
http://nemetral.net

Profile
 
 
Posted: 31 July 2008 08:07 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  756
Joined  03-20-2006

I’ll keep an eye out for it, perhaps your site has one of these rss thingys i could subscribe too….

Profile
 
 
Posted: 31 July 2008 08:10 AM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  64
Joined  01-12-2007

Haha exactly: the feed is burnt over there at http://feeds.feedburner.com/nemetral

Enjoy!

 Signature 

http://nemetral.com
http://nemetral.net

Profile
 
 
Posted: 31 July 2008 08:13 AM   [ Ignore ]   [ # 5 ]  
Grad Student
Rank
Total Posts:  95
Joined  07-03-2007

Just some thoughts on clarity…

What’s Business Logic, PHP Logic, what’s the difference?
Explain view, controller, which should go where. (Review definition of MVC).

Doesn’t really go into why it’s more maintainable although that should be blindingly obvious.

Good Luck smile

 Signature 

Artur E.
Software Engineer & MySQL Junkie at MapMyFitness, LLC.
Located in Denver, Colorado


I am interested in unique projects and problem solving opportunities; if you’re planning, working, or implementing something that’s “outside the box” please contact me. If you’re a non-profit than I am too, please contact me if you need consultation.

Profile
 
 
Posted: 31 July 2008 08:16 AM   [ Ignore ]   [ # 6 ]  
Grad Student
Avatar
Rank
Total Posts:  64
Joined  01-12-2007

@Aea

Thanks a lot for your comments.

Part 1 of the tutorial is not yet about MVC: MVC will be explained in part 2 and the basis of a MVC framework will be shown in part 3 (kind of a super light CodeIgniter to really understand how the different parts work).

But you’re right I’ll define Business Logic & PHP Logic.

Thanks!

 Signature 

http://nemetral.com
http://nemetral.net

Profile
 
 
Posted: 31 July 2008 08:31 AM   [ Ignore ]   [ # 7 ]  
Summer Student
Avatar
Total Posts:  21
Joined  05-16-2008

hey nice tutorial, nice work
thanks for sharing

 Signature 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Eros, cities builder.

Profile
 
 
Posted: 01 August 2008 12:43 AM   [ Ignore ]   [ # 8 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  4839
Joined  07-14-2006

Nice article for beginners but one thing bothers me and that is your use of the for loop to display the results

<?php for ($i = 0; $i < count($members); $i++) : ?>
    
<li>Member #<?php echo $i + 1; ?>: <?php echo $members[$i]; ?></li>
  
<?php endfor; ?>

This snippet is better

<?php foreach($members as $i=>$member) : ?>
    
<li>Member #<?php echo $i + 1; ?>: <?php echo $member; ?></li>
  
<?php endforeach; ?>

The bad things about your snippet is the performance hit adding the count function to the second part of the for statement because then it is a part of the loop and you add variables instead of using the data that is present.

Using the foreach loop naming of the variables it’s also more clear once you need to get multiple fields

$members[$i]['name']
// vs
$member['name'] // or as an object $member->name
Profile
 
 
Posted: 01 August 2008 02:06 AM   [ Ignore ]   [ # 9 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2612
Joined  06-10-2007

What xwero is saying is absolutely the better method to use.

 Signature 

URI Language Identifier | Modular Extensions - PHP5 | Modular Separation - PHP5 | Widget plugin | Access Control library

Profile
 
 
Posted: 01 August 2008 04:38 AM   [ Ignore ]   [ # 10 ]  
Grad Student
Avatar
Rank
Total Posts:  64
Joined  01-12-2007

Thanks for all your comments! I have modified some parts of the post.

Stay tuned for the other two posts!
nemetral

 Signature 

http://nemetral.com
http://nemetral.net

Profile
 
 
   
1 of 2
1
 
‹‹ Another newb :)      Hi everyone ››
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 721, on January 06, 2010 09:38 AM
Total Registered Members: 115017 Total Logged-in Users: 57
Total Topics: 122449 Total Anonymous Users: 2
Total Replies: 647332 Total Guests: 547
Total Posts: 769781    
Members ( View Memberlist )