Save this video free

UNC COMP 301 - F26/Lec 11 - UML; Creational Design Patterns: Singleton, Multiton, Factory

Muhammad Sayeed Ghani · 1:15:26 · Watch on YouTube

Part of UNC Chapel Hill COMP 301. See all 22 lectures and search them

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Overview

The lecture introduces UML class diagrams, then compares three creational patterns: Singleton for one shared instance, Multiton for one instance per key, and Factory Method for centralizing subclass creation. It also revisits composition over inheritance, showing how two dog traits with three options each produce nine inheritance subclasses.

Key takeaways

Chapters

0:00 Why COMP 301 Adds UML Before Creational Patterns
1:49 UML Class Boxes, Visibility, Fields, and Methods
5:59 Course Roster Example: Person Interface and Abstract Base Class
8:49 UML Notation for Interfaces and Abstract Classes
11:10 Student and Professor Inheritance in UML
14:27 Course Ownership: Professor Aggregation and Roster Composition
20:02 Roster Multiplicity, Student Aggregation, and Main Dependencies
27:47 Creational Patterns and Singleton Use Cases
33:25 Singleton Construction: Private Constructor and Static Access
37:46 Singleton's Static Instance Check and UML Representation
43:44 Singleton Tradeoffs and the Multiton Identity Requirement
49:33 Multiton with a PID-to-Student HashMap
55:19 Factory Method: Scattered Notification Subclass Selection
1:02:42 Factory Method Centralizes Notification Creation
1:10:56 Composition Over Inheritance and the Dog Class Explosion

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

0:01 Good afternoon everyone. So I hope your exam went well. Uh the grading is in process but I don't think the results will be out uh before the end of this week. So uh today we will uh start our discussion on the next major design pattern which is creational design pattern. However, uh as we get into more and more complex design patterns and more complex softwares, it becomes important to be able to visualize the different relationships between the different classes. And so what I'm going to do is spend some time talking about the unified modeling language or UML as it's

0:48 referred to. That should hopefully give you a better sense of how your code is overall structured. So let's take a look at UML and we'll start by taking a look at um a piece of code that I wrote um in lecture six. I'm going to modify that somewhat and show you an example um of a of a you know program that has an interface that has an abstract class. It has a couple of implementations uh of the of the interfaces and the inheritance relationships are there and as well as you know showing relationships of composition and aggregation. So hopefully that should be

1:36 useful and then what we'll do is for the rest of the semester wherever possible we'll also show you a UML diagram of the um code that we're taking a look at. So let's take a look at an example of UML. And so uh let's start by focusing in on one particular class. So how do you depict a particular class? You start by drawing a rectangle and you show uh the rectangle as having three compartments and these compartments uh start from the top with the class name.

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

In this course

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Muhammad Sayeed Ghani.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.