kkisiele / codekata Goto Github PK
View Code? Open in Web Editor NEWCode Katas adhering to object-oriented and clean code principles: kata04-data-munging, kata09-back-to-the-checkout, minesweeper.
Code Katas adhering to object-oriented and clean code principles: kata04-data-munging, kata09-back-to-the-checkout, minesweeper.
You asked for code reviews on the telegram chat so here are my two cents:
Any object should have an interface. For instance, in your minesweeper game, you place the mines on the Field after the Field is created. Instead, I believe Field should be an interface with a few implementations, and then when you create each Field, you wrap them with decorators. Some of them will be wrapped in the Mined
decorator. For instance:
Field mined = new Mined (
new Hidden()
);
mined.uncover(); //boom, inside Mined.uncover(), you throw an exception.
Field clear = new Hidden(
new Number(1);//or 2, or 3, or make this dynamic based on the table's size.
);
clear.uncover();//will uncover it just fine since it is not wrapped inside Mined decorator.
//Hidden.uncover() may look like this, taking into account that classes should also be immutable
public Field uncover() {
new Visible(this);
}
Field is an interface, while Hidden, Number, Mined and Visible are all implementations of it. I think with such a design, you wouldn't even need FieldState
anymore.
Furthermore, uncover()
may actually return Field[]
since, in Minesweeper, when you uncover a Field, sometimes more neighbouring fields are uncovered together, simultaneously.
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.