CompSci 307 Fall 2021 |
Software Design and Implementation |
This exercise is intended to help you to learn to separate a program's concerns by focusing on modern program's two major parts: the model, typically called the backend, is the dynamic data structure, its "knowledge", logic and rules; the view, typically called the frontend, is a visual representation of the model and can be any number of output representations of information and ways to interact with the data. One feature of this de facto design standard is that these parts can typically be developed and tested separately.
While there will not be an official submission for this exercise, this code will be the basis for this week's programming exercise.
Here is a review of the steps you will use to work with GIT during lab (as distinct from assigned team projects):
lab_browser
into their own repository to allow pushing your group's changes
Settings -> Members
to add your partner so both people in the group can access the same repositoryMaintainer
role in the project and choose Add to Project
git clone
to copy the one forked repository to their individual machines so they can work on their own separate copiesOpen
the cloned folder to create a new project on their personal machineDISCUSSION.md
file included in the repositoryDISCUSSION.md
using Gitlab's Markdown formatgit add
changed files
git commit -m
to describe your changes
git push
changes back to Gitlab
git pull
changes from Gitlab back to the local machine (if you are not sharing a single computer)
DISCUSSION.md
using Gitlab's Markdown format This project implements a basic (nano-small) web browser where OpenJFX handles all the work to display the website's HTML and your code handles the data structures to model different ways to work with the websites (represented as URLs) such as: history of sites visited, favorite sites, most visited sites, etc. Currently, only history is implemented but adding the other features is complicated because the model and view code are mixed together.
Take some time to play with the program and also explore the code to make sure you understand how it works.
As a reminder, the goal of separating these two concepts is to create a "backend" model that has no dependencies on specific view classes (like OpenJFX) so that the "frontend" can more easily be varied as new frameworks or new kinds of devices are developed. The clearest way to achieve this goal is make sure none of your backend classes import
anything from the javafx
package (sometimes java.awt
is okay since its utility classes are used in all modern Java frameworks) and instead return
requested or computed data when needed by the view.
Examine the code to identify what behaviors are associated with URL data and what are associated with the display of the URL's contents. Note, methods may interact with both sides and will likely need to separated out themselves to achieve your goals.
Here are some questions to get your discussion started:
Finally, consider adding common modern browser features (like a favorites map of title to URL) to the program:
Refactor the NanoBrowser
class based on your discussion to thoughtfully, deliberately, split it into separate model and view classes in separate packages.
The following example steps show moving the existing code to a new class and then calling the new methods in place of the old code so that you always feel in control of the changes being made to the code when refactoring:
NanoBroswerModel
, and rename the existing NanoBrowser
class to NanoBrowserView
.NanoBroswerModel
class (even though it has no methods) in the main()
method, pass it to the NanoBrowserView
class's constructor, and assign it to an instance variable.NanoBroswerModel
class and the active method(s) that use it (rather than simply making a passive getter/setter for the variable).public
method calls on the model's method that return a useful value to the view.Practice using refactoring safely so you are not stuck with a lot of syntax and logic errors that ruin your larger design goals!
Labs in this course expect you to work either in pairs or with your project team.
Professionally, this practice is called Pair Programming: working closely with another programmer, sharing a "single computer" that we will simulate using a shared computer, shared repository or use IntelliJ's new Code With Me feature. To ensure both people do some coding, you will switch which person actually writes the code every 10-15 minutes (in industry this switch happens only 1-3 times per day). The person who is not actively coding can be advising, suggesting better names, looking up documentation, or searching the Internet for solutions to small problems you are likely to face, but not multi-tasking (i.e., doing their own work or socializing).