This is a discussion on Spaghetti Code within the Software Patterns forums, part of the Testing category; I've got a class with about 1029 lines of code - obviously I want to refactor this, but the first ...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Spaghetti Code
I've got a class with about 1029 lines of code - obviously I want to
refactor this, but the first thing I need to do (I think) is separate the GUI from the logic stuff. Anyone know of any sites or links to show how to do this? Thanks |
|
|||
|
Re: Spaghetti Code
If I understand your question, you are looking for the Model-View-Controller
pattern. Just google on those three words together just get you a bunch of hints on what functionality should go where. Bob "Jenski" <jenski182@aol.com> wrote in message news:1133984167.920588.221120@g44g2000cwa.googlegroups.com... > I've got a class with about 1029 lines of code - obviously I want to > refactor this, but the first thing I need to do (I think) is separate > the GUI from the logic stuff. Anyone know of any sites or links to show > how to do this? > > Thanks > |
|
|||
|
Re: Spaghetti Code
What you need is a MVC pattern. A Model View Controller. keep in mind
that there are 3 major types of a MVC. You have a Front Controller, a Page Controller or a Application Controller. There maybe more but I have not used any others. If your app is small and web based I would almost always go with a Page Controller. And if you are using .NET this is the default behavior so that makes it even easier as it is built into the Visual Studio. If you are using Java Apache Struts is a very nice Front controller. Good Luck it is really fun stuff, PitDog |
|
|||
|
Re: Spaghetti Code
There is a good book that provides names to the various techniques needed to
take a 'bad' bit of code and rework it until you get a good bit of code. That book is called 'Refactoring' and I believe it was written by Martin Fowler. Excellent for advice on how to clean up your code. MVC is probably not the pattern you need (based on statistics: there are hundreds of patterns. both responses picked one without any foundation whatsoever for selecting it. Odds are, they are wrong!) Not only is MVC a particularly vague pattern, it is nearly useless in event-driven systems like we usually face today. It's derivatives like Front Controller are useful, but your problem could be solved by an entirely different combination of patterns. It is hard to tell based on the limited info you provided. Check out the 'Refactoring' book. It will help. -- --- Nick Malik [Microsoft] MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik Disclaimer: Opinions expressed in this forum are my own, and not representative of my employer. I do not answer questions on behalf of my employer. I'm just a programmer helping programmers. -- "Jenski" <jenski182@aol.com> wrote in message news:1133984167.920588.221120@g44g2000cwa.googlegroups.com... > I've got a class with about 1029 lines of code - obviously I want to > refactor this, but the first thing I need to do (I think) is separate > the GUI from the logic stuff. Anyone know of any sites or links to show > how to do this? > > Thanks > |