Tag Info

New answers tagged

1

You might want to check whether you can still use some sensible abstractions and use e.g. the template method pattern to write understandable code for the common functionality and move the differences between the methods into the "primitive operations" (according to the pattern descrition) in 12 subclasses. This will mightily improve maintainability and ...


0

There is absolutely nothing wrong with the 'problem' you mentioned. From what I know this is the exact kind of design and approach used by DB server to have good performance. They have lot of special methods to make sure they can maximize the performance for all kinds of operations: join, select, aggregate, etc... when certain conditions apply. In short, ...


1

No sane Java method can be long enough to have 12 variants... and JITC hates long methods - it simply refuses to optimize them properly. I've seen a speed up factor of two by simply splitting a method into two shorter ones. Maybe this is the way to go. OTOH having multiple copies may make sense even if there were identical. As each of them gets used in ...


-2

How old is the program? Most probably newer hardware would remove the bottleneck and you could switch to a more maintainable version. But there needs to be a reason for maintenance, so unless your task is to improve the codebase, leave it be as it is working.


8

Really make sure than under real, production, conditions (realistic memory consumption, that triggers Garbage Collection realistically, etc), all those separate methods really make a performance difference (as opposed to having only one method). This will take a few days out of your time, but may save you weeks by simplifying the code you work with from now ...


-1

If the function in question is large, turning the "mode/paradigm" bits into an interface and then passing an object that implements that interface as a parameter to the function can work. GoF calls this the "Strategy" pattern, iirc. If the function is small, the increased overhead may be significant... did somebody mention profiling yet?... more people ...


20

This is a very bad situation, you need to refactor this ASAP - this is technical debt in it's worst - you don't even know how important the code really is - only speculate that it's important. As to solutions ASAP: Something that can be done is adding a custom compilation step. If you use Maven that is actually fairly simple to do, other automated build ...


15

Is the maintenance hit real, or does it just bother you? If it only bothers you, leave it alone. Is the performance issue real, or did the previous developer only think it was? Performance problems, more often than not, are not where they are thought to be, even when a profiler is used. (I use this technique to reliably find them.) So there is a ...


6

Why not include some sort of template preprocessor\code generation for this system? A custom extra build step that executes and emits extra java source files before compiling the rest of the code. This is how including web clients off of wsdl and xsd files often works. You'll of course have the maintenance of that preprocessor\code generator, but you ...


0

Without being puritanical: prefer functional style. Most languages these days (.NET, Ruby, Python, Javascript, etc.) support and promote it (e.g. LINQ, underscorejs). It is exceedingly easy to read. var recentTopCustomers = OrderList .Where(o => o.Date >= DateTime.Now.AddDays(-5)) .Where(o => o.Amount > 1000) .OrderBy(o => ...



Top 50 recent answers are included