Project 1 Solitaire Part 1 Review; CST338 Week 4

Project 1 Part 1 Reflection

After cloning this project, I took a tour through the folder and document structure.  This project has several more .md files to review and reference.  I focused on the relevant Card and Deck ones for review, then reviewed the assignment outline again in Canvas.  I keep the assignment outline and the relevant .md files open and off to the side so I can constantly reference them.

Making a plan before hand would normally be a solid staring approach.  However, this assignment presents several //TODO items in the code, so I started tackling them from top to bottom.  Because some items were "stand alone" (did not need to involve other items), this worked pretty well.  Some items did involve other items but because the existing method and field names were clear, it did not cause confusion.

I don't think this project really lent itself to a planning phase.  The code, structure, and todo items were delivered - we just needed to complete them.  We didn't design anything, we worked on small todo items in an existing project.  Maybe later in the project we will do more from-scratch implementation.  In that case, I would like to take my time deciding what kind of approach the project is taking, what kind of design pattern is being used.  I would like to spend some time working on the class UMLs and making sure they make sense.  One of our other projects this week mentions the Single Responsibility Principle and I would like to keep this in mind.

While it was satisfying to complete the missing parts represented by the //TODO items, I did not celebrate once the unit tests passed.  Because a lot was provided to us, I don't feel that I accomplished very much.  I suppose I could take a moment and celebrate that I did not have to go back and do much troubleshooting.  There was some with the removeCardsFrom() method, but everything else went pretty smooth.  This assignment was more about reinforcement than new learning.

On considering the OOP concepts, I don't feel that I understand anything better than before.  If I had to pick one thing, it would be how to setup and use enum objects in Java.  It did take me a little bit of staring at the provided code to understand what I was seeing in the listed enums and how they have properties of their own.

Peer Code Review

This week I reviewed Khiem Vo's Project 1 Solitaire code for Card and Deck classes.

One thing Khiem did different is using a Card's Suit or Rank methods instead of the Card's similar methods.  For example, isRed() is a method of a Card and also a Suit.  This logic is closest to Suit, and Card just call's the isRed() method from Suit and returns the result.  I used the Card's methods instead of the Suit's methods.  The result amounts to the same thing, but Khiem may be correct that using the Suit's method is better in case that code changes in the future. The implementation of Card's method is so simple I don't think it makes a difference one way or the other.

Some responses to prompts from the code review assignment.



Encapsulation

  • Are instance variables private? Why does that matter here?
    • Yes, they are private, per the assignment specification. Instance variables should be private to enforce encapsulation. Getters and setters will be used externally.
  • Do getters and setters exist where appropriate? Are there any that probably shouldn't exist?
    • Getters and setters are present according to the assignment spec. Mostly getters as several internal values should not change after instantiation. The setters that are present make sense to exist and none exist that do not make sense.

Constructors
  • Does the constructor validate its inputs? What happens if someone passes an invalid suit or value?
    • No, constructors are not validating inputs. Deck() has no inputs so nothing to validate. Card has two constructors. Inputs are not validated (Suit, Rank). I did not validate my inputs either. If a Suit with an unknown name or symbol is used, it will be used without validation. Same with Rank. Should validation happen in the Rank and Suit enums?
  • Is there a default constructor? Should there be one for Card? For Deck?
    • Card does not have a default constructor. We are not extending Card, so at this time it should not need a default constructor.


Deck does have a default constructor and needs no other constructor.

Readability and Style

  • Can you follow the logic without running the code?
    • Yes
  • Does the code follow the Google Java Style Guide in terms of naming, braces, and spacing?
    • Yes
  • Note: checkstyle can automate style checking — ask your classmate if they used it. If neither of you knows how, that is worth finding out.
    • I don’t know what checkstyle is. I used IntelliJ’s Code -> Reformat Code to align with the Google Java Style guide.

Comments

Popular posts from this blog

Project Management, Time Management, Study Skills, Outline Revisions - Week 2

Goal Setting, Time Mgmt Review, Expert Interview, Ethics Paper - Week 4

Goals; Capstone Project Ideas; Weekly Learning - Week 5