Sign in to follow this  
bobjink

Help me refactoring to MVC on current project

Recommended Posts

I am currently doing a project with a group where we are doing application like googlemap. Me who is obsessed with making good design and following OOD(though not so good at it), have done so that everything is delegated to new objects /classes. I believe this is a good thing so that each object has just one thing to do. This has resulted in 3600 lines of code / 33 classes. Is that too many classes? However I have a big problem understanding how objects far away from each other can communicate because of t his. I think the whole design is wrong. My group don’t really have problem with this, they just make everything static or singleton. I am thinking we are heading for a disaster because of this but I am not sure:/ MVC to the rescue?! This is the pattern I get pointed to, but I need help to understand it. Every tutorial/book only shows how it’s used on a simple Calculator example etc., not on a big application. I hope someone will look at the code and tell me how I should refactor the code. I think this is the only way I will really get it. Unfortunately I can’t upload the data(only code), so the code is not runable. A picture is included though, showing the application to give you a brief understanding of it. I would really appreciate any help :) Download Link: http://www.megaupload.com/?d=NJP71DXR I asked similar question here: http://stackoverflow.com/questions/803504/help-me-understand-ood-with-current-project

Share this post


Link to post
Share on other sites
I'm too busy to download your project and look through it. A summary or a UML diagram here would help though.

Personally I think your problem is that your group members just want to do what works, not what is best. Pointing them at MVC links probably isn't going to sway them.

MVC itself however is quite simple. You have your Model, which is the collection of classes that represent the key data in your application, you have the View, which are the classes that display the key data to users of some description, and you have the Controller which tells the Model how/when to update itself and typically tells the View to query the Model for changed state as a result.

These are quite separate issues to that of having statics and singletons. That comes about through not having clear interfaces to access the data and instead making it global. If each class has a clear role, its interface should be obvious, and every piece of information you need would form part of a class's interface somewhere. If class A connects to B and B connects to C, but A needs something of C, you put extra logic into B to get it from C on A's behalf. (See also: Law of Demeter.) And if you find yourself doing this far too much, it's a sign that perhaps your class associations are in the wrong place, so refactor.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this