emilybache / gildedrose-refactoring-kata Goto Github PK
View Code? Open in Web Editor NEWStarting code for the GildedRose Refactoring Kata in many programming languages.
Home Page: https://youtu.be/Mt4XpGxigT4
License: MIT License
Starting code for the GildedRose Refactoring Kata in many programming languages.
Home Page: https://youtu.be/Mt4XpGxigT4
License: MIT License
I did the the Java - Spock version of the Kata. The starter unit test runs against app.items, but the test harness assumes that the original inputs will be changed.
Based on the initial unit test I built my solution around access to the property, not on side effects to the original inputs. So when I ran the TextTestHarness (TextDemoApp would be a better name) things broke. Just had to change the harness to app.items and things worked as expected.
Is this an issue? An intended part of the kata? I'm willing to do a PR to change it in the Java versions if you think it's an issue.
Hi @emilybache, I'm working on adapting the kata for Unity game developers. Here's some questions I have:
Unity doesn't have a way to compile down to a command line program, so I'm not sure I'll be able to integrate it with TextTest. Would it be suitable/appropriate to write some code to compare a custom log with the text file instead? Or does this make Unity a bad candidate for addition into this repo?
As I was reviewing the C# ApprovalTest.ThirtyDays.verified.txt file, I noticed that I hadn't implemented the conjured item feature yet, but my output was identical. The existing file seems to have output that doesn't include the conjured item feature (ex: day 1 mana cake quality = 6, and day 2 it's 5 instead of 4). Is this a mistake or am I missing something?
Do you have any other concerns or words of advice as I try to implement a Unity version of this kata?
Let me know, thanks!
The instructions state that conjured items degrade twice as fast as normal items, but the texttest stdout.gr indicates that they degrade at the normal item rate. Therefore, I believe there may be an issue with the conjured items.
The spec here is not well enough defined for "Conjured Items".
I suppose that finding these learning and collaboration exercises might be the point of this kata. Just wanted to take the time to say how much i appreciated and enjoyed the experience. Thank you for maintaining this. ❤️
While testing my own code against the original I believe I've noticed an incorrect edge case.
When tickets have sellIn==10, it is supposed to increase quality by 2 but it does not, it works from 9 and below just fine, same for 5 and below.
Hello,
There's an issue in the dotnet core test on Windows only (I guess), for some reasons the console stdout is changing the carriage return sequence, and the test can't be validated.
Using
[cmake] -- The C compiler identification is GNU 10.4.0
[cmake] -- The CXX compiler identification is GNU 10.4.0
from ubuntu 22.04 causes compilation issues:
full output:
root@fa43466bd319:/workspaces/GildedRose-Refactoring-Kata/build# cd ../cpp
root@fa43466bd319:/workspaces/GildedRose-Refactoring-Kata/cpp# mkdir build
root@fa43466bd319:/workspaces/GildedRose-Refactoring-Kata/cpp# cd build
root@fa43466bd319:/workspaces/GildedRose-Refactoring-Kata/cpp/build# cmake ..
-- The C compiler identification is GNU 10.4.0
-- The CXX compiler identification is GNU 10.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
cmake --build CMake Deprecation Warning at build/_deps/googletest-src/CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
.CMake Deprecation Warning at build/_deps/googletest-src/googlemock/CMakeLists.txt:42 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
CMake Deprecation Warning at build/_deps/googletest-src/googletest/CMakeLists.txt:49 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- Found PythonInterp: /usr/bin/python (found version "3.10.6")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /workspaces/GildedRose-Refactoring-Kata/cpp/build
root@fa43466bd319:/workspaces/GildedRose-Refactoring-Kata/cpp/build# cmake --build .
[18/21] Building CXX object test/cpp_catch2_unittest/CMakeFiles/GildedRoseCatch2UnitTests.dir/GildedRoseCatch2UnitTests.cc.o
FAILED: test/cpp_catch2_unittest/CMakeFiles/GildedRoseCatch2UnitTests.dir/GildedRoseCatch2UnitTests.cc.o
/usr/bin/c++ -I/workspaces/GildedRose-Refactoring-Kata/cpp/lib -I/workspaces/GildedRose-Refactoring-Kata/cpp/src -std=gnu++11 -MD -MT test/cpp_catch2_unittest/CMakeFiles/GildedRoseCatch2UnitTests.dir/GildedRoseCatch2UnitTests.cc.o -MF test/cpp_catch2_unittest/CMakeFiles/GildedRoseCatch2UnitTests.dir/GildedRoseCatch2UnitTests.cc.o.d -o test/cpp_catch2_unittest/CMakeFiles/GildedRoseCatch2UnitTests.dir/GildedRoseCatch2UnitTests.cc.o -c /workspaces/GildedRose-Refactoring-Kata/cpp/test/cpp_catch2_unittest/GildedRoseCatch2UnitTests.cc
In file included from /usr/include/signal.h:328,
from /workspaces/GildedRose-Refactoring-Kata/cpp/lib/Catch.hpp:7937,
from /workspaces/GildedRose-Refactoring-Kata/cpp/test/cpp_catch2_unittest/GildedRoseCatch2UnitTests.cc:2:
/workspaces/GildedRose-Refactoring-Kata/cpp/lib/Catch.hpp:10717:58: error: call to non-‘constexpr’ function ‘long int sysconf(int)’
10717 | static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;
| ^~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
from /usr/include/signal.h:328,
from /workspaces/GildedRose-Refactoring-Kata/cpp/lib/Catch.hpp:7937,
from /workspaces/GildedRose-Refactoring-Kata/cpp/test/cpp_catch2_unittest/GildedRoseCatch2UnitTests.cc:2:
/usr/include/unistd.h:640:17: note: ‘long int sysconf(int)’ declared here
640 | extern long int sysconf (int __name) __THROW;
| ^~~~~~~
In file included from /workspaces/GildedRose-Refactoring-Kata/cpp/test/cpp_catch2_unittest/GildedRoseCatch2UnitTests.cc:2:
/workspaces/GildedRose-Refactoring-Kata/cpp/lib/Catch.hpp:10776:45: error: size of array ‘altStackMem’ is not an integral constant-expression
10776 | char FatalConditionHandler::altStackMem[sigStackSize] = {};
| ^~~~~~~~~~~~
[19/21] Building CXX object test/cpp_catch2_approvaltest/CMakeFiles/GildedRoseCatch2ApprovalTests.dir/GildedRoseCatch2ApprovalTests.cc.o
FAILED: test/cpp_catch2_approvaltest/CMakeFiles/GildedRoseCatch2ApprovalTests.dir/GildedRoseCatch2ApprovalTests.cc.o
/usr/bin/c++ -I/workspaces/GildedRose-Refactoring-Kata/cpp/lib -I/workspaces/GildedRose-Refactoring-Kata/cpp/src -std=gnu++11 -MD -MT test/cpp_catch2_approvaltest/CMakeFiles/GildedRoseCatch2ApprovalTests.dir/GildedRoseCatch2ApprovalTests.cc.o -MF test/cpp_catch2_approvaltest/CMakeFiles/GildedRoseCatch2ApprovalTests.dir/GildedRoseCatch2ApprovalTests.cc.o.d -o test/cpp_catch2_approvaltest/CMakeFiles/GildedRoseCatch2ApprovalTests.dir/GildedRoseCatch2ApprovalTests.cc.o -c /workspaces/GildedRose-Refactoring-Kata/cpp/test/cpp_catch2_approvaltest/GildedRoseCatch2ApprovalTests.cc
In file included from /usr/include/signal.h:328,
from /workspaces/GildedRose-Refactoring-Kata/cpp/lib/Catch.hpp:7937,
from /workspaces/GildedRose-Refactoring-Kata/cpp/lib/ApprovalTests.v.6.0.0.hpp:2422,
from /workspaces/GildedRose-Refactoring-Kata/cpp/lib/ApprovalTests.hpp:3,
from /workspaces/GildedRose-Refactoring-Kata/cpp/test/cpp_catch2_approvaltest/GildedRoseCatch2ApprovalTests.cc:2:
/workspaces/GildedRose-Refactoring-Kata/cpp/lib/Catch.hpp:10717:58: error: call to non-‘constexpr’ function ‘long int sysconf(int)’
10717 | static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;
| ^~~~~~~~~~~
In file included from /workspaces/GildedRose-Refactoring-Kata/cpp/lib/ApprovalTests.v.6.0.0.hpp:271,
from /workspaces/GildedRose-Refactoring-Kata/cpp/lib/ApprovalTests.hpp:3,
from /workspaces/GildedRose-Refactoring-Kata/cpp/test/cpp_catch2_approvaltest/GildedRoseCatch2ApprovalTests.cc:2:
/usr/include/unistd.h:640:17: note: ‘long int sysconf(int)’ declared here
640 | extern long int sysconf (int __name) __THROW;
| ^~~~~~~
In file included from /workspaces/GildedRose-Refactoring-Kata/cpp/lib/ApprovalTests.v.6.0.0.hpp:2422,
from /workspaces/GildedRose-Refactoring-Kata/cpp/lib/ApprovalTests.hpp:3,
from /workspaces/GildedRose-Refactoring-Kata/cpp/test/cpp_catch2_approvaltest/GildedRoseCatch2ApprovalTests.cc:2:
/workspaces/GildedRose-Refactoring-Kata/cpp/lib/Catch.hpp:10776:45: error: size of array ‘altStackMem’ is not an integral constant-expression
10776 | char FatalConditionHandler::altStackMem[sigStackSize] = {};
| ^~~~~~~~~~~~
ninja: build stopped: subcommand failed.
root@fa43466bd319:/workspaces/GildedRose-Refactoring-Kata/cpp/build#
I see these 3 C# projects?
These are all very similar; whould it make sense to just keep the csharpcore
and rename this to csharp
?
We use the Gilded Rose kata to teach developers how to write tests and refactor the code. We use JavaScript with Jest. Right now there are katas in JavaScript with Mocha and Jasmine, but none for Jest.
Hi,
I'm wondering if this is normal or not, the code provided does +=2 on the quality of "aged brie" at each step, which the requirements don't seem to express.
It's not obvious in the source code, but after refactoring in my solution (without touching semantics) it was glaringly obvious.
There are two updates to quality :
I thought the kata was about the new feature, but that existing code was supposedly semantically correct.
thanks for the work on these kata.
When opening https://bettercodehub.com/ it says that Better Code Hub has retired. The BCH compliance badge isn't working.
I believe there is an error on the file stdout.gr for the texttests for the expected values on conjured items (the new feature):
-------- day 0 --------
Conjured Mana Cake, 3, 6
-------- day 1 --------
Conjured Mana Cake, 2, 5
-------- day 2 --------
Conjured Mana Cake, 1, 4
-------- day 3 --------
Conjured Mana Cake, 0, 3
-------- day 4 --------
Conjured Mana Cake, -1, 1
-------- day 5 --------
Conjured Mana Cake, -2, 0
-------- day ... --------
The requirement is "Conjured" items degrade in Quality twice as fast as normal items, so while a normal item quality degrades by 1 each day, the conjured items should degrade by 2 and while normal items quality degrades by 2 once the sell by date has passed, the conjured items should degrade by 4.
Given that, a test suit for conjured items could be:
-------- day 0 --------
Conjured Mana Cake, 3, 10
-------- day 1 --------
Conjured Mana Cake, 2, 8
-------- day 2 --------
Conjured Mana Cake, 1, 6
-------- day 3 --------
Conjured Mana Cake, 0, 4
-------- day 4 --------
Conjured Mana Cake, -1, 0
-------- day 5 --------
Conjured Mana Cake, -2, 0
-------- day ... --------
I wanted to tackle this kata as I heard so much about it and was happy that there is an elixir version available in this repositoriy.
So I thought, "lets start with that failing test!" – Nope… No failing tests, only a single one which is empty, it does test even less than an asserting true
…
So move on… Just write tests…
First one was that an items quality is reduced by 1, check! worked well…
Second one was to check if sell_in
of an item is decremented, and guess… It is not. So I took a look into the corresponding source and found out, that there is only reading access to that field, but no writing access. So I took a look at the ruby sources, which in fact do update that field/attribute, so missing it seems not to be on purpose.
Maybe there are other flaws I haven't found so far…
Hey, sorry I'm new to git, so I'm not sure what the best practices are but I found a possible issue.
In your texttest_fixture.py, you've got the quality set to 49 for the backstage passes:
Item(name="Backstage passes to a TAFKAL80ETC concert", sell_in=10, quality=49),
Item(name="Backstage passes to a TAFKAL80ETC concert", sell_in=5, quality=49),
In your GildedRoseRequirements.txt, you've written:
The Quality of an item is never more than 50
The output of texttest_fixture.py, indicates that the quality of the backstage passes become 51 and 52, should the output not be 50? Since that's one of the constraints that's been applied?
Apple have removed the Process enum in Swift 3, and replaced it with CommandLine. I'll send a PR for the fix to the main.swift file.
Hi,
I am maybe super new in C#, and NUnit and Acceptance Testing... so, pardon my newbeness.
After running the .sln csharpcore project, I don't obtain the .txt of the approval tests.
And my approval tests stays blue (meaning not executed).
But the unit tests pass.
Is the project badly configured, or is there a pre-requisit I miss?
Based on the requirements
Rider doesn't detect the NUnit unit tests in the csharpcore project, possibly due to the project setup. Because the unit test project is configured as a console application, I assume that the unit tests aren't being recognized. It's not commonplace to have your unit test project be a console application.
My suggested fix is to have three projects:
Further instructions for the approval testing also wouldn't go amiss as it's not clear how they should be used.
When refactoring the PHP version from PHP 5 to PHP 7, the Item
class was made final
, but no interface was introduced.
Given that:
Item
class cannot be extended nowItem
is not an interfaceGildedRose
class directly depends on the concrete Item
class instead of an interface... this all makes it technically wrong to use any proper OOP techniques for refactoring this in such a way that items can include any properties about themselves, forcing you to hardcode all behavior into the GildedRose
or one of its parts in some way. Using final
without any interfaces in-between generally makes for the type of bad couplig you cannot easily rectify in PHP.
Note: you can still do these types of operations, as the type is not technically enforced, but this will break static analysis and be conceptually wrong.
I would suggest one of two approaches to allow for better refactoring opportunities in the PHP version:
Remove the final
keyword from the Item
class.
This would allow something like LegendaryItem extends Item
to still be accepted in the shop class (which requires items to be of type Item
as per its docblock).
Turn Item
into an interface and provide something like a BaseItem
implementation.
This would allow the shop to type against an interface instead, which opens up refactoring methods like using decorators: new ConjuredItem( new Item( 'Mana Cake', 1, 4 ) )
.
I would think, that the text output could make use of iostreams or fmt instead of using C's printf. but may be that is part of the refactoring exercise?
I've noticed on the Supermarket Receipt Refactoring Kata a with_tests
branch has been optionally provided. I was thinking of creating the same for this Kata (PHP version), which, as that will allow jumping directly into the refactoring part of this exercise too.
I wanted to get your opinion, as this is the most stared Kata, and most versions, adding a new branch may create more work for you.
I was also going to update the PHP version to the same tooling and similar README as the others I've recently done, which would keep the install method and tooling consistent across Katas.
Hello,
It might by knit-picking but the number of days contained in texttests/ThirtyDays/stdout.gr
is actually 31 although the title suggests 30 entries.
Regards,
Sven Heyll
The swift version of the test data in swift/main.swift
has 2 copy/paste errors. PR coming up to fix.
links like Ruby gives us Rails routing error
was wondering if it could be interesting to add a version of the kata for octave / matlab?
First of all: excellent idea! Although this kata has become a classic among the software-craftsmanship circles by now, I wanted to congratulate you on the idea and the initiative nevertheless. Probably we will be doing this kata at our company soon.
What I wanted to point out is that the link to the article "Why Most Solutions to Gilded Rose Miss The Bigger Picture", mentioned in the README, seems to be broken (the article does not seem to be available anymore).
I could only access it by consulting Google's cache:
If the article is "gone forever", maybe you could compensate it by mentioning the message of the article: that getting a piece of legacy code in a language different than the one you are familiar with is part of the challenge (of dealing with legacy systems) itself.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.