legacy-code

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

流过昼夜 提交于 2019-12-06 00:07:33
问题 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 should be parameterized The clean fix would be if JSONObject were genericized, but since it isn't, I can't add any generic type parameters to fix this. I'd like to switch off as few warnings as possible, so adding "@SuppressWarnings("unchecked")" to

Suggest a simple ORM on .NET - design for maintaining legacy apps

人走茶凉 提交于 2019-12-05 11:10:01
I am assigned to maintain a bunch of legacy apps with heavy stored procedure usage built before '05 when there was no ORM. The developers who work with me don't know Entity Framework nor LINQ and are not eager to learn. Is there any ORM on .NET that provides a simple object interface to existing database tables and perhaps stored procedures? I am quite happy if it enables me to code a few lines to get a class to each table, and it has properties corresponding to data in each column and some methods or properties to resolve foreign key relationship / many-to-many relationship - forward and

Separate threads for socket input and output

落爺英雄遲暮 提交于 2019-12-05 08:05:51
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 difficult as trying to tweak some legacy code. I skimmed through some well known books in search of answers, but the weird thing is, as long as I read about it and analyze the examples provided, everything seems clear. However, the second I look at the code I'm supposed to work on, I'm no longer sure about anything! Must be too much of theoretical

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

依然范特西╮ 提交于 2019-12-04 08:03:42
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 nice example where this would make sense too IMHO are libraries like jQuery that have to consider all those browser peculiarities. Projects that have to keep legacy compatibility would probably also be a good target audience for such techniques. I'm especially interested in ruby solutions but language independent patterns or good examples from

Advice on working with legacy code

穿精又带淫゛_ 提交于 2019-12-04 07:40:37
问题 I need some advice on how to work with legacy code. A while ago, I was given the task to add a few reports to a reporting app. written in Struts 1, back in 2005. No big deal, but the code is quite messy. No usage of Action forms, and basically the code is one huge action, and a lot of if-else statements inside. Also, no one here has functional knowledge on this. We just happened to have it in our contract. I'm quite unhappy about this, and not sure how to proceed. This application is

Passing scalars and array elements to a procedure expecting an array

两盒软妹~` 提交于 2019-12-04 04:57:14
问题 I have some legacy Fortran 77 code which I'm trying to at least compile without warnings (without disabling warnings). There are subroutine calls that pass a scalar where subroutine expects an array, since the scalar is used as a size-1 array, this causes no problems. But with the Intel compiler, if I enable interface warnings I get this error : error #8284: If the actual argument is scalar, the dummy argument shall be scalar unless the actual argument is of type character or is an element of

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

北城余情 提交于 2019-12-04 04:30:48
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 should be parameterized The clean fix would be if JSONObject were genericized, but since it isn't, I can't add any generic type parameters to fix this. I'd like to switch off as few warnings as possible, so adding "@SuppressWarnings("unchecked")" to lots of methods is unappealing, but do I have any other option besides putting up with the warnings?

Understanding a big company project in Java [closed]

筅森魡賤 提交于 2019-12-03 21:05:38
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . what is the best way to understand a big company project in java? 回答1: You'll never know every line of every piece of code at a company. What you CAN do is understand the classes, what they do, and how they relate to each other. Start by getting the most basic understanding of

How to go about mocking a class with final methods?

天大地大妈咪最大 提交于 2019-12-03 14:33:06
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 B { String methodIWantToTest(A a) { String output = a.foo(); // ... whatever this method does, e.g.: output += "_suffix"; return output; } } How would I go about unit testing this method? The reason foo() is final is because we don't want our classes which extend A to change its functionality. But at the same time to truly unit test the method, I don't want it to

Practical refactoring using unit tests

蹲街弑〆低调 提交于 2019-12-03 12:10:47
问题 Having just read the first four chapters of Refactoring: Improving the Design of Existing Code, I embarked on my first refactoring and almost immediately came to a roadblock. It stems from the requirement that before you begin refactoring, you should put unit tests around the legacy code. That allows you to be sure your refactoring didn't change what the original code did (only how it did it). So my first question is this: how do I unit-test a method in legacy code? How can I put a unit test