Are you afraid to refactor?

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 497 Views - Last Post: 24 January 2018 - 02:06 PM

#16 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2388
  • View blog
  • Posts: 5,012
  • Joined: 11-December 07

Re: Are you afraid to refactor?

Posted 24 January 2018 - 12:28 AM

View Postjon.kiparsky, on 24 January 2018 - 03:47 AM, said:

No shouting here, I'm just going to quietly sigh and wonder where you get the free time.


The best example I can think of was when having to fix a bug in part of the codebase in which I had never worked. It would have taken much longer to understand what was happening if I had not refactored.
Was This Post Helpful? 0
  • +
  • -

#17 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 6016
  • View blog
  • Posts: 20,701
  • Joined: 05-May 12

Re: Are you afraid to refactor?

Posted 24 January 2018 - 06:24 AM

View Postjon.kiparsky, on 23 January 2018 - 10:47 PM, said:

No shouting here, I'm just going to quietly sigh and wonder where you get the free time.

By relaxing the 10 lines per method to 25 lines per method. Just kidding. :)

I usually do the parallelization type refactoring while listening in to meetings that I'm compelled to "attend", but I'm not actually an active participant in.

Spoiler

Was This Post Helpful? 0
  • +
  • -

#18 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 5152
  • View blog
  • Posts: 13,842
  • Joined: 18-April 07

Re: Are you afraid to refactor?

Posted 24 January 2018 - 01:31 PM

I find that most programmers actually enjoy refactoring and the problem, as many have already stated, is that programmers tend to do premature optimization as they write which bogs them down and causes problems later. That or they refactor by getting "witty" and mess up perfectly readable code with cryptic optimizations that may work, but that destroy readability.

All too often I see code that suffers from this. However, from time to time, I do catch myself wanting to optimize on the fly and have to stop myself. :)
Was This Post Helpful? 0
  • +
  • -

#19 jon.kiparsky  Icon User is online

  • Beginner
  • member icon


Reputation: 10897
  • View blog
  • Posts: 18,593
  • Joined: 19-March 11

Re: Are you afraid to refactor?

Posted 24 January 2018 - 02:06 PM

View PostMartyr2, on 24 January 2018 - 03:31 PM, said:

I find that most programmers actually enjoy refactoring and the problem, as many have already stated, is that programmers tend to do premature optimization as they write which bogs them down and causes problems later. That or they refactor by getting "witty" and mess up perfectly readable code with cryptic optimizations that may work, but that destroy readability.


I would think that refactoring is the opposite of optimizing, or maybe orthogonal to it. If you're refactoring, it really shouldn't affect performance.
Now, you might go in to optimize, do a bit of refactoring to make it easier, then do the optimize, and put that all on one pull request, but those should at least be on different (well-named) commits, so that future you doesn't invent a time machine and come back and break your kneecaps.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2