-
Notifications
You must be signed in to change notification settings - Fork 383
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
refactoring katas practice #33
Open
kumarnareshh74
wants to merge
19
commits into
NotMyself:master
Choose a base branch
from
nareshh74:user/nareshh74/refactor_1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
refactoring katas practice #33
kumarnareshh74
wants to merge
19
commits into
NotMyself:master
from
nareshh74:user/nareshh74/refactor_1
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Added a new Inn class in Inn.cs to encapsulate the logic for updating the quality and sell-in values of items. Updated GildedRose.Console.csproj to include Inn.cs. Modified Program.cs to use the new Inn class for updating item quality, replacing the previous call to app.UpdateQuality().
Refactored the `UpdateItem` method in the `Inn` class to delegate item update logic to a new `Update` extension method in the `ItemExtensions` class. Added `ItemExtensions.cs` to the project compilation in `GildedRose.Console.csproj`.
Removed ItemExtensions.cs and updated GildedRose.Console.csproj to exclude it from compilation. Moved the update logic into a new Update method within the Item class, handling specific rules for different item types directly.
Added a new `AgedBrie` class in `AgedBrie.cs` inheriting from `Item` with a custom `Update` method for "Aged Brie" items. Updated `GildedRose.Console.csproj` to include this new file. Removed special handling for "Aged Brie" from the `Item` class in `Item.cs`. Changed instantiation of "Aged Brie" items in `Program.cs` to use the new `AgedBrie` class. Updated `TestItem_AgedBrie` in `TestAssemblyTests.cs` to create an instance of the `AgedBrie` class.
… class Refactored the `Item` class to remove specific logic for "Backstage passes to a TAFKAL80ETC concert" and introduced a new `BackstageItem` class to handle this behavior. Updated `GildedRose.Console.csproj` to include `BackstageItem.cs`. Modified `Program.cs` and `TestAssemblyTests.cs` to use the new `BackstageItem` class. This change adheres to the Open/Closed Principle by extending functionality without modifying the existing `Item` class.
Refactored the `Item` class to remove special handling for "Sulfuras, Hand of Ragnaros". Introduced a new `Sulfuras` class that inherits from `Item` and overrides the `Update` method to do nothing, reflecting its unique behavior. Updated `Program.cs` to instantiate `Sulfuras` instead of `Item` for "Sulfuras, Hand of Ragnaros". Modified `TestAssemblyTests.cs` to use `Sulfuras` in the `TestItem_Sulfuras` test.
The Sulfuras class, which represents the "Sulfuras, Hand of Ragnaros" item, has been moved from Item.cs to a new file named Sulfuras.cs. The GildedRose.Console.csproj file has been updated accordingly. The functionality of the Sulfuras class remains unchanged.
Updated `GildedRose.sln` to Visual Studio 17.10.35004.147. Moved `AgedBrie.cs`, `BackstageItem.cs`, `Item.cs`, and `Sulfuras.cs` to `Items` directory. Reformatted the moved files for consistency. Updated `GildedRose.Console.csproj` to reflect new file paths.
Introduced a new protected method `DecreaseSellIn()` in `Item.cs` to encapsulate the logic for decrementing the `SellIn` property by 1. Updated the `Update` methods in `AgedBrie`, `BackstageItem`, and `Item` classes to use this new method instead of directly manipulating the `SellIn` property. This refactoring enhances code readability and maintainability by centralizing the decrement logic.
Refactored the `Update` methods in `AgedBrie.cs`, `BackstageItem.cs`, and `Item.cs` to use a new `UpdateQuality` method. This method encapsulates the logic for updating the quality of items, ensuring that quality constraints (not exceeding 50 or dropping below 0) are maintained. This change promotes code reuse and simplifies the `Update` methods by delegating the quality update logic to a separate method.
The UpdateQuality methods in AgedBrie.cs, BackstageItem.cs, and Item.cs were changed from protected to private, restricting their access to within their respective classes. Additionally, the logic was updated: AgedBrie and BackstageItem now increment Quality by 1 if it is less than 50, while Item decrements Quality by 1 if it is greater than 0.
Updated project file `GildedRose.Console.csproj` to reflect renaming of `AgedBrie.cs` to `AgedBrieItem.cs` and `Sulfuras.cs` to `SulfurasItem.cs`. Renamed class `AgedBrie` to `AgedBrieItem` in `AgedBrieItem.cs` and updated the constructor accordingly. Renamed class `Sulfuras` to `SulfurasItem` in `SulfurasItem.cs` and updated the constructor accordingly. Updated `Program.cs` to use the new class names `AgedBrieItem` and `SulfurasItem`. Updated test methods in `TestAssemblyTests.cs` to use the new class names `AgedBrieItem` and `SulfurasItem`.
This reverts commit 246e14a.
Added a new ConjuredItem class that inherits from Item and overrides the Update method to decrease quality twice as fast. Updated the project file to include ConjuredItem.cs. Modified the Main method to use ConjuredItem for "Conjured Mana Cake". Added a unit test to verify ConjuredItem behavior.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.