Live data from Hacker News

Ask HN: Good resources about legacy code?

news.ycombinator.com

31–40 of 41 posts

Re: Ask HN: Good resources about legacy code?

#32
Some really good suggestions here, so I'll just add: become acquainted with a code search tool (I used grep for a long time, now ag -- I don't think the tool matters that much for most purposes as long as you are comfortable with it).

Re: Ask HN: Good resources about legacy code?

#33
The core idea is that you need to imagine what would be the condition of the artifact in question if it'd be reasonable to do the required modifications, and (slowly) push the environment towards that state, filling in the gaps.

IMHO it's to be expected that you won't get where you want to be, you'll fill some of the gaps but not all of them.

The key issue is to identify what is the major pain point that prevents you from doing this. For example, in a particular similar situation for me the key points were (a) ability to reliably build a deployment package that's sure to work; (b) brief documentation about the functionality of the main components of the software and their interaction/interfaces; (c) creating a basic suite of tests to ensure that key functionality keeps working as intended if we change/rewrite certain parts fo the codebase.

The pain points will be different for you, but that's the direction that needs to be identified and taken to proceed properly.

Re: Ask HN: Good resources about legacy code?

#34
post #24
post #15

Earlier quoted context omitted.

Agreed. Adding type annotations is already a huge refactor in itself though and pretty risky with PHP. Once you have that done life will be much easier.

For those unfamiliar with php, or its type annotations, why is adding type annotations a risky step? Do they become enforcing? function foo(string $bar) { ... } foo(1234) // kaboom?

Wait? You mean you get runtime errors? That's well...good in a way but as you say dangerous on old code.

To get the true benefits of typing you should also run a static type analyzer.

Re: Ask HN: Good resources about legacy code?

#36

I sencond Working With Legacy Code. A lot of advice comes down to writing tests so you don’t break existing functionality. You should write a lot of tests, particularly high level stuff that tests the entire system because with tightly coupled systems you’ll modify part A but part Q will break. Integration level tests help find this stuff out. You have two problems on your hand. One is understanding what the code is…

Can you share a python example of replacing boilerplate code with advanced features?

Re: Ask HN: Good resources about legacy code?

#37
post #34
post #24

Earlier quoted context omitted.

For those unfamiliar with php, or its type annotations, why is adding type annotations a risky step? Do they become enforcing? function foo(string $bar) { ... } foo(1234) // kaboom?

Wait? You mean you get runtime errors? That's well...good in a way but as you say dangerous on old code. To get the true benefits of typing you should also run a static type analyzer.

Are there any for PHP?

Re: Ask HN: Good resources about legacy code?

#38
post #22
post #20

How did you get this job with no experience? How did you estimate the price and time to completion? Congrats and good luck

Possibly the OP has got hourly/daily rate gig.

Yes exactly. My first task is to examine the system and give recommendations on how to improve it.

Re: Ask HN: Good resources about legacy code?

#40

I sencond Working With Legacy Code. A lot of advice comes down to writing tests so you don’t break existing functionality. You should write a lot of tests, particularly high level stuff that tests the entire system because with tightly coupled systems you’ll modify part A but part Q will break. Integration level tests help find this stuff out. You have two problems on your hand. One is understanding what the code is…

Can you share a python example of replacing boilerplate code with advanced features?

Context handlers come to mind and can often save a lot of error handling code.
Post reply on HN