CompSci 308 Spring 2023 |
Advanced Software Design and Implementation |
SonarQube combines a number of static code analysis tools to automatically generate issues by looking for certain features in your code (such as public
instance variables). We have created an app that helps organize and prioritize those issues to clarify why these issues are relevant to your design. It should be noted that this analysis in no way guarantees your code is well designed, it only helps find obvious potential flaws and brings them to your attention. For example, it is an obvious 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 app, you should be prepared to justify why you left significant issues in your code (e.g., with comments near the lines flagged as issues in any of the reports).
As a team, use today's lab time to focus only on the project's design rather than adding new features.
At the end of class, use Gitlab's Merge Request within your team repository to submit your group's discussion file, doc/REFACTORING_DISCUSSION.md
, and your refactored code from the separate branch, refactoringLab
, to your master
branch.
Make sure the Title of your Merge Request is of the form "lab_cellsociety_refactoring - NetIDs".
In your Cell Society teams, complete the following activities today:
REFACTORING_DISCUSSION.md
in the doc
folder using Gitlab's markdown formatrefactoringLab
refactoringLab
branch to your team's master
branch so the changes can be compared and approved before being integrated
Individually, share your interpretation of the Open-Closed and Liskov Substitution Design Principles and how they apply to the abstractions you have created in the project.
As a group, for each current abstraction in your project, discuss how it helps close a core algorithm in your project and how its subclasses are designed to be substitutable.
Additionally, discuss three new abstractions that would be helpful in light of the given change requirements.
Examine the results of SonarQube's static analysis of your most recent master
branch and, as a team, discuss how fixing each issue would improve the overall program design as well as which issues you think are the most important to work on first. 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, sometimes it requires creating an inheritance hierarchy, sometimes generics is the right approach, or a new class or abstraction may be required.
To begin discussing the code's design, review the top issues found in your code using the following steps and record the results in your discussion file:
Note, the top issues on the Dashboard that are organized roughly in the following order:
For each of these kinds of issues, you can also see the complete list of issues in your project rather than just the top ones by selecting a specific file, colored and sized by how many issues it has, or by the category option at the bottom of the Dashboard (in its footer).
In your discussion file, describe why you chose to refactor the code as you did and what, if any, alternatives you considered.
As a reminder of some of the project specific design goals, here are a minimal set that every team is expected to reach:
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 in any public
method signatureList
, Set
, Map
, Collection
, or even Iterator
rather than concrete types such as ArrayList
or HashMap
if
or switch
) per inheritance hierarchy can be used in the entire project and only for purposes of calling new
instanceof
checks (except in equals()
methods)Object
returned from Java to a known abstraction is often required, but not to concrete subclasses throw
an exception, rather than return null
or simply call printStackTrace()
, and frontend classes should catch
those exceptionsimport javafx.XXX
) to OpenJFX classes within your model classes (not even javafx.scene.paint.Color
or javafx.geometry.Point2D
)String.format()
for dynamic information rather than '+
'model
, view
, and configuration
)Not every team will have all of the issues above, but every team has at least one of these issues.
You will know your design is on the right track if your code: