code-duplication

Code duplication refactoring tool for VB

I need a very specific tool for VB (or multi-language). I ask for it, before I start making one myself (probably, in python). What I need: The tool must crawl, recursivelly or not, a path, searching for a list of extension, such as .bas, .frm, .xxx Then, It has to parse that files, searching for functions, routines, etc. And finally, ...

How to share code between Pages and Masterpages without multiple inheritance/code duplication?

Hi, I've read the questions/answers explaining that there is no multiple inheritance in C#, that we don't even need it, and that it causes too much problems. Now, I'm working on a project where I don't really understand how can I do things without multiple inheritance, without duplicating code. Here's the situation. There is a website...

Identifying repeated code within PHP project

I have a single PHP file within a legacy project that is at least a few thousand lines long. It is predominantly separated up into a number of different conditional blocks by a switch statement with about 10 cases. Within each case there is what appears to be a very similar - if not exact duplicate - block of code. What methods are avail...

Avoiding code duplication (const-correctness) redux

I was reading this question here here regarding const-correctness. The Scott Meyer solution seems like a good work-around, but what if you have a member function (which requires both a const and non-const version) that makes use of the this pointer. If the member function is const then this automatically means const this, which can mak...

Variable value assignment operation duplication

Context From The Pragmatic Programmer: Every piece of knowledge must have a single, unambiguous, authoritative representation within a system. Questions How is that statement reconciled with directly setting a private member variable's value throughout a class in multiple places? Does it matter as there can be no external de...

How can you have two URL routes mapped to the same handler method in Spring MVC (3.0)?

I have a a userPanel method mapped to the /user/panel URL route: @RequestMapping(value = "/user/panel", method = RequestMethod.GET) public final String userPanel(HttpServletRequest request, ModelMap model) However, I would also like the userPanel method to handle the route /panel without creating a separate method such as this: @Requ...

Avoiding duplicate code (PHP)

As a sysadmin, I end up doing some simple ad-hoc programming every once in a while. I'm trying to learn as I go along, so in general, is there anything in the code below that jumps out at you as being bad practise or otherwise unnecessary? Specifically, the 3 if statements at the end feels like I'm duplicating code unnecessarily. Is the...