将现有凌乱的 web 应用程序迁移到优雅的 MVC 的最佳方法是什么? [英] What is the best way to migrate an existing messy webapp to elegant MVC?

查看:17
本文介绍了将现有凌乱的 web 应用程序迁移到优雅的 MVC 的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大约一个月前,我加入了一家新公司.该公司规模较小,具有很强的初创"感.我在其他 3 人的团队中担任 Java 开发人员.该公司主要向企业/业务类型的人销售用于相互交流的服务.

I joined a new company about a month ago. The company is rather small in size and has pretty strong "start-up" feel to it. I'm working as a Java developer on a team of 3 others. The company primarily sells a service to for businesses/business-type people to use in communicating with each other.

我一直并将从事的主要工作之一是公司的主要网站 - 销售服务的网站,现有用户登录以查看他们的服务并支付账单,新用户可以注册用于试用等.目前这是一个部署在 Tomcat 上的 JSP 应用程序,可以通过公司自己编写的持久层访问数据库.

One of the main things I have been, and will be working on, is the main website for the company - from which the service is sold, existing users login to check their service and pay their bills, new users can sign up for a trial, etc. Currently this is a JSP application deployed on Tomcat, with access to a database done thru a persistence layer written by the company itself.

我在这里遇到的反复和越来越大的挫败感(我对这份工作非常满意,所以这不是哦,不,我不喜欢我的工作"类型的帖子)是缺乏任何此 Web 应用程序的更大设计或架构.该应用程序由几十个 JSP 页面组成,在 Servlets 或 Beans 或任何其他类型的框架中几乎不存在逻辑.很多JSP页面都是上千行代码,他们jsp:include其他JSP页面,业务逻辑混在HTML中,经常使用的代码片段(比如获取一个web服务连接)是剪切和粘贴而不是重复使用等.换句话说,应用程序是一团糟.

A repeated and growing frustration I am having here (and I'm pretty happy with the job overall, so this isn't an "oh no I don't like my job"-type post) is the lack of any larger design or architecture for this web application. The app is made up of several dozen JSP pages, with almost no logic existing in Servlets or Beans or any other sort of framework. Many of the JSP pages are thousands of lines of code, they jsp:include other JSP pages, business logic is mixed in with the HTML, frequently used snippets of code (such as obtaining a web service connection) is cut and paste rather than reused, etc. In other words, the application is a mess.

公司内部有一些关于试图重新构建该站点以使其更适合 MVC 的传言;我认为开发人员和高层开始意识到这种当前的意大利面条式代码模式是不可持续的,或者很容易扩展以为用户添加更多功能.高层和开发人员对完全重写这个东西持谨慎态度(有充分的理由,因为这意味着需要几周或几个月的时间来重写现有功能),但我们已经就(缓慢地)重写进行了一些讨论.将网站的某些区域写入新框架.

There have been some rumblings within the company of trying to re-architect this site so that it fits MVC better; I think that the developers and higher-ups are beginning to realize that this current pattern of spaghetti code isn't sustainable or very easily scalable to add more features for the users. The higher-ups and developers are wary of completely re-writing the thing (with good reason, since this would mean several weeks or months of work re-writing existing functionality), but we've had some discussions of (slowly) re-writing certain areas of the site into a new framework.

使应用程序和代码库朝这个方向发展的最佳策略是什么?作为一名开发人员,我如何才能真正帮助推动这一进程,而且不会看起来像一个进入工作并告诉每个人他们写的东西都是废话的混蛋新人?当您遇到此类事情时,您在自己的工作经历中是否使用过任何行之有效的策略或经验?

What are some of the best strategies to enable moving the application and codebase into this direction? How can I as a developer really help move this along, and quickly, without seeming like the jerk-y new guy who comes into a job and tells everyone that what they've written is crap? Are there any proven strategies or experiences that you've used in your own job experience when you've encountered this sort of thing?

推荐答案

最好的办法可能是在进行过程中慢慢地重构它.很少有人拥有完全从头开始处理埋藏着如此多业务规则所需的资源.当您花费数月时间开发的应用程序比您替换的应用程序存在更多错误时,管理层真的很讨厌它.

Your best bet is probably to refactor it slowly as you go along. Few us of have the resources that would be required to completely start from scratch with something that has so many business rules buried in it. Management really hates it when you spend months on developing an app that has more bugs than the one you replaced.

如果您有机会从头开始构建任何单独的应用程序,请使用那里的所有最佳实践并用它来证明它们的有效性.如果可以,请逐渐将这些想法融入旧应用程序中.

If you have the opportunity to build any separate apps from scratch, use all of the best practices there and use it to demonstrate how effective they are. When you can, incorporate those ideas gradually into the old application.

这篇关于将现有凌乱的 web 应用程序迁移到优雅的 MVC 的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