4
votes
4answers
208 views

How to avoid excessive method overloading?

We have quite a lot of places in the source code of our application , where one class has many methods with same names and different parameters. Those methods always have all the parameters of a ...
9
votes
6answers
432 views

Is it better to have one method that takes a bool as a parameter or two methods with different names? [duplicate]

I'm writing a factory class for a Selenium Web Driver and I came across a choice that I couldn't figure out which is cleaner. Having two methods with the same parameter. GetWebDriver(string browser) ...
1
vote
1answer
75 views

A better approach to refactor code when doing A/B Testing

I'm asked to refactor my component code to support A/B Testing. What is the better approach: 1) Pass a boolean value to the methods and check for that flag inside the method body? method(flag ...
42
votes
12answers
3k views

Coding style (do more, then simplify) [duplicate]

I'm a CS student and I have been coding for a few months shy of a year now, and I seem to have developed what I think may be a "bad" habit and I'm wondering if anyone does the same (or whether it's a ...
4
votes
7answers
500 views

Naming guard clauses that throw exceptions

I have a function evaluate() that parses a String for some variables and replaces them with their corresponding value: public String evaluate() { String result = templateText; for ...
7
votes
3answers
532 views

Cleaning Up Generated Code: Refactor or Map?

Context: I recently had to deal with a class file generated by XSD.exe. It was 3500 lines long with ridiculously-verbose class / variable names (think ...
21
votes
6answers
1k views

How do I prevent unknowningly duplicating code?

I work on a rather large code base. Hundreds of classes, tons of different files, lots of functionality, takes more than 15 minutes to pull down a fresh copy, etc. A big problem with such a large ...
27
votes
9answers
2k views

How clean should new code be? [duplicate]

I'm the lead designer in our team, which means I'm responsible for the quality of the code; functionality, maintainability and readability. How clean should I require my team members' code to be if ...
95
votes
16answers
4k views

Should I remove unreferenced code?

I'm working on a medium sized (100k lines) code base, it's all relatively recent code (less than a year old) and has good unit test coverage. I keep coming across methods which are either no longer ...
28
votes
12answers
2k views

What is best practice on ordering parameters in a function?

Sometimes (rarely), it seems that creating a function that takes a decent amount of parameters is the best route. However, when I do, I feel like I'm often choosing the ordering of the parameters at ...
13
votes
3answers
353 views

Low impact refactoring and code cleaning of sloppy code while waiting for requirements

I inherited an existing code base for a product that is reprehensibly sloppy. The fundamental design is woefully inadequate which unfortunately I can do little about without a complete refactor (HIGH ...
22
votes
18answers
2k views

Why write clean, refactored code? [duplicate]

This is a question I've been asking myself for a long time. Thought of throwing out it to you. From my experience of working on several Java based projects, I've seen tons of codes which we call ...
26
votes
6answers
801 views

What payoffs have you seen from taking care of technical debt?

This article on technical debt has some good points, including: Working on the "technical matters" works best when it is driven by stories. The code base is probably in need of work everywhere, ...