Skip to content

Conversation

@WencesLlobet
Copy link

No description provided.

throw new Error("Invalid next player");
}
//if not first move but play on an already played tile
else if (this._board.TileAt(x, y).Symbol != ' ') {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this._board.TileAt(x, y).Symbol content coupling

// update game state
this._lastSymbol = symbol;
this._board.AddTileAt(symbol, x, y);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is breaking rule one of the SOLID Princple (single responsibility)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can list the responsibilities with a name, you can never go bad with an apporach like that, I've came with this two, surely there can be better ones.

Responsibilites in this class:
A) decide winner
B) keep track of the turn


public Winner() : string {
//if the positions in first row are taken
if (this._board.TileAt(0, 0)!.Symbol != ' ' &&
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

content coupling here ^

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The internal content is exposed so it can be modified by external classes

We not only can access to the internals of the board but also we have to learn a protocol to interpret it. The convention ' ' means empty tile could really be any convention '_'.

Copy link
Author

@WencesLlobet WencesLlobet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to go deeper in the subjects of last thursday I would suggest on thinking of more inapplicable situations (design pattern, personal project...) like the builder pattern we discussed.

// update game state
this._lastSymbol = symbol;
this._board.AddTileAt(symbol, x, y);
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can list the responsibilities with a name, you can never go bad with an apporach like that, I've came with this two, surely there can be better ones.

Responsibilites in this class:
A) decide winner
B) keep track of the turn


public Winner() : string {
//if the positions in first row are taken
if (this._board.TileAt(0, 0)!.Symbol != ' ' &&
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The internal content is exposed so it can be modified by external classes

We not only can access to the internals of the board but also we have to learn a protocol to interpret it. The convention ' ' means empty tile could really be any convention '_'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants