Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Create BeatTable #238 #239 #240 - #291

Merged
magwas merged 28 commits into
edemo:developfrom
valentinbujdoso:feature/create_beattable_240
Mar 28, 2019
Merged

magwas merged 28 commits into
edemo:developfrom
valentinbujdoso:feature/create_beattable_240

Conversation

@valentinbujdoso

Copy link
Copy Markdown
Contributor

Fix #238 #239 #240

@magwas

magwas commented Mar 25, 2019

Copy link
Copy Markdown
Member

The beat table is supposed to contain pairs. See https://github.com/andrewcmyers/civs/blob/master/cgi-bin/beatpath2.pm
Entities describe data structures, hence contain only public fields, and live in package org.rulez.demokracia.pdengine.dataobjects
The behaviour related to an entity is in a class derived from it.
Use Matrix as the backing type for a beat table.
Listen to sonar. A lot of times he is right.
If you have questions, ask. I'm here to help.

@magwas magwas left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also I expect sonar to find legitimate issues, please take care of them, too.

Comment thread src/test/java/org/rulez/demokracia/pdengine/BeatTableBeatInformationTest.java Outdated
Comment thread src/test/java/org/rulez/demokracia/pdengine/BeatTableBeatInformationTest.java Outdated
Comment thread src/test/java/org/rulez/demokracia/pdengine/BeatTableBeatInformationTest.java Outdated
Comment thread src/test/java/org/rulez/demokracia/pdengine/BeatTableGetPairTest.java Outdated
Comment thread src/test/java/org/rulez/demokracia/pdengine/BeatTableGetPairTest.java Outdated
Comment thread src/test/java/org/rulez/demokracia/pdengine/BeatTableGetPairTest.java Outdated
Comment thread src/test/java/org/rulez/demokracia/pdengine/BeatTableGetPairTest.java Outdated
Comment thread src/test/java/org/rulez/demokracia/pdengine/BeatTableSetPairTest.java Outdated

@magwas magwas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

At least some of the code duplication findings, none of the linguistic antipattern and all other findings by sonar seem to be legit. Of course do not comment, but fix scope.

Comment thread src/main/java/org/rulez/demokracia/pdengine/dataobjects/Pair.java Outdated
Comment thread src/main/java/org/rulez/demokracia/pdengine/BeatTable.java Outdated
Comment thread src/main/java/org/rulez/demokracia/pdengine/BeatTable.java Outdated
Comment thread src/test/java/org/rulez/demokracia/pdengine/BeatTableBeatInformationTest.java Outdated
Comment thread src/test/java/org/rulez/demokracia/pdengine/BeatTableCompareBeatsTest.java Outdated
Comment thread src/test/java/org/rulez/demokracia/pdengine/BeatTableGetPairTest.java Outdated
@magwas

magwas commented Mar 26, 2019

Copy link
Copy Markdown
Member

there are still legit sonar findings.

@valentinbujdoso

Copy link
Copy Markdown
Contributor Author

@magwas As I see there are some duplicated codes in sonar but I cannot eliminate it in a nice way.
Could you take a look?

@magwas

magwas commented Mar 27, 2019

Copy link
Copy Markdown
Member

There are actual code duplications using.

	result = beatTable.matrix.getElement(choice1, choice2);
	assertTrue(result.winning == pair.winning && result.losing == pair.losing);

Also you use the exact same code to test different things in setPair and getPair test, which means that some of the tests are redundant.

Please note that there are other problems, for example the complexity of BeatTable.
I have experimented with the traits pattern we were talking about, and BeatTable can be made as simple as

public class BeatTable extends MapMatrix<Choice, Pair> implements Matrix<Choice, Pair>, ContainingBeats {

	private static final long serialVersionUID = 1L;

	public BeatTable(final Collection<Choice> keyCollection) {
		super(keyCollection);
	}

}

Comment thread src/main/java/org/rulez/demokracia/pdengine/BeatTable.java Outdated
Comment thread src/main/java/org/rulez/demokracia/pdengine/BeatTable.java Outdated
Comment thread src/main/java/org/rulez/demokracia/pdengine/dataobjects/Pair.java
@valentinbujdoso

Copy link
Copy Markdown
Contributor Author

@magwas Could you run the sonar to not whine about the public entites?

Comment thread src/main/java/org/rulez/demokracia/pdengine/ContainingBeats.java
Comment thread src/main/java/org/rulez/demokracia/pdengine/ContainingBeats.java Outdated
Comment thread src/main/java/org/rulez/demokracia/pdengine/ContainingBeats.java Outdated
@TestedBehaviour("Unimplemented")
@Test
public void compareBeats_is_not_yet_implemented_when_the_result_is_tie() {
assertThrows(() -> beatTable.compareBeats(beats1, beats1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

use assertUnimplemented

@valentinbujdoso valentinbujdoso Mar 27, 2019 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

as I see there is no such a method like assertUnimplemented yet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok I think I created that method I hope you will like it. :)

Comment thread src/test/java/org/rulez/demokracia/pdengine/BeatTableCompareBeatsTest.java Outdated

@magwas magwas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice work

@magwas
magwas merged commit c08ba94 into edemo:develop Mar 28, 2019
@magwas

magwas commented Mar 28, 2019

Copy link
Copy Markdown
Member

testcaseCount=10

magwas pushed a commit that referenced this pull request Apr 11, 2019
* Create BeatTable #238 #239 #240

* CompareBeats #249 #250

* Add unimplemeneted test

* Traits pattern
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants