Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and Clean the code of the GildedRose class #5

Closed
aatwi opened this Issue Dec 24, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@aatwi
Copy link
Owner

aatwi commented Dec 24, 2017

No description provided.

aatwi added a commit that referenced this issue Dec 24, 2017

[#5] Use ArrayList instead of Array
In order to extract constants for variables
- Convert the array of items to an ArrayList
- Make the ArrayList of items private
- Add a new method itemAt that returns an item at a specific index

aatwi added a commit that referenced this issue Dec 25, 2017

[#5] Make GildedRose final
In order to refactor the code of GildedRose

aatwi added a commit that referenced this issue Dec 25, 2017

[#5] Create new classes representing the known items of GildedRose
In order to refactor and clean the code of GildedRose
- Add Classes for AgedBrie, Concert, Sulfuras and OtherItems that extend Item

aatwi added a commit that referenced this issue Dec 25, 2017

[#5] Introduce the visitor pattern in the code
In order to refactor and clean the code of GildedRose
- Add the Visitable interface
- Add the Visitor interface
- Make all the Item classes implement the Visitor interface
- Add ItemVisitor the implementation of the Visitor interface

aatwi added a commit that referenced this issue Dec 25, 2017

[#5] Introduce the visitor pattern in the code
In order to refactor and clean the code of GildedRose
- Rename Visitable to ItemVisitable and change its type to abstract class instead of interface
- Make ItemVisitable extends Item
- Update the Item classes to make them extend ItemVisitable instead of the Item class

aatwi added a commit that referenced this issue Dec 25, 2017

[#5] Create an ItemFactory class
In order to refactor and clean the code of GildedRose
- Add an ItemFactory class that initializes an instance of ItemVisitable based on the name of the Item
- Use this factory in the ItemBuilder Class

aatwi added a commit that referenced this issue Dec 25, 2017

[#5] Build the list of ItemVisitable in GildedRose from the list of Item
In order to refactor and clean the code of GildedRose
- Convert the list of Item in the GildedRose constructor to List of ItemVisitable
- Make the ItemBuilder return an Item instead of ItemVisitable

aatwi added a commit that referenced this issue Dec 25, 2017

[#5] Use the visitor in the case of AgedBrie
In order to refactor and clean the code of GildedRose
- Implement the logic for AgedBrie in the corresponding visit method in ItemVisitor
- Use the visitor pattern in the GildedRose in the case of AgedBrie

aatwi added a commit that referenced this issue Dec 25, 2017

[#5] Use the visitor in the case of Concert
In order to refactor and clean the code of GildedRose
- Implement the logic for Concert in the corresponding visit method in ItemVisitor
- Use the visitor pattern in the GildedRose in the case of Concert
- Refactor the code in ItemVisitor and extract methods for common code
- Remove the previous code from GildedRose.updateQuality in the case of AgedBrie and Concert

aatwi added a commit that referenced this issue Dec 25, 2017

[#5] Use the visitor in the case of Sulfuras and OtherItems
In order to refactor and clean the code of GildedRose
- Implement the logic for Sulfuras and OtherItems in the corresponding visit method in ItemVisitor
- Use the visitor pattern in the GildedRose in the case of Sulfuras and OtherItems

aatwi added a commit that referenced this issue Dec 25, 2017

[#5] Refactor the ItemVisitor class
In order to refactor and clean the code of GildedRose
- Use lambda expression in GildedRose instead of a for loop
- Extract methods for the common code in the ItemVisitor

@aatwi aatwi changed the title Refactor the GildedRose Refactor and Clean the code of the GildedRose class Dec 25, 2017

aatwi added a commit that referenced this issue Dec 25, 2017

[#5] Move the constants out of the GildedRose class
In order to refactor and clean the code of GildedRose
- Make MAX_QUALITY, MIN_QUALITY & MIN_SELL_IN_DATE as local variables ItemVisitor
- Move AGED_BRIE string to the AgedBrie class
- Move SULFURAS string to the Sulfuras class
- Move CONCERT string to the Concert class
- Adapt the tests accordingly

@aatwi aatwi closed this Dec 25, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.