CompSci 307 Fall 2021 |
Software Design and Implementation |
In your Cell Society team, use today's lab time to focus only on the project's design rather than adding new features.
You will know your design is on the right track if your code:
Work on today's lab following these steps:
REFACTORING_DISCUSSION.md
file and add it to the repository in the doc
folderrefactoringLab
At the end of lab, use Gitlab's Merge Request to submit your team's updated code and doc/REFACTORING_DISCUSSION.md
file from its separate refactoringLab
branch to the team repository's master
branch. Make sure the Title of your Merge Request is of the form "lab_refactoring - participating NETIDs".
It is fine to accept this Merge Request after lab whenever your team is ready.
Use our app that helps organize and prioritize issues to clarify issues found using static analysis. It should be noted that static analysis in no way guarantees your code is well designed, it only helps find potential flaws and brings them to your attention. For example, it is clearly a design flaw to have public
instance variables, but you can still have a bad design even if all of your instance variables are private
. While you are not required to remove all issues found by this tool, you should be prepared to justify your decisions if significant issues are left in your code (e.g., with comments near the lines flagged as issues in any of the reports).
To begin discussing the code's design, review the top issues found in your code's most recent master
branch using the following steps and record the results in your discussion file:
Some issues may refer to the same piece of code (likely making that code a higher priority to refactor), some issues may have easy fixes, and some may require more thought or require more sweeping changes. For example, as we have discussed in class, sometimes removing duplicated code is as simple as creating a new method and sometimes it requires creating a new class or abstraction.
Additionally, consider the priorities of the project specific design goals minimally expected of every team:
public
instance variables (also note, protected
instance variables also break encapsulation and should be avoided, but public
ones are simply poor design)public
references to grid's data structure implementation (i.e., as a 2D array or a List
of List
s) should appear as a parameter or return typeinstanceof
checks (except in equals()
methods)if
or switch
) based on a "type" or enumerable property that distinguishes small differences in behaviorimport javafx.XXX
) to OpenJFX classes within your model classes (even javafx.scene.paint.Color
)String.format()
for dynamic information rather than '+
'List
, Set
, Map
, Collection
, or even Iterator
rather than concrete types such as ArrayList
or HashMap
throw
an exception rather than return null
or simply call printStackTrace()
Not every team will have all of the issues above, but every team has at least one of the issues above. They represent a minimal set of design goals for this project that every team should be able to reach and, once you have verified that these issues are taken care of, you can use this time to clean up any aspect of the project's design.
Now that your team has considered how to improve the project's design, choose small refactorings to move forward implementing actual changes to your code to move it towards that design in a controlled manner. Let IntelliJ help you as much as possible with its Refactor menu and keep on top of any syntax errors that are produced with each change so it remains manageable and does not spiral out of control. Commit your changes to this lab's separate GIT branch frequently in case you need to roll back something.
Once you have verified that the primary issues and the formatting issues are taken care of, you can use the rest of the time to clean up any other aspect of the project's design or to add more tests.