Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Strategy for Migrating from Model 1 to Model 2  RSS feed

 
Sandep Chaturvedi
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew and other experts
Can you recommend a way to migrate from a Model 1 application to MVC Model 2. Are there any guidelines or best practices for this process ...there are many applications around written with previous approach, someone must have / should have come up with a best practice!
Thanks
 
Andrew Patzer
Author
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sandep Chaturvedi:
Andrew and other experts
Can you recommend a way to migrate from a Model 1 application to MVC Model 2. Are there any guidelines or best practices for this process ...there are many applications around written with previous approach, someone must have / should have come up with a best practice!
Thanks

You could start by implementing a model 2 framework (like the one I create in my book, or Struts). Once the framework is in place, start the migration by ripping out the navigational code and making every POST to the controller servlet. Once that is done and tested, move your business logic to your Action classes, store the data needed for the response page in a JavaBean, and then modify your pages to use the bean to obtain the required data. It sounds like a lot of work, but if you start with the navigation, and then attack each page individually, it shouldn't be too bad.
Good question!
Andrew
 
Sandep Chaturvedi
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. That was very helpful.
 
Alvin Tan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
"there are many applications around written with previous approach, someone must have / should have come up with a best practice!"

I totally agree with you! We kept a 2000-line monster in our backyard, and now we couldn't control it. Assigning someone to maintain the spaghetti code is a new form of torture.
My question is: is it still feasible for us to patiently transform a file this huge or are we better off building it from scratch?
Thanks
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on how bad your monolithic monster is. The good thing is that the business analysis work is done and that is usually the hardest part of any project. A ground up rewrite will almost definitely result in better quality code then if you try to piece-meal retrofit your current application.
It doesn't sound as if your application is huge, so it shouldn't take an extremely long time regardless of the method you choose. Your hardest job is going to be selling the rewrite to management.
Your project will be even faster if you use a framework such as Struts or WebWork but it won't be nearly as fun . Ultimately, every application is eventually going to introduce less than optimal design, because at the end of the day we all have deadlines to meet and not enough resources to meet them with. For this reason it is good practice to consistantly refactor your code. You don't need to schedule "re-writes" every other year if you are continuously fixing those nasty parts on a regular basis.
 
Andrew Patzer
Author
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chris Mathews:
It depends on how bad your monolithic monster is. The good thing is that the business analysis work is done and that is usually the hardest part of any project. A ground up rewrite will almost definitely result in better quality code then if you try to piece-meal retrofit your current application.
It doesn't sound as if your application is huge, so it shouldn't take an extremely long time regardless of the method you choose. Your hardest job is going to be selling the rewrite to management.
Your project will be even faster if you use a framework such as Struts or WebWork but it won't be nearly as fun . Ultimately, every application is eventually going to introduce less than optimal design, because at the end of the day we all have deadlines to meet and not enough resources to meet them with. For this reason it is good practice to consistantly refactor your code. You don't need to schedule "re-writes" every other year if you are continuously fixing those nasty parts on a regular basis.

I agree completely. In a nutshell, use a framework and continuosuly refactor the code. I've found that once I explain to clients the benefits of refactoring, they're more than happy to spend a few more dollars making sure that what they're getting is of the highest quality, rather than rushing code into production and then forgetting about it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!