This is a snippet from a prototype class i am putting together. The scoping workaround feels a little hacky to me, can it be improved or done differently?
var myClass = Class.create({
initialize: function() {
$('formid').getElements().each(function(el){
$(el).observe("blur", function(){
this.valid...
I'm a TDDer and often have a need to refactor out common or similar code. If it is exactly the same there is no big problem, Eclipse can almost always do that by itself. But to get there I'm finding myself often looking at similar, but not identical, code fragments in the same, or even different, files.
It would be very handy if there w...
Hi all,
I have two tables which look kind of similar and i was thinking about combining them and thought i would get some input from everyone.
Here's what they currently look like:
Issues
Id | IssueCategory | IssueType | Status | etc..
-------------------------------------------------
123 | Copier | Broken | Open |
1...
Is there a simpler way of reordering methods within a class source file in IntelliJ than cutting and pasting the code manually? Nowadays I often need this while refactoring legacy code, e.g. to move related methods close to each other in the source code.
In Eclipse AFAIK there is a view similar to the Structure view of IntelliJ, where I...
I'm considering purchasing a resharper license but would like to know if there are any possible alternatives to resharper and how would you rate these compared to reharper?
It doesn't necessarily have to be a free alternative but I would just like to know how good equivalent products are.
...
I have a function irc_sendline that can be called like printf can
irc_sendline(s, "A strange game.\nThe only %s is not to play.", "winning move");
It works perfectly, but I'm not happy with its implementation:
int irc_sendline(irc *iobj, char *msg, ...)
{
char tmp_msg[BUFSIZE], fmsg[BUFSIZE];
va_list args;
int len;
va_st...
I just completed a complex piece of code. It works to spec, it meets performance requirements etc etc but I feel a bit anxious about it and am considering rewriting and/or refactoring it. Should I do this (spending time that could otherwise be spent on features that users will actually notice)?
The reasons I feel anxious about the code ...
Is there a more pythonic way of doing this? I am trying to find the eight neighbours of an integer coordinate lying within an extent. I am interested in reducing its verbosity without sacrificing execution speed.
def fringe8((px, py), (x1, y1, x2, y2)):
f = [(px - 1, py - 1),
(px - 1, py),
(px - 1, py + 1),
...
I'd like to rewrite such function into F#:
zipWith' :: (a -> b -> c) -> (a -> c) -> (b -> c) -> [a] -> [b] -> [c]
zipWith' _ _ h [] bs = h `map` bs
zipWith' _ g _ as [] = g `map` as
zipWith' f g h (a:as) (b:bs) = f a b:zipWith f g h as bs
My first attempt was:
let inline private map2' (xs : seq<'T>) (ys : seq<'U>) (f ...
And if so are there Eclipse plugins that add those types of code refactoring to eclipse?
note:for C#/Java respectively.
...
As I understand it, you can enter any non-structured information into a document-oriented database. Let's imagine a document like this:
{
name: 'John Blank',
yearOfBirth: 1960
}
Later, in a new version, this structure is refactored to
{
firstname: 'John',
lastname: 'Blank',
yearOfBirth: 1960
}
How do you do this with Docu...
I just finished reading the "Functions" chapter from Uncle Bob's Clean Code. The main advice was to make sure that functions are short -- really short. And they should only do one thing per level of abstraction. Here's a function from an app I'm making to learn Cocoa (idea from Andy Matuschak).
- (IBAction)go:(id)sender
{
NSString *outp...
Looking at the (mature) codebase at my new job, there is an interface, and only one class implements it (as far as I can tell). Can/should I get rid of the interface?
...
Suppose I have a table amountInfo with columns (id, amount1, amount2, amount3)
where amountX are money values and id is an int value ranging from 1 to some int under 10.
Currently I have some code that approximately does this:
declare @id int, @idmax int, @amounttotal money
select @idmax = (select max(Id) from amountInfo)
while (@id <=...
I've found myself coming across a lot of reasonably large, complicated codebases at work recently which I've been asked to either review or refactor or both. This can be extremely time consuming when the code is highly concurrent, makes heavy use of templates (particularly static polymorphism) and has logic that depends on callbacks/sig...
I currently have code like this in a web based file called 'view_file.php' to grab an image from an internal network.
<img src="put_file.php?type=<?=$TN_TYPE;?>&path=<?=$TN_PATH;?>&filename=<?=$TN_FILENAME;?>" />
The 'put_file.php' script allows access to an internal server that we don't want to expose to the internet. This script che...
Hello guys,
How can I refactor that code ?
public enum enum1
{
value1 = 0x01,
value2 = 0x02,
value3 = 0x03,
value4 = 0x04,
value5 = 0x05,
UNKNOWN = 0xFF
}
class class1
{
private const string STR_VALUE1 = "some text description of value1";
private const string STR_VALUE2 = "some text description of value...
we have a big portal that build using SharePoint 2007 , asp.net 3.5 , SQL Server 2005 .. many developers work in it since 01/2008 and we are now doing huge analysis for current SQL Databases [not share-point DB ] to optimize and enhance it.
The main db have about 330 table and 1720 stored procedure (SP) created from 01/2008 till now
Ma...
Suppose I have a table with columns (DayId, RunningTotal):
DayId RunningTotal
---------------------
1 25
3 50
6 100
9 200
10 250
How can I select the DayId and the amount the RunningTotal has increased from the previous day? i.e. how can I select:
DayId DayTotal
---------------------
1 2...
Hi,
I'm working on an old site that needs to be optimised, I've installed Refactor! and its coming up with lots of recommendations, including lots of instances where objects aren't disposed off. Is there a way to create a report of these recommendations or another tool that I could use?
Thanks,
Chris.
...