What is a legacy code?

Asked

Viewed 6,389 times

49

I’ve heard that term from some people, but I’m not usually good with those technical terms.

What would be a legacy code?

It is related to the code being exceeded?

  • Higher percentage of questions are related to problems that on the internet there is already a solution, but I see simple questions like "I need help on the IF command" that stay open and do not receive any votes to be closed, is your question and easy to be localized on the internet and yet received 49 votes, wanted to understand what criteria you use to judge a question be closed without adding any justification.

  • 1

    Hello @Harry. We are not a site of Helpdesk, a level of Helpdesk is even tolerated, as long as we do not fall into the problems mentioned in Survival guide, back to focus, the main goal of stackoverflow is to be a repository of knowledge, this explanation of what "is legacy" may exist on other sites, but the stack overflow audience can and should have the right to search within the site itself the answer with a text that is evaluated by members to be a reliable source that the information is correct. Thank you for understanding.

  • 1

    Hello, if you have any questions, complaints or questions about the functioning of the community, I suggest you ask a question on meta. Most questions like "I need help on the if" I close (and the other moderators too). Remembering that here is a question and answer site about programming, and not a forum. On the question of being "simple" or not: you can read more about it here

  • On the question to be closed: The justifications are always highlighted in the closing description itself. On the question of votes: it is the community that decides how they vote or not on the questions (I cannot vote for myself).

  • @Guilhermenascimento, I understand your point of view, more if I am to pick up questions that exist on the internet, as you spoke the public should have the right to search inside the site is very easy to achieve high scores on the site, Since there are many questions in this category that are on the internet, nothing against always thought that the score was according to the amount of questions you would answer the questions. more and good to know because when I locate something that is on the internet and is not on the site I can post in this category.

  • @Wallacemaxters, I understand your point of view, I believe you are right, but the site is full of very bad questions and many do not receive any votes to be closed, in some cases are closed after someone post a reply.

  • 1

    Hi @Harry. I did not say anything about "high reputations", I’m talking about the score system serve to indicate that the content is reliable, the points do not serve only to feed egos, no, the main and ideal purpose of the points is to say that the content is good or bad, mainly of the answers. I hope you understand the role ;)

  • @Guilhermenascimento, I don’t have a problem with scoring and ego, I don’t care about that, but like I said, this kind of question from my point of view is only for scoring. Maybe I’m wrong more and what I think about it

  • @Harry I didn’t tell you that you have this problem, I’m telling you what the purpose of the score is, that it has nothing to do with your person, but it has to do with the high-score posts, you complained about something as if the concern of users like Wallace was just the score, and the purpose of the post and the score on the site is to evaluate the content as reliable. That’s all.

Show 4 more comments

6 answers

47


TL;DR

There is no exact definition of what is legacy, but the meaning goes in the sense of an old code or produced with technologies already retired or old techniques, almost always difficult to maintain and control.

Legacy code may be that code produced in language or platform where the manufacturer has already discontinued the support of new features or/and security or existing bugs will not be fixed, the programmer should circumvent these situations or create a patch if the platform/language/framework is open-source. The best alternative would be to isolate the problematic code and rewrite it with modern technology and integrate it into the old system.

Another situation where code can be considered legacy (in the sense of cursed heritage) is when the software has already been built and after a while all the original members of the project no longer work on it, the 'beginners' in charge have no notion of the context of the project, internal functioning of the architecture etc usually there is no documentation or the existing one is already totally outdated.

The definition of Michel Feathers, author of Effective Work with Legacy Code is

Legacy code is the one without testing.

The phrase above is very suspicious, since one of the subjects dealt with in his book is how to test legacy code and add unit tests.

Factors that kill the code over time are lack of preventive maintenance or refactoring, freezing of the platform on the part of the customer no version update can be made due to some bizarre requirement of the design or approval policy, drastic changes in architecture, each part of the software gets in a way that is also known as lava flow. All this combined transforms any change, complicated because it is difficult to calculate side effects and to worsen sometimes there is no type approval environment so the change goes straight to production.

Related:

  • 4

    Great clarification! There is no exact definition +1

  • 1

    @Guilhermenascimento, thank you for the edition, path is kind of tense even kkk

  • Aside from punctuation flaws, excellent response. Congratulations.

41

Ensō, o símbolo da iluminação, força, elegância, o universo e o vazio

So said the Master Programmer: Let the programmers be many and the managers few - then everyone will be productive.


Legend has it that in a remote province there was a monastery where the Master Programmer shared his teachings. One of his dialogues was about legacy code.

'Master', asked the proud court engineer of Lao, 'Why are legacy systems used? Usually when dealing with legacy systems, I feel they lack Zen: They are like Karesansui1 who, in an abandoned house, are disfigured by time and carelessness. Forgotten, disconnect from the nature of the business; not understood, make impossible the feng shui.'

