Skip to content

Code review #2#9

Open
dkaznacheev wants to merge 52 commits intomasterfrom
dev
Open

Code review #2#9
dkaznacheev wants to merge 52 commits intomasterfrom
dev

Conversation

@dkaznacheev
Copy link
Copy Markdown
Owner

Часть с сетью ещё будем дописывать, но остальное вроде уже можно просмотреть.

Igor-Tukh and others added 30 commits December 1, 2017 00:19
Copy link
Copy Markdown

@dovchinnikov dovchinnikov left a comment

Choose a reason for hiding this comment

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

  • класс Player связан с моделью только Model.this.field.getSize(). Это можно передать в конструктор, чтобы убрать зависимость
  • неиспользуемые импорты
  • неиспользуемые декларации
  • не-final поля (везде)
  • слишком сильная связность. Зачем игроку знать, что он победил (markThatPlayerWin)? Просто чтобы двумя строками ниже проверить if (!players[index].playerWin) ? Это можно превратить в локальную переменную.
  • слишком много int-ов. int - сам по себе - это число, которое никакого смысла не несёт. Используйте объекты.
  • из-за предыдущей проблемы код трудно понимать, а ещё его трудно понимать из-за отсутствия документации, а так же потому что Turn.getId() - это не идентификатор хода, а индекс игрока в массиве игроков (внезапно!)

borderY = new boolean[fieledSize][fieledSize + 1];
public Field(int fieldSize) {
size = fieldSize;
field = new State[size][fieldSize];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Или [size][size] или [fieldSize][fieldSize].

public Field(int fieldSize) {
size = fieldSize;
field = new State[size][fieldSize];
borderX = new boolean[fieldSize + 1][fieldSize];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Почему +1 ?

private boolean[][] borderY;
private int treasureX;
private int treasureY;
private int treasureOwner;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

У вас тут int умеет владеть сокровищами.
Это поле должно называться treasureOwnerIndex, а ещё лучше оно должно иметь тип Player.

private State[][] field;
private boolean[][] borderX;
private boolean[][] borderY;
private int treasureX;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Заведите класс Point.


private int size;
private State[][] field;
private boolean[][] borderX;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Вот это совсем непонятно.
Что означают индексы?

private int hospitalX;
private int hospitalY;
private int exitBorderType; // 0 = X, 1 = Y
private int exitBorderX;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Point

private int treasureOwner;
private int hospitalX;
private int hospitalY;
private int exitBorderType; // 0 = X, 1 = Y
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Заведите enum

}

public void addBorderY(int row, int column){
public void addBorderY(int row, int column) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

addBorder(x,y) = setBorder(x,y,true)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Или уберите этот метод, или выразите один через другой

public int getPlayerNum() {
return playerNum;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

final ?

import ru.spbau.labyrinth.model.Model.*;

public class GameState {
public Model getModel() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Зачем этот метод?

@dovchinnikov
Copy link
Copy Markdown

Как отличается int[] в getBorderInd от int[] в getPosChange ? Почему до сих пор методы принимают и возвращают int-ы ?

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