CompSci 308 Spring 2023 |
Advanced Software Design and Implementation |
The most difficult problem in teaching object-oriented programming is getting the learner to give up the global knowledge of control that is possible with procedural programs, and rely on the local knowledge of objects to accomplish their tasks. Novice designs are littered with regressions to global thinking: gratuitous global variables, unnecessary pointers, and inappropriate reliance on the implementation of other objects. — Kent Beck
As a team, use today's lab time to focus only on the project's design rather than adding new features, using the Design Coach static analysis app:
Use the course's Design Coach tool and IntelliJ to verify your project does not have a easily findable design flaws. 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). As a reminder, no automated tool guarantees your code is well designed, it only helps find potential flaws and brings them to your attention.
At the end of class, use Gitlab's Merge Request to submit your group's discussion files 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_slogo_refactoring - NetIDs".
In your SLogo teams, complete the following activities today:
API_CHANGES.md
in the doc
folder using Gitlab's Markdown formatREFACTORING_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
At the beginning of this project your team defined four APIs: an external and internal set of public methods for each "side" of the project. For most of you this was your first time specifically designing an API and you did not know a lot about the project you were building. Since then you have also learned new Java techniques that you may have incorporated into your design.
Start by reviewing your original API designs (in your doc/plan/DESIGN_PLAN.md
file and the interfaces you created to express that design) as well as your current API (represented here as your project's public methods). When looking at the current version of your API you may decide that some methods do not actually need to be public or that a new interface or class would be useful to more clearly separate part of an internal from an external API or to hide an implementation choice or to add flexibility to the code. To help you clarify the design goals of your APIs, you may want to spend some time reviewing your API's design goals and describing your internal APIs to each other (e.g., how to add a new command to the backend or a new View component to the frontend).
As a team, try to determine:
Recall that one of the requirements for this project is that your team complete a document, doc/API_CHANGES.md
, that describes how your APIs have evolved over the course of the project. This exercise is intended to help you determine the content of that document.
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.
Review the top issues found in your code using the following steps and record the results in your discussion file:
Not every team will have all of the issues below, but every team has at least one of the issues below. 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.
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:
private
instance variablesList
, Set
, Map
, Collection
, or even Iterator
rather than concrete types such as ArrayList
or HashMap
if
or switch
) can be used in the entire projectinstanceof
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 '+
'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: