Tag Info

Hot answers tagged

54

This may be a cultural thing. In some cultures, admitting that you made a mistake is unheard of, and asking someone to admit to making a mistake is about the rudest thing you can do. If it is that situation, run away. In my experience with very smart people, if you tell them that something they are doing is less than perfect, they will either (1) give you ...


37

It will earn the company F million pounds, over t years at a cost of x dev-days work Which is ignoring maintenance costs, support costs, the cost of sales/marketing, and makes a whole lot of assumptions about how the feature will be taken in the marketplace. But whatever; your question is clear enough about what you're looking for: How can I make a ...


25

Shipped, imperfect code is better than perfect code on the whiteboard that never gets shipped. That being said... Those of you with more experience, or that have been in similar situations. What did you do? What would you recommend I do? I would consider the following. What is the purpose of this project? Fun? Money? To learn? Are you actually ...


12

Possibly the easiest way is to bring someone else into the project - either you're wrong and his codebase is just too clever for you, or you're right and its too clever for everyone. You'll soon find out, and will get backup if it does turn out to be rubbish, convoluted, junior-programmer level code. On the other hand, a working product is worth any number ...


10

The question you should ask yourself is how is the salesperson know that the feature will cost x developer-days of work. Given that even good project managers with years of professional experience cannot often tell that, such data coming from a salesperson seems extremely... speculative. According to my experience, salespersons usually don't make estimates, ...


9

Am I justified in making the refactoring (assuming we have time allocated for cleaning up code)? Are you doing anything else in this code? If not, this seems not worth the effort. Your peer is likely right that you aren't ever going to use other things - and that you should keep things consistent. If you are, then cleaning this stuff up too seems like ...


9

Before grabbing into the "modern C++" bag, let us keep things simple and start with some classic, language agnostic techniques. One solution is to make a function of the form void myfunc(int i,bool upward) { identical_lines identical_lines identical_lines if(upward) first_for_specific_line else ...


8

Here are some ideas even if some of them are mutually exclusive. Separate source responsibilities. If you work on Module A and him on Module B you can compete with your different styles. Is he releasing working features often? Does he reach a point where he needs to rewrite his code from scratch? Refactor the code from your modules and do not touch him's, ...


5

Your scenario seems like you have placed an entire "message processing subsystem" inside a single function. In order to simplify the function, you will need to come up with an actual message processing subsystem consisting of several classes. Some, if not all, of these classes will need to be instantiated, allowed to run, and discarded on each invocation ...


4

Ok, here is an answer you will probably not like. Do not 'correct' the code unless it fails to implement the feature. Here's my reasoning. You are presumably trying to make money. To make money you have to ship completed features quickly. No one is going to pay you more for a 'well coded' computer game. Most companies have the same problem. Refactor ...


3

Firstly, you need to estimate the dev cost for the re-factoring as you would the sales driven feature request. This may well be tricky to get accurate if it's a large job but, assuming you have sufficiently experienced people in the 2 technologies, it should be doable. Secondly, you need an estimate of the cost of not re-factoring. If you were doing the ...


3

I like all of the answers so far. Taking one of the points from enderland's answer: Are there benefits to working with someone on a voluntary basis when it's frustrating? I'd like to take this time to plug for the code review stack exchange. It's a wonderful place where you can get your code critiqued by professionals. And honestly, a lot of the ...


2

It sounds pretty hopeless. I would probably give up and move on if I felt about it as you do; there definitely comes a time to walk away and you may be there. If you're not ready to walk away yet, you need to find a way to come to better agreement about your process. It sounds like you have coding standards, but not agreed-upon standards. Next time you ...


2

The value of refactoring comes up in multiple different ways. It helps you make other changes later, so the X days the that feature would have taken would now take 2/3X days to complete. To use the agile terminology it increases velocity. The explicit change listed would over time help since you would no longer need to maintain developers with VB6 ...


2

Assuming you decide to abandon the project: Fork the code and refactor it, using it as a 'before/after' portfolio item Since the goal was (mainly or partly) to learn programming and since learning something takes 2-4x as long as doing something you know already, that work is not really wasted. 'Sunk cost attachment' (the investment you've already made in ...


2

I think the point the other answers miss is you need to measure the cost of refactoring against the lost revenue from not refactoring. Refactoring for the sake of changing code is a waste of time. It needs to bring value to the table. In this context I do not mean spending an hour refactoring a problem class, but the major refactoring such as changing to a ...


1

In term of performance, there will be virtually no difference between the two considered options. Theoretically, the Single Responsibility Principle suggests that the solution with several small functions called by the big one is preferable if the small functions make sense. Are there semantically well defined? When you read the function names and the ...


1

It depends on how much of a performance hit you can reasonably accept when throwing the exception. If it only happens once, it might not be a big deal. If it happens every line of the file, it could be a huge problem. Normally exceptions are thrown when something happens that you can't do anything about, and execution is stopped.


1

Replacing conditional with polymorphism (see Refactoring, Martin Fowler, page 255) is indeed the refactoring which comes into mind. You've already did it partially, by: Creating classes, one for normal price, another for the promotional one. Moving the business logic to the newly created classes. The remaining part is to: Create the hierarchy. It ...


1

There's more than one way to skin a cat. Try again until you find a solution that resolves everyone's concerns. Part of the problem is you haven't really broken the coupling on the caching code all the way. I would start with something like this: public class WidgetRepository { public Widget GetWidget(int id) { return ...


1

The value of refactoring cam be measured like so: currently new feature x will cost 5 devs 2 weeks. If we refactor y old component, the cost of new features will be reduced by an estimated 20%. So new feature x will only cost 4 devs over 5 weeks. Refactoring is an investment in reducing the cost of future developments. If you can't make that argument for ...


1

Benefits of having a refactored system You make a business case for refactoring by comparing the business bottom-line benefits between doing and not doing it. It means either reduction of current real costs, or an increase in future real cash inflow. The key budget items affected by refactoring are the follows: Maintenance costs - if the current system ...


1

To add additional points to all the great answers: How much more effort will it take to finish the project? Note that finishing the "last 10%" takes much much longer than people expect. That includes play testing/tuning, usability fixing, coping with a variety of target platforms, releasing, ... If it's an iOS game, then there's code signing and getting ...


1

I'd got pretty much the same question, but this time in Java. I found one solution that uses non-static nested classes in java - which in C++ would translate to something like: class AI // : public Country { private: Country *pCountry; public: class Super : public Country { AI* outerThis; public: Super(AI* outer, ...) ...



Only top voted, non community-wiki answers of a minimum length are eligible