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

coding references - refactoring #21

@Jamanius

Description

@Jamanius

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions