CS Blog

CS-343 Quarter 1

We did three things this quarter.



PlantUML is a tool that generates diagrams based on their domain-specific language. Here's an example structural diagram:

@startuml
title Hello World - Structural Diagram

class Hello {
    +sayHello()
}

class World {
    +receiveHello()
}

Hello --> World : says "Hello"
@enduml
Hello World Diagram

There are also ones known as "Sequence Diagrams" that outline a program's flow of operations while showing the scope of each variable. I don't know when it'd come in handy but that may change once I do the capstone assignment.

They look something like this:

@startuml
participant "Program" as Program
participant "main()" as Main
participant "readInput()" as Read
participant "printOutput()" as Print

Program -> Main: call main()
activate Main

Main -> Read: call readInput()
activate Read
Read -> Read: get user input
deactivate Read
Main <-- Read: return input

Main -> Print: call printOutput(input)
activate Print
Print -> Print: print to console
deactivate Print

deactivate Main
Program <-- Main: end main()
@enduml
Hello World Diagram



We then applied what we learned to refactor a duck codebase into variants that follow the Strategy and Singleton patterns. The usage of a structural diagram helped visualize the attribtues and relations between classes immensely. I'd see myself using at least the structural diagrams for collaborative projects as we'd iron out a design for our codebase to follow.