Imagine a system of filters (maybe audio filters, or text stream filters).
A Filter base class has a do_filter() method, which takes some input, modifies it (perhaps), and returns that as output.
Several subclasses exist, built with TDD, and each has a set of tests which test them in isolation.
Along comes a composite class, of an unr...
After years of coding Delphi programs as untestable code in forms and datamodules, including global variables, and the only classes are the forms themselves, containing all the code I need for the form UI itself.
How would I convert the code to a set of classes that do the actual work? would I need to stop using the datasources/datasets...
I'm currently trying to DRY up this initial verbose code:
def planting_dates_not_nil?
!plant_out_week_min.blank? || !plant_out_week_max.blank? || !sow_out_week_min.blank? || !sow_out_week_max.blank?
end
def needs_planting?(week)
if !plant_out_week_min.blank? && !plant_out_week_max.blank?
(plant_out_week_min..plant_out...
I have four foreach loops that iterate through the collections and based on a condition do something. Here is the code that I am writing now:
boolean breakFlag = false;
String valueFromObj2 = null;
String valueFromObj4 = null;
for(Object1 object1: objects){
for(Object2 object2: object1){
//I get some value from object2
valueFr...
I've done some work for a personal project of mine, and now I understand why people tell us to plan out all our interfaces and design before coding. I've got some good classes and already have some working code, but all in all the the organization (architecture) is somewhat of a mess, and I'm already saying "If I did it again, I would do...
Are there any free refactoring tools available for Visual Studio 2003? ReSharper seems to require a license key.
...
Should I use VS 2008 refactoring support or buy ReSharper?
What are some of really good things you can do using ReSharper that cannot be done using VS 2008 refactoring support?
...
We have an internal Flex application which has been designed more through feature creep than by any kind of clear vision. It's basically a kind of CRM and reporting system which utilises quite a lot of Flex components (trees, graphs, custom components, datagrids - all sorts) and talks to a .NET webservice backend.
It was initially my fi...
I have the following code which I am are currently using .... Basically, this method assigns the correct boolean flag (TRUE/FALSE) for each Task. As more and more tasks need to be added .. I can see that the switch statement will have to grow to cater for every task.
There has to be an easier way ... to keep the method small.
Code: (fo...
I've got an ASP.NET (VB.NET) page that has an Infragistics grid on it. One of the columns is called 'status'.
When I load the grid, I'm setting permissions to the fields at the column level, granting user roles (ENUM 'UserTypes') read/only or read/write permissions.
Next I need to loop through each row and assign permissions based upo...
I'm starting on a project where strings are written into the code most of the time. Many strings might only be used in a few places but some strings are common throughout many pages.
Is it a good use of my time to refactor the literals into constants being that the app is pretty well established and runs well? What would be the long-t...
A colleague of mine refactored this code:
private void btnGeneral_Click(object sender, RoutedEventArgs e)
{
Button button = (Button)e.OriginalSource;
Type type = this.GetType();
Assembly assembly = type.Assembly;
string userControlFullName = String.Format("{0}.{1}", type.Namespace, button.Name);
UserControl userContr...
I have the following code in one of my Django templates that I want to refactor:
{% ifequal sort_type "set" %}
{% regroup cards by set as grouped %}
{% endifequal %}
{% ifequal sort_type "rarity" %}
{% regroup cards by rarity as grouped %}
{% endifequal %}
It does work, but it's really ugly and I want to make it more like this:
...
We have some really shocking code touted as a next generation framework at my current place of employment.
Thing is, there is only one person of this opinion and that is the guy who wrote most of it. The rest of the department are of the impression it is badly coded, a pita to debug and just a bit naff in general.
The guy that wrote it...
I have just started to learn Java and is curious is it any good practice in Java for good object decomposition? Let me describe a problem. In big software project it's always a big classes like 'core' or 'ui' that tends to have a lot of methods and are intended as a mediators between smaller classes. For example, if user clicks a button ...
At present we have a rather large (4k+ loc) function that we wish to decompose in to separate functions.
Some of it has been decomposed where there are relatively encapsulated side effects and these ones are the easy bits.
However we now have ~3k loc of intertwined nastyness. Some vars are passed to external functions by ref and all so...
I currently have an algorithm that operates on an adjacency matrix of size n by m. In my algorithm, I need to zero out entire rows or columns at a time. My implementation is currently O(m) or O(n) depending on if it's a column or row.
Is there any way to zero out a column or row in O(1) time?
...
Over the course of time, my team has created a central class that handles an agglomeration of responsibilities and runs to over 8,000 lines, all of it hand-written, not auto-generated.
The mandate has come down. We need to refactor the monster class. The biggest part of the plan is to define categories of functionality into their own cl...
Yet another TFrame IDE-registered-component question from me. Thanks for all the help, fellow programmers. : )
Playing around with Darrian's TFrame inheritance suggestion here:
Specifics:
Basically, I have a TFrame-based component that I've registered to the IDE, and it has worked wonderfully. I'm now developing a few "sister" compo...
I have some research code that's a real rat's nest, with code duplication everywhere, and clearly needs to be refactored. However, the code base is evolving as I come up with new variations on the theme and fit them into the codebase. The reason I've put off refactoring so long is because I feel like the minute I spend a few days comin...