Code Monkey home page Code Monkey logo

31daysofrefactoringinjava's Introduction

31DaysOfRefactoringInJava

Most part of my job is to work on a piece of code that's already written by someone. When I read such code, I often like to think(sometimes actually do) about changing things to make the code better. And I also wonder, how a piece of code I am writing today, will be changed by someone else in future. Coz that's what a lot of jobs demand - to be able to re-use/improve/extend code already written.

So I thought of reading a bit about Refactoring, and upon googling, I came acorss this book called 31 Days of Refactoring by Sean Chambers, Simone Chiaretta. It is a great book - clear and concise. It has one lesson per day, but you can really finish the entire book in a day.

The book is originally written for .net as a language. And hence, I took up the task of learning the lessons as given in the book - one per day. But, I also started converting them to Java.

This repo is a literal translation of the book called 31 days of refactoring. Now, a lot of the lessons - like the 1st one - feel very obvious to a Java developer. Those who have read Effective Java might find this a waste! But the point is not to teach Java, it's about engendering the thought of Reafctoring and what to keep in mind while doing it yourself!

I will try to add one lesson each day!

Feel free to contribute! :D

Contents:

Day 1 - Encapsulate Collection

Day 2 - Move Method

Day 3 - Pull Up Method

Day 4 - Push Down Method

Day 5 - Pull Up Field

Day 6 - Push Down Field

Day 7 - Rename

Day 8 - Replace Inheritence with Delegation

Day 9 - Extract Interface

Day 10 - Extract Method

Day 11 - Switch To Strategy

Day 12 - Break Dependencies

Day 13 - Extract Method Objects

Day 14 - Break Responsibilities

Day 15 - Remove Duplication

Day 16 - Encapsulate Conditional

Day 17 - Extract Superclass

Day 18 - Replace Exceptions With Conditional

Day 19 - Extract Factory Class

Day 20 - Extract Subclass

Day 21 - Collapse Hierarchy

Day 22 - Break Method

Day 23 - Introduce Parameter Object

Day 24 - Remove Arrowhead Antipattern

Day 25 - Introduce Design by Contract Checks

Day 26 - Remove Double Negative

Day 27 - Remove God Classes

Day 28 - Remove Boolean Method

Day 29 - Remove Middle Man

Day 30 - Return ASAP

Day 31 - Replace Conditional With Polymorphism

Motivation

31daysofrefactoringinjava's People

Contributors

havanagrawal avatar sunnypatel165 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

31daysofrefactoringinjava's Issues

Poor examples on some days

The lessons of the book are really good - small and yet meaningful.
But some examples aren't as good. Maybe it's the case when converted to Java.

Links in ToC of Main README have hard links

The links in your table of contents in the main README link directly to your repo. Someone with a fork to your repo cannot use the main README to navigate his own repo.

Specifically, instead of this:
[Day 1 - Encapsulate Collection](https://github.com/sunnypatel165/31DaysOfRefactoringInJava/tree/master/src/com/sunnypatel/daysofrefactoringjava/day1/encapsulatecollection)

You need to have
[Day 1 - Encapsulate Collection](src/com/sunnypatel/daysofrefactoringjava/day1/encapsulatecollection)

Will send a PR.

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.