I have a factory class, DocumentLoaderFactory, which simply returns an instance that implements an interface, IDocumentLoader.
All implementation resides under the following namespace
Skim.Ssms.AddIn.ActiveFileExplorer.Loader
But what I am wondering is, which namespace does DocumentLoaderFactory belong?
I have placed the factory c...
i have taken over a website that has tons of css files and lots of inline css as well. Is there any tool that can show me a visualization of how this stuff is organized as i have a strong feeling that. Many pages are bringing in more css than necessary
Also, i want to remove all the inline formatting as well into css files. Is there ...
In our CORE library we offer this class as a 20,000 line abstraction.
Can you see anything wrong with the way this is designed?
Note1: This class has a SharpZipLib backing.
Note2: SharpZipLib is approximately 20K lines.
public static class Compression
{
public static Byte[] CompressBytes(Byte[] input);
public static Byte[] C...
I have a method that will receive a string, but before I can work with it, I have to convert it to int. Sometimes it can be null and I have to change its value to "0". Today I have:
public void doSomeWork(string value)
{
int SomeValue = int.Parse(value ?? "0"); //it can throw an exception(i know)
}
I did it, but my boss asked me t...
Hi everyone,
I'm actually struggling with some piece of code. I do know that it can be refactored, but I can't find the nice-smart-elegant solution.
Here are two functions (much more functions of that kind are in my code):
def fooA(param1, param2):
if param2 == True:
code_chunk_1
fooA_code #uses only param1
if pa...
I have the following models:
class FieldEntryValue < ActiveRecord::Base
belongs_to :field_entry
end
and
class FieldEntry < ActiveRecord::Base
belongs_to :field
belongs_to :media
has_many :field_entry_values, :dependent => :destroy
accepts_nested_attributes_for :field_entry_values, :allow_destroy => true
end
The FieldEntri...
When I wish to bind a control to a property of my object, I have to provide the name of the property as a string. This is not very good because:
If the property is removed or
renamed, I don’t get a compiler
warning.
If a rename the property
with a refactoring tool, it is
likely the data binding will not be
updated.
I don’t get an er...
This JS will be executed on pages with a lot of fields. Can you see anyway to improve the speed of this code? If so, can you explain what you found?
var _TextInputs = null;
function GetTextInputs()
{
if (_TextInputs == null)
{
_TextInputs = jq('input[type=text]');
}
return _TextInputs;
}
var _Spans = null;
func...
I have joined a rails project as a contractor. The project has been going for more than a year. The code is written by about 10 different developers and most of them are contractors as well. They have different code style. Some of them came from Java. The code has horrible scores with metric_fu. Many functions are very long (100 - 300 li...
Hey. This example is pretty specific but I think it could apply to a broad range of functions.
It's taken from some online programming contest.
There is a game with a simple winning condition. Draw is not possible. Game cannot go on forever because every move takes you closer to the terminating condition. The function should, given a st...
Hello,
i`m working on the legacy project in VB6 with huge object all with public variables.
I want to convert these public variables to private variable/property combinations.
Is there some tools with which i can do these conversion?(optimally all variables in class at once)
Thanks
...
Following Uncle Bob's avice in Clean Code, I'd like to have no SQL in my PHP code. Presently I'm making use of Prepared Statements and I've factored my database access code into model classes.
My initial thought is to break out my SQL into separate SQL files and then load them at runtime. Since this involves more disk IO (my gut feeli...
Let's say I am writing a class in Cocoa to act as a proxy to a server. To represent the current state of the connection, consider the enumeration:
enum
{
MyConnectionStatusDisconnected = 0,
MyConnectionStatusConnecting,
MyConnectionStatusConnected,
MyConnectionStatusCount
};
typedef NSUInteger MyConnectionStatus;
I may...
The TDD circle is:
"Write failing Test" -> "Write Code to fit a Test" -> "Refactor"
At "Coding" step we are assumed to write code as simple as possible, just to fix a failing test. We should not write complex code until it is really required.
The next step is Refactor. Should we refactor just written code? I think there is no real se...
In Eclipse's "Package Explorer", let's say I have a list of packages like this:
com.dog
com.cat
com.frog
If I want to rename the "com" part of the package structure to be "animal", then I could select each package (above) and perform a refactor > rename.
If I have many packages that start with "com", that process may take a while. ...
I refactor some classes from standard SQL to JPA/ORM usage. In most cases the Objects have a "real" reference but sometimes the references to other objects are only given by an unchecked database id reference (no foreign key, just simple a string with a reference to another table id).
The code looks like:
@Entity
public final class my...
I have a page in one of my client's websites that generates an extensive report pulling data from numerous tables throughout the website's MS Access database. One of the unfortunate architectural issues of the website is the existence of two nearly identical tables that represent the same "type" of data, but one is an "old" version and t...
I was doing a little exploring of a legacy system I maintain, with NDepend (great tool check it out), the other day. My findings almost made me spray a mouthful of coffee all over my screen. The top 3 functions in this system ranked by descending cyclomatic complexity are:
SomeAspNetGridControl.CreateChildControls (CC of 171!!!)
SomeF...
When refactoring methods it is easy to introduce binary incompabilities (with previous versions of the code) in Java.
Consider changing a method to widen the type of its parameter to a parent interface:
void doSomething(String x);
// change it to
void doSomething(CharSequence c);
All the code that uses this method will continue...
I have several horrors of old ASP web applications. Does anyone have any easy ways to find what scripts, pages, and stored procedures are no longer needed? (besides the stuff in "old___code", "delete_this", etc ;-)
...