Here's my current query:
SELECT IFNULL(sum(open_for), 0) total, count(IF(open_for > 0, 1, null)) wins, count(IF(open_for < 0, 1, null)) losses FROM `sport_points` WHERE (sportable_id = 1 and sportable_type = 'Team' and game_time > '2010-07-13 11:39:58 UTC'
It basically returns this aggregated data:
TEAM A
open_for
total: 2000
win...
i have this process that is the heart of my app, that im creating, but for some reason i feel like its the worst way to do it(instinct) , and i wanted to see if thier is something wrong with this process, and am i approaching it in a bad way! p.s. the code works fine, just refactoring problem.
the process is:
users go to homepage, they...
Is there a pattern to refactor such a construct into a readable single line?
def show_section
@news = News.all_active
@news = @news.where(:section => params[:section]) unless params[:section] == "all"
@news = @news.all
end
I use Rails 3 and Ruby 1.9.2
...
Well, I am not alone who is being sick of magical strings which are constantly used just to do data binding -- see:
http://stackoverflow.com/questions/1329138/how-to-make-databinding-type-safe-and-support-refactoring
However I am concerned with performance of this solution and much more typing -- each time you would like to use nameof ...
I have been assigned the task to refactor a Delphi unit. Wow. 10000 lines of code, no documentation, tons of copy and paste code.
THere are many methods made with copy and paste that could be refactored, anyway I am lost in all those lines, I have the interface section where I can "find my way", but in general what do yuo suggest for ta...
Hi,
Lately I've been a lot into agile methodologies. Some papers I've read at Martin Fowler's website looked thoroughly unflawed to me to say the least, and I was wondering what agile practices are most suited to game development, particularly for small-budget, small-sized and inexperienced team projects (bold because it's really import...
Possible Duplicate:
What tool to find code duplicates in C# projects?
I have to refactor a C# batch that has a lot of duplicates method in different files (Copy and Paste bonanza); essentially I would like to create a common librabry for all of this methods replicated on many .cs files.
Do you know if Visual Studio out of th...
I'm quite new to both ASP.Net and MVC.
I got the following code in my master page:
<div id="main-menu" class="menu">
<%
var items = (IList<CompanyName.Framework.Web.MenuItem>)ViewData["MainMenu"];
if (items.Count > 0)
{
%><ul><%
foreach (var item in items)
{
if (!string.IsNullOrEmpty(item.RequiredRole) && ...
Hello,
I have one module written on Java - web service module which accepts request process it(some business rules here), saves(modify or delete) values in db (using Hibernate) and then send status response). Is it reasonable to refactor that module so at the end there will be 2 modules - 1 is web service module and 2 - processing mo...
Hi all,
I have a "Course" class which contains collection of "CourseItems".
Each CourseItem has a folder associated with it(for its files).
I need to add the CourseItem to a Zip file and after zipping it encrypting.
Using FZip and As3crypto I can do the zip and encrypt the zip file.
Whether to do Encryption or not is upto the user .
Cur...
I'm currently in the process of evaluating the design, and possible reimplementation of an in-house app our engineers use.
Although the application handles large amounts of data. Only two sets of values (floats) are saved along with a simple name and description of the data. In my opinion the current application is in overkill territory...
Does a refactoring (able do conscious language-aware rename classes/variables renaming and replace simple constructions instead of doing dumb string search-and-replace) tool exist which can be used without IDE/editor?
I am particularly interested in Scala, C# and PHP languages.
...
C++ and C# are quite simmilar programming languages, in my opinion. If a C++ code needs to be ported to platform where C# is the only supported platform, how much work will need to be done?
Should I get ready, that most of the C++ code will need to be rewritten to C#? Or, because of language simmilarities, should refactoring be quite ea...
I am working in Java, inserting data from HashMaps of certain types into a SQL database. It has produced some code like this:
for ( String key : strings.keySet() ) {
result_set.updateString(key, strings.get(key));
}
for ( String key : booleans.keySet() ) {
result_set.updateBoolean(key, booleans.get(key));
}
for ( String key : ...
After months of frustration and of time spent in inserting needles in voodoo dolls of previous developers I decided that it is better try to refactor the legacy code.
I already ordered Micheal Feather's book, I am into Fowler's refactoring and I made some sample projects with DUnit.
So even if I don't master the subject I feel it is ti...
I have two setup scripts that share common code. It is possible to refactor them?
One way of doing that is having a file for common code which will be referenced by each script.
Is this possible?
...
I've been assigned to do some work on a huge Java project, and the influence of several iterations of developers is obvious. There is no standard coding style, formatting, naming conventions or class structure. It's a good day when I come across a class with Javadoc, and unit testing is a happy daydream.
So far those of us on the proj...
what is the best way to optimize the following snippets that uses delegate()?
jQuery('.menu').delegate('li.gallery', 'hover', function () { jQuery(this).children('.submenu').toggleClass('hide show'); });
jQuery('.menu').delegate('li.interior', 'hover', function () { jQuery(this).children('.submenu').toggleClass('hide show'); });
jQuery(...
Eclipse is warning that I'm using a depricated method:
eventDay = event.getEvent_s_date().getDate();
So I rewrote it as
eventDay = DateUtil.toCalendar(event.getEvent_s_date()).get(Calendar.DATE);
It seems to work but it looks ugly. My question is did I refactor this the best way? If not how would you refactor? I need the day num...
I know I can generate setters and getters for fields in the Eclipse source menu, but I'm very surprised it doesn't offer to replace the direct field accessors with calls to the newly created methods.
Does anyone know how to do this short of manual search and replace?
Thanks!
...