'The answer is a reflection of the engineer’s heart', started the master. This then arose, in which was followed by the disciples who accompanied him that spring morning where the morning mists still hovered.

He then began a walk, which led them up the hill to the edge of the forest. Finding a place in the sun on the surrounding grass where the morning dew still persisted, he turned and, sitting on a nearby stone, began to observe the city in front of him, whose delicate roofs stretched like a handful of jewels in a jade-colored purse.

On his left, bordering the road where the locals were walking - here, a mother carrying a basket of bread, a baby in tow; there, a samurai with the decided step of someone on an important mission given by his daiymio - , a wooden pillar stood up, decorated with shinto motifs and a poem in style haiku:

く も と へ だ つ と も か や か り の い き わ か れ
Clouds separate us - the time to depart has come. The wild goose takes flight.2

'This is the fourth incarnation of this city', said the master, returning to the subject. 'Before the current name, others were used: other engineers, from the top of this ravine, observed the space in front of them - other constructions, other people, other times. The engineers who raised that pillar are long gone; their art is now appreciated elsewhere, or have withdrawn from the pleasures of the world.

Fires swept the wooden and bamboo buildings; court dignitaries changed the official residence of address, size, color, shape and purpose; the fort that was built at the time of the war was converted into a warehouse.

However the stone pit in the central square is the same - because its purpose is clear, its implementation simple, and its function perfectly observed. This is one of the reasons.

The abandoned mansion in the forest, also ancient, has another reason to be. Legends say that a yōkai the habita; soldiers avoid their surroundings, and mothers use it to contain the curiosity of their own offspring with stories of missing children.

The city before us is like a fabric of fibers of various eras, in a plot that tells, at the same time, the stories of the old and the new. Zen persists not in individual aspects, but in its day-to-day life, in the life that inhabits its streets of various widths.

The nature of legacy systems is similarly derived from either respect for functionality or fear of the consequences of dealing with the unknown.'

But the engineer was dissatisfied with the answer. 'But would that be ideal, Master? I recently returned from Edo, and the city stood magnificent - all the new buildings, their varnishes shining in the sun.'

The master then replied: 'Not all cities have vaults as full as the Emperor, who can afford to rebuild a city at will. What would Zen be in this case? Where would be the balance between will, objective and achievement? Would not the scene be perfectly in balance?'

The master and his followers continued to admire the city and its buzz. After a few minutes of contemplation, the engineer smiled. He had accepted the nature of the argument; with his new eyes, before him, the small town gleamed in perfect balance in the morning dew.

1Japanese rock garden.
2Matsuo Bashō, 1671

  • 3

    Poetic!

  • 2

    雲 と へ だ つ 友 か や 雁 の 生 き 別 れ Kumo-to-ê-datsu tomo-ka, ya-Kari-no Iki-wakarê. Onosendai I think cut the kumo(cloud) く at the beginning of its hiragana phrase. Story summary: -Engineer: Why legacy systems are used? -Master Zen: Because not every company has the money to make a new system every time the system starts getting old.

  • 1

    @Antonioalexandre Yes, that would be the version TL;DR. ;) As for the quote, you’re right! Thanks for the correction. =)

  • 2

    very good, I get an upvote just for the culture...

30

It is a code that was already present before the code that is intended to write now and is related to the code that is intended to write now, but it was not written predicting this relationship.

In general, legacy code does not have an easy or obvious integration mechanism with this code that is intended to be written now.

Related expressions: legacy applications or legacy systems. The concept is the same: you need to write new applications that somehow relate to those that were already there (whether integrating with them or replacing them).

Legacy code is outdated code?

Not necessarily, but generally yes, because the expression takes place precisely when it comes to the challenges of integration or replacement of the legacy.

If we need to replace, or if instead of expanding the existing we will integrate new algorithm, then it is likely that what is there (the "legacy") is "outdated".

It is important to note that "outdated", or that it needs to be replaced or that it cannot be expanded, does not always mean that it is bad.

In other words, the legacy is not always of poor quality or poorly made. There are several other reasons to replace a tool or use new ones in integration with it instead of expanding it.

3

This is a definition of my authorship: "Legacy code is one that is inherited and you don’t have enough confidence to modify it." All created code has the potential to become legacy, yes. But not all created code becomes legacy. In the book "How to be a better programmer", Goodliffe explains if a code has no maintenance, it tends to disappear from the company, either by another internal tool, or by vendor software. This can also be a good definition.

1

Bequest.

s.m. What is passed on to the generations that follow.

When you join a company, you call yourself legacy code every code that you must maintain and which you did not participate in the initial development. It may have been written by programmers who are no longer part of the company’s staff or older programmers on the team who will now dedicate their time to other projects.

0

Legacy code is the one implemented in part or in full using some old technology in relation to current technology. That is my definition. One of the reasons I see for the existence of such a code is the limitation of computer system where the project is spinning.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.