Question - Refactoring a variable into another class?

Hi, 

I hope this is the right place to post this but I was just wondering if there's a way to refactor this code to move the variable into the class without breaking too much?

The way I'm doing it is a bit janky, and I feel there's probably a much nicer way.

Thanks, Pete

0
3 comments

Refactoring isn't directly applicable here. Tell me more about your needs. Then I can help you find a suitable solution.

0

Hey thanks! 

I'm talking generally, just looking to see if there's an option to move a variable into another class? 

I tend to just move the variable into the class manually, then fix any errors with things that need to be relinked, is there a better way than that? No worries if not.

Thanks, 

Pete

0

There is a refactoring called “Extract Class refactoring”, can extract the fields from a class and create a new one based on them. Also, a similar refactoring is “Extract to the Superclass”.

0

Please sign in to leave a comment.