refactoring

Benefits of migrating my work to a new web development framework?

When I first started programming with PHP, I was ignorant of other php frameworks (like code igniter, cake php, etc...). So I fell into the trap of re-inventing wheels, which had the benefit of being "fun" and "educational". Overtime, I discovered other open source products that I found useful, like smarty templating engine, jquery lib...

Visual studio: automatically update C++ cpp/header file when the other is changed?

For example, if I change the signature in a function in either the header or the cpp, I'd like it to automatically change in the other one. If I add a new function in either, it should appear in both. If I delete a function, it could probably comment out the other one. Manually having to duplicate one's changes seems silly. Some people ...

Bad Design? Constructor of composition uses `this`

Example: class MyClass { Composition m_Composition; void MyClass() { m_Composition = new Composition( this ); } } I am interested in using depenency-injection here. So I will have to refactor the constructor to something like: void MyClass( Composition composition ) { m_Composition = composition; } Howe...

Changing property stubs for Interface refactoring

Is it possible to change the stub used to implement interfaces in Visual Studio 2008? For instance, when I choose either Implement interface 'IMyInterface' or Explicitly implement interface 'IMyInterface' Instead of a number of properties that look like this: public string Comment { get { throw n...

Access Violation Using memcpy or Assignment to an Array in a Struct

Update 2: Well I’ve refactored the work-around that I have into a separate function. This way, while it’s still not ideal (especially since I have to free outside the function the memory that is allocated inside the function), it does afford the ability to use it a little more generally. I’m still hoping for a more optimal and elegant s...

Refactor Pro versus Visual Assist X for C++ Development

There are two major refactoring tools which can be installed for Visual Studio that provide C++ support. The full versions of both tools are $250, and they seem to offer similar functionality. They are: Developer Express' Refactor Pro + CodeRush Whole Tomato's Visual Assist X Which tool is better? EDIT: My initial evaluation of the ...

Better way to write this SQL

I have the following table: create table ARDebitDetail(ID_ARDebitDetail int identity, ID_Hearing int, ID_AdvancedRatePlan int) I am trying to get the latest ID_AdvancedRatePlan based on a ID_Hearing. By latest I mean with the largest ID_ARDebitDetail. I have this query and it works fine. select ID_AdvancedRate...

refactor LINQ TO SQL custom properties that instantiate datacontext

I am working on an existing ASP.NET MVC app that started small and has grown with time to require a good re-architecture and refactoring. One thing that I am struggling with is that we've got partial classes of the L2S entities so we could add some extra properties, but these props create a new data context and query the DB for a subset...

Singleton class design in C#, are these two classes equivalent?

I was reading up on singleton class design in C# on this great resource and decided to go with alternative 4: public sealed class Singleton1 { static readonly Singleton1 _instance = new Singleton1(); static Singleton1() { } Singleton1() { } public static Singleton1 Instance { get { ...

Change namespace/filesystem folder names in Visual Studio

I'm trying to change a namespace in Visual Studio. My folder structure looks something like this: GameAlpha/ GameAlpha.sln GameAlphaRelease/ GameAlphaTest/ GameAlphaLevelEditor/ These include namespaces like GameAlphaRelease. I want to change all this to GameBetaRelease. Before this process, it bu...

Javascript source code analysis ( specifically duplication checking )

Partial duplicate of this Notes: I already use JSLint extensively via a tool I wrote that scans in intervals my current project directory for recently updated/created .js files. It's drastically improved productivity for me and I doubt there is anything as good as JSLint for the price (it's free). That said, is there any analysis tool...

Should I refactor this code?

The code is for a view debate page. The code is supposed to determine whether or not to show an add reply form to the viewing user. If the user is logged in, and the user is not the creator of the debate, then check if the user already replied to the debate. If the user did not already reply to the debate then show the form... Otherw...

Can I use Ninject ConstructorArguments with strong naming?

Well, I don't know if "strong naming" is the right term, but what I want to do is as follows. Currently I use ConstructorArgument like e.g. this: public class Ninja { private readonly IWeapon _weapon; private readonly string _name; public Ninja(string name, IWeapon weapon) { _weapon = weapon; _name = ...

Ruby: Is there a better way to iterate over multiple (big) files?

Here's what I'm doing (sorry for the variable names, I'm not using those in my code): File.open("out_file_1.txt", "w") do |out_1| File.open("out_file_2.txt", "w") do |out_2| File.open_and_process("in_file_1.txt", "r") do |in_1| File.open_and_process("in_file_2.txt", "r") do |in_2| while line_1 = in_1.gets do ...

can you simplify and generalize this useful jQuery function, please?

Hi, I'm doing an eshop with goods displayed as "tiles" in grid as usual. I just want to use various sizes of tiles and make sure (via jQuery) there are no free spaces. In basic situation, I have a 960px wrapper and want to use 240x180px (class .grid_4) tiles and 480x360px (class .grid_8) tiles. See image (imagine no margins/paddings th...

How could I refactor this into more manageable code?

Is this code even complex enough to deserve a higher level of abstraction? public static JsonStructure Parse(string jsonText) { var result = default(JsonStructure); var structureStack = new Stack<JsonStructure>(); var keyStack = new Stack<string>(); var current = default(JsonStructure); var currentState = ParserS...

Restful authentication + Facebook connect - User model redesign

I have a site with Restful authentication as authentication plugin. I need to integrate Facebook connect. Facebook does not provide email address for the user (maybe only if user agrees if), and of course does not provide a password. The main issue is that the User model has a lot of validates_** on those 2 fields (from Restful authent...

Refactoring an ASP.NET 2.0 app to be more "modern"

This is a hypothetical scenario. Let's say you've just been hired at a company with a small development team. The company uses an internal CRM/ERP type system written in .NET 2.0 to manage all of it's day to day things (let's simplify and say customer accounts and records). The app was written a couple of years ago when .NET 2.0 was j...

How do I force Coderush to always display the context menu when I trigger a Refactor?

It seems that starting v9.3 by default CodeRush disables the Refactor context menu and performs the Refactor if there is only one option. How do I force Coderush to always display the context menu when I trigger a Refactor even if there is only one option? ...

Good readings about refactoring data structures

Nowadays most programmers know about code refactorings. What about refactorings of data structures, are there any good readings about it? One paradigm that I can think of is the normalization process of a relational database. Are there any other good examples? ...