Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Legacy Code..defintion.

 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What would qualify as Legacy code. Any code in production would be termed 'legacy' code?
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Based on Jeanne's review and the preface, it seems that Michael has defined legacy code as code written by someone else and that has no tests to accompany it -- or simply a spaghetti cludge that works but nobody knows why...
 
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my domain legacy code is some large application that is very painfull to maintain because of the costs and because of the lack of knowledge (super systems working already for 20 years and more).

./pope
 
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my experience, "legacy code" is old code that still needs maintenance for whatever reason. For example, in California's Medi-Cal system, many programs were written in COBOL on mainframes in the sixties and seventies, and they still need to be maintained, enhanced, etc, because the cost to build them anew is prohibitive. That's legacy code from my standpoing. (Your results may vary.)
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep indeed Jeff. This is what I meant by the above post (you better expressed it). 10x

./pope
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For a book that describes techniques handling "legacy code", it probably isn't that important how the code came into existence, but what it looks like *now*, what problems it causes and how we can deal with it.

"Old code" certainly often has the properties of being an untested, incomprehensible design mess that is hard to change without breaking something. But you also can find similar code that only is weeks old, and then probably the same strategies can be applied.
 
author & internet detective
Posts: 41110
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lasse,
From my review:

The author defines "legacy code" as "code without tests."


It doesn't matter who wrote it or when it was written.

But you also can find similar code that only is weeks old, and then probably the same strategies can be applied.


Ilja,
Definitely! I was impressed with how useful the book was for code I wrote myself (within the last two years) before I fully believed in the value of unit testing.
 
Jeanne Boyarsky
author & internet detective
Posts: 41110
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the preface:
the strict definition is "code that we've gotten from someone else"
"a slang term for difficult-to-change code"

Most importantly,
"To me [Michael] legacy code is simply code without tests." He admits this isn't the standard defintion, but this is the definition that serves the purpose of the book.
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While it gets more and more clear that the author definition of legacy code is code without tests, I am really wondering why he has chosen it.

./pope
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


What would qualify as Legacy code. Any code in production would be termed 'legacy' code?



Any code that requires enhancements to cater to the growing needs of the customer
or
Any code that is written by someone and maintened by somebody else without
any proper documentation
 
author
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ali Pope:
While it gets more and more clear that the author definition of legacy code is code without tests, I am really wondering why he has chosen it.

./pope



I chose it because I notice a definite qualitative difference when I work in code bases that have very good test coverage. Silly mistakes are caught immediately. It is like having a code base that bites back. This seems to be pretty much the opposite of the very typical difficult-to-change code bases, the ones we often call 'legacy code' in a derogatory way.

I hope that people begin to notice the difference in feel among those two different kinds of code bases, and that they inch towards the kind that makes work less of a chore
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Michael. I would like to add a personal feeling here: sometimes, even if this kind of work is quite nasty, after a succesfull refactoring campaign I feel very happy about my work and moreover I enjoy very much going into some other programmers way of thinking.

./pope
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Karthik Guru:
What would qualify as Legacy code. Any code in production would be termed 'legacy' code?



I think US Supreme Court Justice Potter Stewart said it most effectively in a different context:

I shall not today attempt further to define the kinds of material I understand to be embraced . . . [b]ut I know it when I see it . . .



Legacy code could be any code that is hard to work with, modify or extend.

One obvious case I worked on several years ago involved 500,000 lines of IBM mainframe assembler code. It was full of bugs, and fixing one often introduced two more. The original developers did try to provide for change by defining every attribute that could change (and some that could not) as a symbolic constant. Thus, if the supported hardware changed, one could just change the appropriate constants and build a version that supported the changes. Of course, they did not consider that versin would no longer support the hundreds of customers using the old hardware.

Yes, this system is still in production today. Heaven only knows how many additional hundreds of thousands of lines of code are in it now.
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand what is being said here, but I thought legacy code had a language change also. My example is a very well written Fortran code that generated a 3X3 matrix given three angles and the axis that they rotate about. There is no way that I can see that Java or another language could improve it. Tests for input errors were built in already I just wanted use it in my Java program like a "black box".
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Indeed Sonny that is the known meaning, but Michael has used this "legacy code" giving it a new perspective.

./pope
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would say any fulfilment system that new system is interacting with is a legacy code.
 
Jeanne Boyarsky
author & internet detective
Posts: 41110
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sonny,
That brings up a good question. If you aren't modifying it, is it still legacy code.

As long as it stays a black box, I would say no. At that point, it is just like a component that you bought from someone else. If you have to make a change to it, it would become legacy code then.
reply
    Bookmark Topic Watch Topic
  • New Topic