How to efficiently and effectively reorganize legacy code?

Possible duplicates:
What should I keep in mind in order to reorganize a huge code base?
When is it good (if ever) to abandon production code and get started?

I am currently working with some old source code files. They have quite a few problems because they were written by a database expert who knows little about Java. For instance,

  • Fields in classes are publicly available. No getters and setters.
  • Use raw types, not parameterized types.
  • Use staticunnecessarily.
  • Super callout method names.
  • Methods require too many parameters.
  • Repeat yourself often.

I want to change them so that they are more object oriented. What are some best practices and effective / efficient approaches?

+5
source share
8 answers

Read Michael Persian's Effective Work With Legacy Code . A great book - and obviously it will be much more detailed than the answers here. It has many methods for making smart use of things.

It looks like you have identified a number of problems that make up a significant part of the problem. Many of them sound as if they can be installed relatively easily - this, of course, is a complex design and architecture, which, of course, are more difficult to do.

Are unit tests already available, or will you add them too?

+8

, , . , , .

, IDE (, grep). , "", , IDE ( ), ... .

, Eclipse . , "" :

  • .
  • .
  • .
  • Java, - , , .

. , . , , , .

, - . , " ". ... ... .

+5

, ? , . , , , ..

, . , .

, :

  • , , . , , . , . , , , .
  • , . , .
  • . . , , , .
  • . I.e., , . , , . , , .
  • , .
+2

Eclipse # 1 .

OO OO, . , .

. , , , , , . .

, , OO OO , , ( , - )

+1

.

, , . , . .

  • , , bugfix .

, - :)

+1

? , (, ).

, , , String, String address, int yearOfBirth, String [] accountNames, int [], Customer, , , [].

IDEA Ultimate Edition , ( " "!), CPD ..

, , , . : http://rickyclarkson.blogspot.com/2009/12/deleting-code-what-first.html

0

"" - , ? "" , , " ", , , - .

0

, -.

Object-Orientation . , , - ( - ? ?). ROI - , ( , ). ROI.

, , , . , , , , .

Before touching on any code, you should evaluate the overall work that needs to be done to complete the refactoring of the code and the dependent code. You should evaluate general code correspondence, partial correspondence, or just internal correspondence without touching the API.

With costs and revenues, you can decide whether to reorganize your code.

0
source

All Articles