This is similar to this question, except the code is already written.
I have
JFrame
JTabbedPane
JPanel X
<...>
JPanel Y
<...>
JPanel Z
<...>
all defined in the same class, but I want to move each panel into its own .java file. I really don't want to manually copy-paste from the underlying .form and .j...
In unit testing, the setup method is used to create the objects needed for testing.
In those setup methods, I like using assertions: I know what values I want to see in those
objects, and I like to document that knowledge via an assertion.
In a recent post on unit tests calling other unit tests here on stackoverflow, the general feelin...
what are the advantages and disadvantages of refactoring tools, in general?
...
I have been practicing TDD in C# for several years now and recently have moved to Ruby on Rails full time. I am continuing the practice of TDD with RSpec. My question is regarding the process of finding references while refactoring. In Visual Studio I was addicted to Resharper's "find all references" when renaming or replacing methods.
...
I have an if else tree that is going to grow as I add additional items for it to maintain and I'm looking at the best way to write it for maintainability I'm starting with this code
private void ControlSelect()
{
if (PostingType == PostingTypes.Loads && !IsMultiPost)
{
singleLoadControl.Visible = true;
singleTru...
Do you refactor when you see things like this? Or do you just plug your nose and move on?
public Collection<DataValidationRuleBase> GetFieldValidationRules(String key)
{
Collection<DataValidationRuleBase> found = null;
try
{
this.mRules.TryGetValue(key, out found);
}
catch (Ar...
The discussion around global variables and their misuse seems to hold a a certain dogmatic tone to it. I am not here to dispute the "globals are bad" concept as it makes sense to me why they are bad. However I was wondering if people had some interesting code snippets that demonstrate exactly how to effectively refactor higher scoped var...
I have several methods that populate a SQLCommand objects parameter collection from an object like this
if (!String.IsNullOrEmpty(SearchObj.FirstName))
{
command.AddParameter(Fields.FirstName, SearchObj.FirstName);
}
if (!String.IsNullOrEmpty(SearchObj.LastName))
{
command.AddParameter(Fields.LastName, SearchObj.LastName);
}
if ...
We plan on changing our company name starting October 1st. All of our namespaces, projects etc use XYZ.ComponentName.
My question to you would be, on October 1st, what would you do? Change all the old components to ABC.ComponentName? Leave the old ones but any new development becomes ABC.ComponentName? Just stick with the old name?
...
I have inherited a large C# project where all the variable and parameter names are written_like_this.
Is there some easy way or tool I could use to rename them all automatically with no more than say 10 mouse clicks. So that the above example would become writtenLikeThis (i.e. camel case). And instance variables _writtenLikeThis.
It wo...
I'm still new to certain PHP functions.
Is there any way I can clean up the following code, because I know all of this is just unnecessary, and it's giving me a headache.
Everything after the if statement is the same for each set of code.
if($class == "2"){if ($posts >= 1){
$sql = "UPDATE users SET posts=posts+1,tposts=tposts+1,poin...
Does anybody know a fully featured refactoring tool for C++ that works reliably with large code bases (some 100.000 lines)?
I tried whatever i can find again and again over the last years: SlickEdit, Eclipse CDT. They all were not at all usable.
SUMMARY:
I took time and evaluated "Visual Assist X" as well as "Refactor for C++". Both h...
I want to ensure an object is unique, and to throw an error when a user tries to save it (e.g. via the admin) if not? By unique, I mean that some of the object's attributes might hold the same values as those of other objects, but they can't ALL be identical to another object's values.
If I'm not mistaken, I can do this like so:
class ...
Hello,
An enum structure declared in its own class is a member variable to the business logic class. That enum basically represents the state of that other class.
Although I have revisited the issue several times, replacing, or getting rid of those case statements proves quite frustrating to me.
Several business logic methods simple i...
Hello,
The following enum structure performs certain operations while remaining agnostic to the client class (for encapsulation reasons)
public enum MyEnum implements Commands{
A{
public int method1(int varY) {
return varY+2;
}
public MyEnum method2(){
return MyEnum.B;
...
Just calculating sum of two arrays with slight modification in code
int main()
{
int a[10000]={0}; //initialize something
int b[10000]={0}; //initialize something
int sumA=0, sumB=0;
for(int i=0; i<10000; i++)
{
sumA += a[i];
sumB += b[i];
}
printf("%d %d",sumA,sumB);
}
OR
int main()
{
...
I have some code that I want to refactor. I have lots of methods that take multiple arguments of the same type, for example:
public void foo(String name, String street, boolean b1, boolean b2) { ... }
and so on. Because the different objects can only be distinguished by name I would like to wrap them in Objects (Enums) so I can make u...
I recently attempted a large refactoring (yes I know smaller increments and unit testing along the way is preferred) that I just had to walk away from. It's not that I couldn't have done it, but I realized that the time to do it right wasn't justified in the business sense. Normally I am one to tackle refactoring with no fear because of ...
Hello - I ahve asked this on the Hibernate forums but no one seems to have been able to provide an answer so I am trying here! Thanks chaps!
I have a collection in my model that contains a set of 'previous versions' of my root domain object. The previous versions are therefore 'immutable' and we will never want to update them, and only ...
For reasons it's not worth getting into, the object Model of the django application I am working on is now "wrong" insofar as a number of relations that are 1 to Many are represented as Many to Many. The application functions correctly and is most of the way through QA. It has never been deployed.
My design OCD makes me want to refact...