Skip to content

Week 1 - Review

How do you learn?

Learning Styles

CIS-12 Review

Classes VS Objects

  • A Class is a blueprint of an Object
  • One Class can create MANY Objects via its Constructor(s) A Class is a blueprint of an Object
  • Constructor is a special method of a class that is (usually) public, has no return type, and named the same as the Class.
  • Each Object has unique values assigned to NON-Static class attributes/fields/data members Class Attributes
  • NON-Static Class methods are Instance or Object methods
  • Static Class methods are class methods and are called by Class name and dot notation Object/Instance Methods
  • this is a keyword that refers to an object of type Class when inside a NON-static instance method of a class.

Packages

  • A Package is just a fancy way of saying, Group of Related Classes
  • Often thought of as a folder hierarchy and used to avoid naming conflicts
    • i.e. com.domain1.Box can be a different class than com.domain2.Box even though they have the same name because they have different package hierarchies/namespaces com.domain1 and com.domain2
  • Packages are often packaged as .jar files, which are really just zip files with some metadata.
  • Classes in packages can be imported via the Java import statement.
  • You can import a single class or multiple classes at the same time via import.

Diagrams

UML (Unified Modeling Language)

  • Standardized modeling languages consisting of set of diagrams.
  • Helps specify, visualize, and document software.
  • Facilitates planning, communication, and sharing on dev teams.
  • Represents best engineering practices.
  • Mermaid.Live is a good free diagram tool.
Class Diagram Example
classDiagram class WeatherStation WeatherStation : -URL url WeatherStation : -List~Display~ displays WeatherStation : -Gson gson WeatherStation : -float temperature WeatherStation : -float humidity WeatherStation : -float pressure WeatherStation : +WeatherStation() WeatherStation : +registerDisplay(display) WeatherStation : +removeDisplay(display) WeatherStation : +notifyDisplays() WeatherStation : +getTemperature() float WeatherStation : +getHumidity() float WeatherStation : +getPressure() float WeatherStation : +measure() class Display Display: -WeatherStation ws Display : update() Display : display() class CurrentConditions CurrentConditions: -WeatherStation ws CurrentConditions : -float temperature CurrentConditions : -float humidity CurrentConditions : +CurrentConditions(weatherstation) CurrentConditions : update() CurrentConditions : display() class StatisticsDisplay StatisticsDisplay: -WeatherStation ws StatisticsDisplay : -float temperatureMin StatisticsDisplay : -float temperatureMax StatisticsDisplay : -float temperatureTotal StatisticsDisplay : -int numReadings StatisticsDisplay : +StatisticsDisplay(weatherstation) StatisticsDisplay : update() StatisticsDisplay : display() class ForecastDisplay ForecastDisplay: -WeatherStation ws ForecastDisplay : -float currentPressure ForecastDisplay : -float lastPressure ForecastDisplay : +ForecastDisplay(weatherstation) ForecastDisplay : update() ForecastDisplay : display() class Client Client: -WeatherStation ws Client: -Display currentConditions Client: -Display statisticsDisplay Client: -Display forecastDisplay Client: +main(args) Display <|.. CurrentConditions Display <|.. StatisticsDisplay Display <|.. ForecastDisplay Display --* WeatherStation Client --> WeatherStation Client --> Display
Sequence Diagram Example
  • The Sequence Diagram models the interaction of objects, or services, based on a time sequence.
  • Typically isolate these to a particular scenario.
  • Use Cases or User Stories often translate directly to sequence diagrams.
sequenceDiagram participant Client participant Server Note right of Server: Listen Note left of Client: Connect Client-->>+Server: SYN SENT - SYN K Server-->>+Client: SYN RCVD SYN K, ACK J+1 Client-->>+Server: ESTABLISHED ACK K+1 Note right of Server: ESTABLISHED

Git/GitHub Workflows

References

Overview of UML