Questions tagged [legacy-code]

Originally legacy code meant code 'inherited' from authors or from a previous program/system version. Since Michael Feathers published his "Working Effectively with Legacy Code" book, new definition came to be, where code without tests is legacy code.

480 questions
7
votes
3 answers

How to avoid Eclipse warnings when using legacy code without generics?

I'm using JSON.simple to generate JSON output from Java. But every time I call jsonobj.put("this", "that"), I see a warning in Eclipse: Type safety: The method put(Object, Object) belongs to the raw type HashMap. References to generic type HashMap…
Paul Crowley
  • 1,656
  • 1
  • 14
  • 26
7
votes
2 answers

Link seams in .NET

I just recently finished Michael Feathers' book Working Effectively with Legacy Code. It was a great book on how to effectively create test seams and exploit them to get existing code under test. One of the techniques he talk about was using "link…
RationalGeek
  • 9,425
  • 11
  • 62
  • 90
7
votes
3 answers

Possible consequences of increasing varchar length in MySql?

I'm using an old table, which has a varchar(40) field in it. I want it to be possible to insert more characters in that field, so I want to increase the length of it. Are there possible negative consequences I should think of before increasing the…
Robin
  • 303
  • 5
  • 17
7
votes
1 answer

Separate threads for socket input and output

I got assigned to work on some performance and random crashing issues of a multi-threaded java server. Even though threads and thread-safety are not really new topics for me, I found out designing a new multi-threaded application is probably half as…
lukem00
  • 859
  • 8
  • 17
7
votes
2 answers

Any good literature on join performance vs systematic denormalization?

As a corollary to this question I was wondering if there was good comparative studies I could consult and pass along about the advantages of using the RDMBS do the join optimization vs systematically denormalizing in order to always access a single…
Newtopian
  • 7,543
  • 4
  • 48
  • 71
6
votes
2 answers

Unit testing C++ code using Java

I have inherited a huge c++ codebase with some integration tests. This is a critical system which feeds data to a lot of downstream systems. As the tests are very unreliable our team is not able to push changes confidently. We want to introduce…
NRS
  • 171
  • 6
6
votes
2 answers

In PHP, how can I wrap procedural code in a class?

I have a large chunk of legacy php code that I need to interface with that looks like this: //legacy.php function foo() { } function bar() { } I want to be able to wrap these legacy functions in a class or somehow require_once without polluting…
james
  • 3,543
  • 8
  • 31
  • 39
6
votes
3 answers

testing legacy codes with phpunit

I have a legacy codebase and I need to test that code with PHPUnit. So I am asking for suggestions based on your experiences. Which classes I should test first? Or give the priority? Should I start with the easy/small classes or with the base/super…
haris hamdani
  • 1,367
  • 2
  • 11
  • 18
6
votes
1 answer

Sharing session between two ASP.NET applications, where one is nested within the other

So, before you ask "what the heck do you mean, one is nested within the other?" I'll explain it as simply as I can. A .NET web application (A) existed. A supplementary application (B) was built that works off several of the same core assemblies. A…
Cᴏʀʏ
  • 105,112
  • 20
  • 162
  • 194
6
votes
17 answers

Inheriting applications at a new job

When inheriting applications at a new job do you tend to stick to the original developers coding practices or do you start applying your own? I work in a small shop with no guidelines and always wondered what the rule was here. Some applications…
Miyagi Coder
  • 5,464
  • 4
  • 33
  • 42
6
votes
1 answer

Confusing if statement in php

I'm refreshing some older code (someone else wrote), and came across this: if ( empty ( $role_data["role_id" == 1])) what are the reasons (if any) one would use the above instead of?: if ( $role_data["role_id"] != 1) IMO readability is worse and…
Marius Schär
  • 336
  • 2
  • 17
6
votes
2 answers

1998 vintage C code now fails to compile under gcc

I have ~16k lines of 1998 vintage C code (~50 main progs) which built flawlessly under gcc at that time but now fails with many "lvalue required as left operand of assignment" errors in the first routine, "stutter.c". I'm not enough of a C…
sambledsoe
  • 69
  • 3
6
votes
3 answers

How to go about mocking a class with final methods?

Say I have class A with class A { final String foo() { // .. computing result, contacting database, whatever .. return "some computed value"; } // ... and a bazillion other methods, some of them final. } Now I have class B with class…
Epaga
  • 38,231
  • 58
  • 157
  • 245
6
votes
12 answers

Inherited code: To format or not to format?

Our team has recently inherited code which is extremely disorganized. As a result, my team leader has decided to enforce a policy of auto-formating of code prior to saving a file. We have even found an option in Eclipse (The IDE of our choice) that…
Yaneeve
  • 4,751
  • 10
  • 49
  • 87
5
votes
1 answer

How to separate good code from legacy/quirks-mode code

Given some library that implements some widespread protocol or something similar (for instance FTP), how would I keep my standard compliant code separate from code that is only needed to be able to cooperate with not so standard compliant systems? A…
raphinesse
  • 19,068
  • 6
  • 39
  • 48