The refactoring tag has no wiki summary.
1
vote
1answer
36 views
Ruby code refactoring
I have n-times similar statements
if trigger_data.tt_closed
unless trouble_ticket.changes.key?(:status)
@run = 0
break
end
unless ...
2
votes
1answer
70 views
Parse a text file in python
I would like to refactor a large python method I wrote to have better practices. I wrote a method that parses a design file from the FSL neuroimaging library. Design files are text files with settings ...
1
vote
0answers
46 views
Setting variable in constructor or within method [migrated]
I have a class which contains two methods.
These methods add & remove an object to a datastore.
The class which contains these methods has a no arg constructor but each of the two methods takes ...
0
votes
0answers
34 views
Does this code follow loose coupling pattern or should be refactored/re-designed?
I've to adming i don't like this design.
The main class (SMSHelper) is responsible of query a REST web service which in turn returns an XML string. This helper is going to return a new SMSCreditInfo ...
2
votes
2answers
72 views
Factory-like pattern implementation
I have a hierarchy of types in my program and need to be able to create them dynamically at runtime. The solution I've come up with below is not the most elegant solution. Are there ways of improving ...
1
vote
2answers
62 views
Bubble sort algorithm in Ruby with tests
As a matter of practice, I tried implementing a bubble sort algorithm in Ruby. I'm especially interested in creating clean DRY and KISS code and keeping things readable, but efficient. Any hints to ...
3
votes
2answers
129 views
Refactor to make intention clearer and testable
I'd like to improve the readability of the following code. The aim of this code is to apply formatting to row(s) in a WinForms DataGridView based on the Priority of an item, determined either by its ...
0
votes
1answer
28 views
PHP illegal offset type in multiple loop structure
For reference, the function in question takes a URL structure which is most often a query string (but sometimes not) and generates filters to remove query var's from the URL. So if you're looking at ...
0
votes
1answer
66 views
Refactoring this state machine (upvoting/downvoting)
I have a list of resources which can be voted on.
There are 3 voting states: upvoted, downvoted and no vote.
In a fashion identical to stackexchange voting, it follows these rules:
If you upvote a ...
1
vote
4answers
113 views
Refactoring and condensing a Javascript function with many repeat conditions, strings, and variables
I have this function which is pretty easy to read and works just fine. I'm looking to advance my coding abilities by writing more concise code, though.
Does anyone know of an elegant way to condense ...
0
votes
2answers
77 views
Refactor c# comparision/filter logic
I have to write a comparison logic.
Following is the code to refactor (as it is looking bad).
// 1. item has filter criteria
// 2. return true if current matches filter criteria
// 3. Criteria ...
9
votes
5answers
244 views
Better test names
I have some simple tests written, however, the names are not good...I think, any suggestions on better names? I'm not really sure how these tests should be named.
I'm looking for a format or pattern ...
0
votes
0answers
31 views
How to refactor this cursor used in a SQL query
So I got this query from another analyst here and I'm a little stumped as to why a cursor was used instead of just joins. Could I please have some help trying to refactor it? I am using MSSQL 2008.
...
1
vote
1answer
51 views
Trying to use “this” to refer to a class's instance variable inside a function within the class's method in JavaScript
Hope that title makes sense.
This is part of an object I have:
The event listener attaches to the correct marker passed in the parameter but inside the function, this points to something else.
...
2
votes
2answers
82 views
Shuttle Puzzle: How can I Make This C++ Code Better
How can I make this piece of code better? The problem to be solved is in the top most comment.
#include <iostream>
#include <vector>
#include <cassert>
#include <stdint.h>
...