-
Notifications
You must be signed in to change notification settings - Fork 0
Component Code Inspection
Note, Since our Team consists of just a single pair, we decided to meet and discuss a single component, which exists on both server and client side. This component is our Invest Component and it entails all of the interface and logic for that half of the game. This includes the files invest.component.js and InvestPhase.js. While going though this component Chris was the reader, and I (Kaveh) was the recorder. I think the first major issue we found was that the logic of the best part of our game is spread over two files: InvestPhase and io.js. io.js in the end should be very barebones. For instance, setting the intervals for new points (for stock prices) is done in io.js, this should be taken care in InvestPhase.js.
onBuyStock, onSellStock, onStartHunt, onStartEvents all have some part of the component's logic in the io.js file. For now, we did not tackle this architectural problem as our code was running fine and we had more pressing issues to focus on. This refactor will be a part of our final iteration.
Another large issue is that has affected both components, being the Hunt and Invest components, is the fact that the client can make server calls for methods that are associated with a phase that they are not in. For instance, we don’t want a client trying to maliciously buy stock whilst in the hunt phase of the game.
This problem is fixed in so far as the server will ignore any erroneous requests made by the client. We did this by checking for all of our events wether or not the player was in the proper context, and if they weren't, then their request would be ignored.
We found an issue with the way in which we tabulated the score, because our investComponent had nothing to do with the player's score, and the hunt component has nothing to do with our wallet. The component's were further integrated, and we decided to give a point for each buy and sell action by the user.
Shifting our attention to the client side: A potential problem here is that the chart is generated on the client side; the numbers are handled on the server side, but the actual chart is handled by the client. This allows the client to act maliciously. They could edit the chart axis and make it more detailed than we intended to be. By this I mean that instead of seeing the intervals that we set for the Y (price) axis, they could set their own which could allow then to see more precisely the price of a stock at any given instant. This would give them a slight advantage over those playing the game with the chart being displayed the way we intended it; they can squeeze extra margins out of trades. We also discussed the matter of aesthetics, another thing which was tabled for the next iteration.
I also believe an integral part of the component of this code is the test code that we wrote, for both component. Our previous iteration had some deficiencies with their testing, so we brainstormed new tests and did our best to implement them. Kaveh and I spent a lot of time on testing, and researching how to do it and what to test. This will be another piece of the app that will be improved in the final iteration, with the development of more mocks, and so on. Specifically going to the Hunt component though; we initially did not write any concrete test for this component. This was because it was difficult to write tests from the hunt component because to get to the hunt component we had to simulate the invest phase. This was, however, resolved in the end after we implemented the rest of the tests.