Today is Refactoring Day!

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Omnivore
Prole
Posts: 18
Joined: Fri Jun 28, 2013 12:51 am
Location: West Coast

Today is Refactoring Day!

Post by Omnivore » Tue Jul 30, 2013 1:42 pm

For me anyhow.

It is that time when the adding of new features and cool ideas has to be brought to a halt before the code becomes too tangled to ever untangle. The time when unnecessary files no longer containing useful code clutter up the source directories. When major files creep up past the 500 LOC mark, when some source directories have more than a dozen or so lua files. All indicators that a bit of house cleaning and reorganization is overdue.

A few tips and tricks I've found useful:
  • Searching for names in files: grep - on linux its easy, on windows WinGrep is handy.
  • Tortoise Hg (source version control), right click context on windows and select rename to move files around.
  • Break the process into steps and commit each step so if you screw up you can easily backtrack.
  • Look at chunks of code that do similar things and see if you can't extract out a reusable chunk.
I'd like to hear your refactoring experiences, good and bad, as well as any tips or tricks you may have discovered.

Thanks,
Omnivore
Lua lou aye, ah no its, lua louie

User avatar
MPQC
Citizen
Posts: 65
Joined: Fri Jun 28, 2013 2:45 pm

Re: Today is Refactoring Day!

Post by MPQC » Tue Jul 30, 2013 2:04 pm

A tip: Last one I did was when I went through all my "constants". In sublime you can ctrl-shift-f, then search whatever term. It'll show you every single spot in your project that that term shows up -> very easy to find unused variables.

When I did a project rewrite, I found using version control extremely annoying, mostly for the fact during most of it, it wouldn't even compile. I didn't like the idea of committing broken code.

Mikaboshi
Prole
Posts: 12
Joined: Mon Jul 22, 2013 8:55 pm

Re: Today is Refactoring Day!

Post by Mikaboshi » Thu Aug 01, 2013 1:38 pm

MPQC wrote: When I did a project rewrite, I found using version control extremely annoying, mostly for the fact during most of it, it wouldn't even compile. I didn't like the idea of committing broken code.
In a case like this, I would create an unstable branch called rewrite, and merge it in with the main branch when it is completed.

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests