Warning: include(/home/html/bandas/conexion.php) [function.include]: failed to open stream: No such file or directory in /home/liadora/design-nation.net/en/archives/000156.php on line 16

Warning: include() [function.include]: Failed opening '/home/html/bandas/conexion.php' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/liadora/design-nation.net/en/archives/000156.php on line 16

Warning: include(/home/html/bandas/banners.php) [function.include]: failed to open stream: No such file or directory in /home/liadora/design-nation.net/en/archives/000156.php on line 17

Warning: include() [function.include]: Failed opening '/home/html/bandas/banners.php' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/liadora/design-nation.net/en/archives/000156.php on line 17
design-nation.blog/en: Design patterns: MVC ( the correct implementation? )
ThinkGeek - Cool Stuff for Geeks and Technophiles

March 01, 2004

Design patterns: MVC ( the correct implementation? )

Yesterday, Darron Schall pointed that my implementation wasn't really a Model-View-Controller, because the view should listen to the events boradcasted by the model.

The fact is that I've been using the implementation I posted yesterday for so long, that I forgot that it wasn't correct. So, I've refactored my code, and here are the results.

Now, the controller aggregates an instance of the view, and and instance of the model. The view listens to the model's events, and uses the controller to access the model.

I'm not really sure about my code, I don't know if this is the best way to implement this pattern, so I'll be glad to hear any suggestions.

Anyway, you can download the source code here

Posted by Cesar Tardaguila Date: March 1, 2004 11:50 PM | TrackBack
Comments

The thing to be careful of with design patterns:

They're just patterns - approaches used to solve common problems in software design. There really is no "right way" to do something in regards to programming. A pattern is just way to simplify a problem... so if what you've been doing is working for you, go ahead and stick to it. :-)

I didn't mean to sound condescending in my last comment, but I also wanted to share the "typical" way in which MVC is implemented. By implementing patterns as they're described, it's easier for other people to pick up on your code if know they the patterns as well. This is especially useful in a maintenance work.

Anyway, keep up the good work.. :-)

Posted by: darron en: March 2, 2004 12:14 AM

Hey, Darron, I dind't want you to think that your comment hurted me, or whatever. Of course, you didn't sound condescending, I just think you were right.

I also feel that first we must learn the "typical" implementation of design patterns.

And if the implementation it's not exactly the typical one, then I think it's better to point it as clear as possible, just to avoid misunderstandings.

So, thanks for your two last comments.

Posted by: Cesar Tardaguila en: March 2, 2004 12:24 AM