COMP2511

Week 10
TUESDAY 9AM - 12PM (T09B)

TUESDAY 1PM - 4PM (T13B)

WEDNESDAY 6PM - 9PM (W18A)

Updates

  • Last day to do any lab marking. If its not marked, it will just be 0.
  • It is on you to get all your labs marked off
     
  • Assignment-ii feedback will be less detailed.
  • You may request for a more detailed feedback once you get your mark.
     
  • Need previous groups that implemented dungeon generation to demo it.

MyExperience

Please fill it in (10 mins)

Visitor Pattern

Visitor Pattern

Problem: How do I add extra functionalities to subclasses without violating open/closed principle.

Visitor Pattern

Problem: How do I add extra functionalities to subclasses without violating open/closed principle.

Visitor Pattern

Behavioural Pattern

  • Adds extra functionality to class without modifying the original (abides by open closed principle)
  • One class/interface (visitor) defines a computation/operation and another (visitable) is responsible for providing data access

Kahoot

Exam Tips

Exam Tips

  • Practice good exam techniques.
  • Get familiar with writing Java & Generics
  • Learn the patterns and the differences (YouTube has some really good resources if you don't understand certain ones).
  • Know code smells and methods of refactoring

Code Demo

Computer.java

Code Demo

In this scenario we have Computers, Keyboards and Mouses which all are of type ComputerComponent. We want to be able to 'visit' different types of Computer components by logging the following messages:

Looking at computer Corelli with memory 500 GB.
Looking at keyboard Mechanical keyboard which has 36 keys.
Looking at mouse Bluetooth mouse.

In particular though, anyone which is visiting a Computer must be validated prior to being able to visit.

Extend/modify the starter code to use the Visitor Pattern to allow different computer components to be visited.

Revision

Attendance

Feedback

COMP2511 Week 10 22T3

By kuroson

COMP2511 Week 10 22T3

  • 213