Say I've got an existing constant string:
private final static String LOREM_IPSUM = "Lorem Ipsum";
Is there a way in Eclipse to quickly extract a substring of this as another constant such that I could end up with something like:
private final static String LOREM = "Lorem";
private final static String IPSUM = "Ipsum";
private final s...
This question is related to my experience with FOSS as a student.
Sorry I might be a bit subjective, but working with a certain approach here and would want to know if I am on the right track.
I am involved in project,where I am supposed to refactor code which has been already written by someone else but was never included in the main t...
I'm not doing much new development right now, but a lot of refactoring of older C# subsystems whose original requirements no longer support new and I'll add unexpected requirements. I'm also now using Rhino Mocks and unit tests where possible (vs 2008).
The dilemma for me is that to make the methods testable and mockable, I need to defi...
I have lots of small pieces of code that look like:
for it in <iterable>:
if <condition>:
return True/False
Is there a way I can rewrite this piece of code with a lambda expression ? I know I can factor it out in a small method/function, but I am looking for some lambda thing if it can be done.
...
Is there a tool that will scan your code and suggest which refactoring to perform, based on duplicate code segments that it finds?
Let's say I'm specifically interested in C#/Java, but I'm open for tools in other languages as well.
...
I understand well how Git can support file moves : as it uses file hash, a "added" file is easily detected as beeing same as the "removed" one.
My question is about refactoring : considering Java, the package declaration changes so the file content will NOT be the same. In such case, how does Git determine that the "added" file shares h...
Hi.
why visual Studio Does not have Refactor tool for vb.net by default ?
but it has this tool for c#.
for example extract method and etc.
thanks all.
...
I am looking for a good design pattern, or best practice to achieve a situation of "either this query, or else that other query", with best performance and least overhead.
Business logic/program of demans says "all items since Foo", unless that returns less then three items, then "all items".
I am refactoring the current code, and can...
I have a tree of objects, where each object has a std::vector of pointers to its children. The class of the object has a rewrite() method that is recursively applied to alter the object and its children, typically with the following transformations, where [N] is the object being rewritten and (M) is the element that rewrite() returns:
...
Hello Expert!!
I'm using liquibase on a project and i just realize what makes my build fails.i've successfully use command line generateChangeLog against the same schema in mysql and included that file in my master-change-log file.
For test environment i use hsqldb.Now all the table name are hyphen separated apart from language.Sinc...
I have a C# class that is serialized to disk by the BinaryFormatter, such as this example:
// Version 3.0
[Serializable]
public class Person
{
public string FullName;
[OptionalField(VersionAdded=2)]
public string NickName;
[OptionalField(VersionAdded=2)]
public DateTime BirthDate;
[OptionalField(VersionAdded=3)...
Hi,
I have a lot of classes which are basically equivalent, ie have almost the same functions in all respect. Let's call them A and B. There are hundreds of methods that are using A and now due to code changes I have to change them to B.
Is there a way by which I can program a mapping between A and B such that I have minimal code chan...
Example code :
EDITED : clarified example. Sorry for any confusion.
using System.Collections.Specialized;
using System.Configuration;
...
// get collection 1
NameValueCollection c1 = ConfigurationManager.AppSettings;
// get collection 2
ExeConfigurationFileMap map = new ExeConfi...
In the current project, there are lots of GetData() method, which
get different kind of data from hand written database at run time,
and set them in different fields in a class.
The projects then have such methods.
void GetData(Datatype type, int& value);
void GetData(Datatype type, double& value);
void GetData(Datatype type, long& valu...
I have some code that consists of a lot (several hundreds of LOC) of uggly conditionals i.e.
SomeClass someClass = null;
if("foo".equals(fooBar)) {
// do something possibly involving more if-else statments
// and possibly modify the someClass variable among others...
} else if("bar".equals(fooBar)) {
// Same as above but wi...
Is there a way to DRY this jQuery up?
<script type="text/javascript">
$('form input#search').watermark('search...');
</script>
<script type="text/javascript">
$('form input#post_title').watermark('title');
</script>
<script type="text/javascript">
$('form input#post_tag_list').watermark('tag (separate tags with a comma)');
</scrip...
I have a pattern that repeats for several member functions that looks like this:
int myClass::abstract_one(int sig1)
{
try {
return _original->abstract_one(sig1);
} catch (std::exception& err) {
handleException(err);
} catch (...) {
handleException();
}
}
bool myClass::abstract_two(int sig2)
{
try {
return _or...
While refactoring, I wanted to change an array where entries are added to an std::vector, but for compatibility (persistency, downgrading,...), it still needs to have an upper limit.
What is the best way (elegant, stl-like, limited extra code) to have an stl-like container which is limited in size, so you know that inserting an entry fai...
Hi,
I am using Pydev on Eclipse to write python code. I am new to Pydev and to Eclipse. I love the feature where by I can use rightClick -> Refactoring -> Rename... to rename a variable.
I was wondering if there is something similar to change a function everywhere in the project, if I change its definition.
For example, suppose I ini...
Hello, I've been messing with this bit of code for over an hour trying to rearrange it different ways. Is there any easier way to write it?
if x is not Number ;// if x is string
{
if y is not Number ;// x, y both strings
{
Eval(x)
Eval(y)
return
}
else ...