I have a large file that I want to refactor. My idea is to make helper classes with helper methods so that I can modularize methods.
Is that a good idea? For instance before refactoring:
public void collision(PhysicsCollisionEvent event) {
if (event.getObjectA() instanceof BombControl) {
final Spatial node = event.getNodeA();
effect.killAllParticles();
effect.setLocalTranslation(node.getLocalTranslation());
BombControl bc = (BombControl) event.getObjectA();
effect.emitAllParticles();
} else if (event.getObjectB() instanceof BombControl) {
final Spatial node = event.getNodeB();
effect.killAllParticles();
effect.setLocalTranslation(node.getLocalTranslation());
effect.emitAllParticles();
}
}
After refactoring:
public void collision(PhysicsCollisionEvent event) {
CollisionHelper.collisionHelp(event, effect);
}
Is that a good idea or must I use a more elaborate recfactoring? I think it would work but I don't know of specific refactoring patterns.
switch
onString
instead of all theelse if
inonAction
. – toto2 Jun 21 '14 at 1:22