Code Monkey home page Code Monkey logo

refactoringtopatterns's Introduction

Refactoring To Patterns

A place to practice Refactoring To Patterns that Kerievsky wrote about in his book.

This repo contains source code that very closely or exactly matches that which is found in Joshua Kerievsky's book Refactoring to Patterns.

Have to say thank you to Joshua for putting all of these patterns together and for making them easily consumable. If you have landed here and are interested in other things Joshua has put out, I encourage you to check out the following links:

Getting Around

Language && IDE Concerns

All code samples are written in C#, and therefor will follow C# coding conventions (versus any Java coding conventions you might see in the book).

I have tested running this code in the following IDE's, and all seems to work fine:

There might be an issue with Visual Studio 2017 (on Windows), but I've not been able to dig into it as of yet.

Other Language Implementations

A big thank you to several friends that have converted this repo to other languages.

What you'll find here

Each refactoring that he walks through has it's own project. For example, you will notice that there is a project titled "ReplaceConstructorsWithCreationMethods". This project corresponds to code he offers up on p. 57 in his section titled "Replace Constructors with Creation Methods"

IntialCode folder

You will also notice that within the "ReplaceConstructorsWithCreationMethods" there is a folder titled "InitialCode". This folder is intended to contain working code that demonstrates the problem as he initially presents it in the book.

MyWork folder

There is also a folder titled "MyWork". This folder initially carries an exact copy of what's in the "InitialCode" folder. However, the intention of the "MyWork" folder is that it is a place for you to experiment with in implementing the refactoring. In this way, once you have implemented the refactoring, you have the ability to look at both the initial problem and the refactored solution and weigh the benefits of one pattern (or lack thereof) and the code refactored to or towards a pattern.

RefactoringToPatterns.Tests Project

This project also contains sections for each refactoring, but it differs from what I meantioned before in that it has unit tests that in some way excercise the code found in the implemented code project.

For example, if you look in the RefactoringToPatterns.Tests project you will see a section for "ReplaceConstructorsWithCreationMethods". This should sound familiar as I mentioned it before. This section of the tests project also has an "InitialCode" section and a "MyWork" section. Each of these sections contains unit tests linking out to the actual implmentations. Like before, your "MyWork" section is a place for you to experiment with as you move through the refactoring as it's discussed in the book.

Conclusion

Take a look around. If anything doesn't make sense once you peek at it, please just create an Issue here in GitHub where we can discuss it. Like any system, if you want to understand how it works, go look at the tests as they are a great durrable source of low level documentation.

On a Personal Note

I've put all of my work on a branch with my name on it corywheeler. There you'll see the refactorings implemented such that the MyWork folders will differ from the Initial Code folders so you can see the solution in before and after states.

refactoringtopatterns's People

Contributors

corywheeler avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.