Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

coding references - refactoring #21

Open
Jamanius opened this issue Nov 24, 2015 · 0 comments
Open

coding references - refactoring #21

Jamanius opened this issue Nov 24, 2015 · 0 comments

Comments

@Jamanius
Copy link
Contributor

How to Refactor

Refactoring is an important step to becoming a world-class beginner, and it's important to look at your code fresh before refactoring.

Refactoring is not about solving the problem differently, it's about solving the problem well.

Good solutions don't just work, they make it clear what they are doing by having:

  • Clear names for variables and methods (see Tips for Naming Variables)
  • Readable, concise code.
    See Code Smells. FYI: When he refers to "shorter methods" think of them as not necessarily short in terms of lines, but having a single thing to do. Avoid chaining too many methods together or having too much logic on one line.

For example:

  # the code below is jibberish, but is what method chaining is. It's easily recognizable due to the many methods chained together by "."

   "hello".split(//).join.match(/\w/).gsub
  • D.R.Y (Don't Repeat Yourself) Code.

If you can't think of a way to improve your code becuase you had an awesome solution the first time, write why you think it's great instead. Do not simply copy the initial solution or leave the refactoring section blank.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants