<p>I think the outline is fine, but it isn't clear from it that students will come away with the essential understanding of what patterns really are. They aren't just <em>cool things to do</em>, but an essential step in architecture. The fact that they were first invented by an architect, not a programmer, (Christopher Alexander) is important.</p>
<p>The materials you suggest don't seem to make this obvious.</p>
<p>The essential components of a pattern are</p>
<ul>
<li>Name</li>
<li>Context (when it makes sense to use it)</li>
<li>Problem</li>
<li>Forces (what pushes you both toward and away from possible resolutions)</li>
<li>Solution</li>
<li>Examples of use</li>
</ul>
<p>Of all of these, the hardest to grasp is the Forces. They aren't the reason why you use the chosen solution, but, rather, the things that need to be &quot;balanced&quot; for a true solution rather than an arbitrary one.</p>
<p>Since your students will probably be using different sources, I suggest that you require that they take each supposed pattern and put it into an outline form, separating out the essential components as above.</p>
<p>Discussions of the actual balance of competing/opposing forces can be very interesting.</p>
<p>I once had a fairly long long-distance conversation with another author about the Iterator pattern. His idea was that each data structure should come with a single pointer/reference variable that could single out a specific element in the structure. He wrote a book (or three) in which these were used to iterate through lists and trees and such.</p>
<p>But it took me a long time to convince him that he hadn't considered all the forces at play. In particular, an algorithm that required more than one such reference was hard to write. The proper balance separates the concept of the data structure from the iterator so that multiple iterators can be in play at the same time. (Yes, this was in the early days.) Now his books (quite good, generally) have got a better structure.</p>
<p>The &quot;problem&quot; with the <a href="https://rads.stackoverflow.com/amzn/click/com/0201633612" rel="nofollow noreferrer" rel="nofollow noreferrer">GOF - Gang of Four</a> book is that it doesn't discuss <em>problems</em> for the various patterns. But, again, I think they wrote the book a bit too early when the community discussing patterns (I wasn't there yet) had an incomplete idea of what a software pattern should be.</p>
<p>Focusing too much on the solution or the structure (UML, say) can leave you with unusable tools, since you need to be able to recognize the context in a given situation to be able to apply it and to know if the forces at play are actually the same (or close to) the forces that the given solution balances. If you don't see the context, you don't know which tool to reach for. If you get the forces wrong, you pick up the wrong tool for the task.</p>
<p>In particular, since it is complicated and since your students are young and somewhat inexperienced, one pattern per team seems right. Lots of discussion and feedback seems right. But you will need to guide it. But if they can put the pattern into &quot;outline&quot; form they will have a good basis and discussion can resolve around that, not around details of some implementation.</p>
<p>I would also suggest that you pick a set of patterns for your students that work together to build things. Some patterns are frequently used together and others are sort of esoteric. Pick the more common ones. The goal should be a mini &quot;pattern language&quot; that can form the core of their programming projects.</p>
<p>I suggest you get a copy of Alexander's <em>A Pattern Language</em> and try to grok the background of the origin story of software patterns. A lot of libraries probably have copies. You certainly don't need to read it all, but the point of it was &quot;livable spaces&quot;. Something worth thinking about in software.</p>

CC BY-SA 4.0
2021-12-14T15:57:40.323Z
I'm checking out Livable Spaces.  It seems to be pdf'd on *many* professors' pages at universities.  You are correct that "forces" is the most unclear part of your list - I'm hoping to make some sense of it with the book you mentioned.
Ben I.
CC BY-SA 4.0
2021-12-14T17:22:04.810Z
@BenI. The only way a search for Livable Spaces turned up anything useful was if I added Christopher Alexander to the search. He has a wikipedia page, also.
Buffy
CC BY-SA 4.0
2021-12-17T20:57:42.640Z
Regarding your essential components, I would also add an essential property: patterns should be part of a *pattern language*, which also implies that patterns have *relationships*. That's one of the biggest flaws of the GoF book: it *does* have relationships (although it misses some, such as Iterator and Subject/Observer being category-theoretic duals of each other), but it is not a pattern language.
Jörg W Mittag
CC BY-SA 4.0
2021-12-17T21:07:21.870Z
@JörgWMittag, no, it isn't a pattern language. As I said, the GoF book was written too early. We learned a lot after that, but a lot of that learning was actually generated by the existence of the book. Note that the "Principle of Relativity" is due to Galileo (IIRC), but it took until Einstein for a deeper understanding.
Buffy
CC BY-SA 4.0
2021-12-13T20:41:37.940Z
2021-12-13T21:37:55.187Z
2021-12-13T21:37:55.187Z
Buffy
<p>I'm a student, not a professional educator.</p>
<p>I think the resource that helped me understand design patterns the best was Game Programming Patterns <a href="https://gameprogrammingpatterns.com/flyweight.html" rel="nofollow noreferrer">https://gameprogrammingpatterns.com/flyweight.html</a> which includes many original Go4 patterns as well as some gamedev-specific ones. You mentioned in a comment that this is already the textbook for the course, which I think is fantastic.</p>
<p>I might try taking a look at it to get some inspiration for what students might include in their presentation. In particular, the book focuses on practical applications for each design pattern.
It might be interesting for students to include in their presentation:</p>
<ul>
<li>A <strong>non-UML</strong> diagram of the design pattern (basically &quot;describe the pattern in your own words/images&quot;)</li>
<li>An existing app, program, or tool that they think uses their chosen design pattern, and what about the app that makes them think that design pattern is present.</li>
<li>A mapping of their implementation/classes to each part of the design pattern (I think having them present both the original pattern and their implementation would probably accomplish this)</li>
<li>An example scenario that would be very difficult/impossible to implement without their design pattern</li>
<li>Sample scenarios in which the design pattern would be totally inappropriate.</li>
<li>Their experiences working with the design pattern (did it make things easier, would it make things easier for a larger/smaller project)</li>
</ul>
<p>I guess these suggestions generally highlight <strong>identifying</strong> design patterns in other contexts, instead of just reproducing them.</p>

CC BY-SA 4.0
2021-12-27T23:36:03.767Z
Hi Tavi, thank you for your thoughts!  I like the distinction you've made about identifying versus reproducing, and I will modify my ask somewhat along these lines.  Game Programming Patterns is already our textbook, so that's a good start already!
Ben I.
CC BY-SA 4.0
2021-12-27T23:50:23.680Z
I probably should have read the comment that mentioned your textbook oops. I'll try and reorganize/clean up my answer at some point.
Tavi Kohn
CC BY-SA 4.0
2021-12-27T19:47:44.563Z
2021-12-27T23:53:17.767Z
2021-12-27T23:53:17.767Z
Tavi Kohn
<p>Beware the GOF book on design patterns: It has 3 problems.</p>
<h1>Claims that there are only about 20 patterns</h1>
<p>It states that it have all design patterns that there are. About 20.</p>
<p>The original pattern book had about 240, and stated that this is by no means all of them.</p>
<p>The GOF book mentions model view controller, and discusses how it can be implemented using design patterns. It does not list MVC as a pattern.</p>
<h1>GUI confusion</h1>
<p>All examples are for Graphical user interface design. This would continually confuse me. I would find a pattern that I thought was relevant. Start reading, and my brain would say “No this is not relevant”. My brain was matching to the GUI-ness of the pattern, and rejecting it. I could not train my self to overcome this. I have to re-write them (summarise them). The head-first book on the same patterns overcomes this.</p>
<h1>Singleton</h1>
<p>Singleton is an anti-pattern. It violates the single responsibility principle.
It is both a factory, and whatever else you want it to be. Split out into a class for the main functionality and one of the factory patterns.</p>
<h1>Conclusion</h1>
<p>Other than that, it is a good book (but get the head first version). It was a pioneer in the programming field (but see also the Chritopher Alexander original). There are now many other books on programming patterns (e.g. Plop series)</p>
<p>Use singleton and mono-state (not in the book). Only to wrap badly written code: e.g. code that assumes that every PC has one or zero serial ports.</p>

CC BY-SA 4.0
2021-12-17T19:28:06.360Z
I'm currently only using chapter 1 of that book, because that is the document where the authors laid out, philosophically, why this should be an area of study, and provided a lot of interesting general insights.  No other book that I've seen has attempted the same.  For the actual patterns, we're mostly hewing to "Game Programming Patterns", which is a much more modern take.
Ben I.
CC BY-SA 4.0
2021-12-17T20:06:35.430Z
I disagree about singleton. Preventing multiple instances is sometimes an essential requirement. And what "original" patterns book are your referring to?
Buffy
CC BY-SA 4.0
2021-12-17T21:09:30.577Z
The lack of coverage in GoF is due entirely to the early stage of understanding at which it was written. New design patterns are published every year at PLoP and at EuroPLoP among others.
Buffy
CC BY-SA 4.0
2021-12-17T21:14:05.937Z
@buffy https://arl.human.cornell.edu/linked%20docs/Alexander_A_Pattern_Language.pdf
ctrl-alt-delor
CC BY-SA 4.0
2021-12-17T21:15:06.703Z
I don't understand why you say the GoF patterns are primarily about GUI. I think the Observer pattern qualifies as it is a fundamental part of Model View Controller architecture. But I've use a lot of these "classic" patterns in building models with no UI components at all. I use Strategy and Decorator constantly (together). Iterator is used in many algorithms over data structures.
Buffy
CC BY-SA 4.0
2021-12-17T21:15:50.037Z
@buffy Preventing more than one, is almost always, mixing a factory with another class.
ctrl-alt-delor
CC BY-SA 4.0
2021-12-17T21:18:08.327Z
@Buffy no GOF patterns are not GUI pattern. However all the examples in the GOF book are GUI. I found it hard to separate from GUI, so had to re-write them in a way that I could read. I now use the head-first book when I need to refer to these patterns, (or other book for other patterns).
ctrl-alt-delor
CC BY-SA 4.0
2021-12-17T21:18:26.023Z
A Pattern Language wasn't about software at all. It took a leap of understanding to apply it to software. The required number of patterns in one field (physical architecture) is unrelated to that in another field. But yes, there are a lot more than 23 patterns as even the authors of GoF agree.
Buffy
CC BY-SA 4.0
2021-12-17T21:37:13.207Z
See the [Wikipedia page for Design Patterns](https://en.wikipedia.org/wiki/Design_Patterns) for more cogent criticisms of GoF and design patterns in general.
Buffy
CC BY-SA 4.0
2021-12-17T19:08:35.893Z
2021-12-17T19:08:35.893Z
ctrl-alt-delor
<p>I am teaching a course in object design patterns for the first time, and it is not a topic I am extremely well versed in.  My students are well aware of this, and signed up for the course fully knowing that I would be exploring alongside them.  They are pretty enthusiastic to learn together, particularly since software engineering is an extremely rare topic for high schools.  They have all completed AP Computer Science A, meaning that they are familiar with object basics, polymorphism, etc.</p>
<p>I heard from a friend whose graduate degree is in SE that her professor had assigned student presentations about design patterns, and it seems like a good idea to me. I would like to assign groups to each learn about, and present, one pattern to the class.  My current thought is to ask the students to structure their lessons thusly:</p>
<ul>
<li>A description of the pattern itself (what is it?). Have students already seen it?  (Such as factory pattern with iterators)</li>
<li>A working toy example of the pattern c#/unity (our platform for the course) to be share with their classmates</li>
<li>A uml diagram of the toy example</li>
<li>A uml diagram of the pattern in general (can be taken straight from the web)</li>
<li>Lead a discussion about when the pattern would be appropriate</li>
<li>Any other considerations that seem appropriate or important about the pattern</li>
<li>A small review quiz to be shared with the class (as learning reinforcement)</li>
</ul>
<p>I will model what I expect with two object patterns myself first (I was thinking about presenting singleton and observer patterns, though I am open to other suggestions if there are better choices), then allow them time to work in their own patterns.</p>
<p>I figure that each group will have roughly 40 minutes to present, and 10 minutes out of a 50 minute period the next day for their reinforcement quiz.</p>
<p>Here are my questions:</p>
<p>Does this seem reasonable given the topic?  Are there elements that I am missing that are specific to design patterns?  Should I allow students to freely pick from the design patterns, or should I restrict them to easier ones?  Is there anything else I should know before embarking on this path with my students?</p>

CC BY-SA 4.0
2021-12-13T15:33:26.170Z
Do students have a book on Design Patterns? I don't recommend the original GOF book as it was written before understanding about patterns had solidified (I know three of the authors and have worked with one of them). There is a later, more complete book that is equivalent in coverage but Java based and more mature (Patterns in Java: Grand). There are a lot of C# design pattern books but I don't recognize any of the authors and most are focused on dot net.
Buffy
CC BY-SA 4.0
2021-12-13T16:02:50.213Z
@Buffy They have the free book Game Programming Patterns (https://gameprogrammingpatterns.com/), which makes sense for our context.  I've given them a printout of the introduction to the GoF book since I like the way that it orients the mind, but otherwise, we're not particularly using that (or any) book.  The internet is our oyster.
Ben I.
CC BY-SA 4.0
2021-12-17T20:25:16.090Z
@Buffy: I fully agree. I always like to say that GoF is *not* a book about patterns, it as a book *of* patterns, a catalog. Teaching patterns with the GoF book is like teaching English by reading a dictionary.
Jörg W Mittag
<curriculum-design><object-oriented-paradigm><lesson-review>
Object patterns student presentation format
# Object patterns student presentation format

(Asked by: username_0 on 2021-12-13)

I am teaching a course in object design patterns for the first time, and it is not a topic I am extremely well versed in. My students are well aware of this, and signed up for the course fully knowing that I would be exploring alongside them. They are pretty enthusiastic to learn together, particularly since software engineering is an extremely rare topic for high schools. They have all completed AP Computer Science A, meaning that they are familiar with object basics, polymorphism, etc.

I heard from a friend whose graduate degree is in SE that her professor had assigned student presentations about design patterns, and it seems like a good idea to me. I would like to assign groups to each learn about, and present, one pattern to the class. My current thought is to ask the students to structure their lessons thusly:

* A description of the pattern itself (what is it?). Have students already seen it? (Such as factory pattern with iterators)
* A working toy example of the pattern c#/unity (our platform for the course) to be share with their classmates
* A uml diagram of the toy example
* A uml diagram of the pattern in general (can be taken straight from the web)
* Lead a discussion about when the pattern would be appropriate
* Any other considerations that seem appropriate or important about the pattern
* A small review quiz to be shared with the class (as learning reinforcement)

I will model what I expect with two object patterns myself first (I was thinking about presenting singleton and observer patterns, though I am open to other suggestions if there are better choices), then allow them time to work in their own patterns.

I figure that each group will have roughly 40 minutes to present, and 10 minutes out of a 50 minute period the next day for their reinforcement quiz.

Here are my questions:

Does this seem reasonable given the topic? Are there elements that I am missing that are specific to design patterns? Should I allow students to freely pick from the design patterns, or should I restrict them to easier ones? Is there anything else I should know before embarking on this path with my students?

**Tags:** curriculum-design, object-oriented-paradigm, lesson-review

> **Comments:**
> **username_1**: Do students have a book on Design Patterns? I don't recommend the original GOF book as it was written before understanding about patterns had solidified (I know three of the authors and have worked with one of them). There is a later, more complete book that is equivalent in coverage but Java based and more mature (Patterns in Java: Grand). There are a lot of C# design pattern books but I don't recognize any of the authors and most are focused on dot net.  
> **username_0**: @username_1 They have the free book Game Programming Patterns (https://gameprogrammingpatterns.com/), which makes sense for our context.  I've given them a printout of the introduction to the GoF book since I like the way that it orients the mind, but otherwise, we're not particularly using that (or any) book.  The internet is our oyster.  
> **username_2**: @username_1: I fully agree. I always like to say that GoF is *not* a book about patterns, it as a book *of* patterns, a catalog. Teaching patterns with the GoF book is like teaching English by reading a dictionary.  

---

## 3 answers

### Answer by username_1 on 2021-12-13. Score: 2

I think the outline is fine, but it isn't clear from it that students will come away with the essential understanding of what patterns really are. They aren't just *cool things to do*, but an essential step in architecture. The fact that they were first invented by an architect, not a programmer, (Christopher Alexander) is important.

The materials you suggest don't seem to make this obvious.

The essential components of a pattern are

* Name
* Context (when it makes sense to use it)
* Problem
* Forces (what pushes you both toward and away from possible resolutions)
* Solution
* Examples of use

Of all of these, the hardest to grasp is the Forces. They aren't the reason why you use the chosen solution, but, rather, the things that need to be "balanced" for a true solution rather than an arbitrary one.

Since your students will probably be using different sources, I suggest that you require that they take each supposed pattern and put it into an outline form, separating out the essential components as above.

Discussions of the actual balance of competing/opposing forces can be very interesting.

I once had a fairly long long-distance conversation with another author about the Iterator pattern. His idea was that each data structure should come with a single pointer/reference variable that could single out a specific element in the structure. He wrote a book (or three) in which these were used to iterate through lists and trees and such.

But it took me a long time to convince him that he hadn't considered all the forces at play. In particular, an algorithm that required more than one such reference was hard to write. The proper balance separates the concept of the data structure from the iterator so that multiple iterators can be in play at the same time. (Yes, this was in the early days.) Now his books (quite good, generally) have got a better structure.

The "problem" with the [GOF - Gang of Four](https://rads.stackoverflow.com/amzn/click/com/0201633612) book is that it doesn't discuss *problems* for the various patterns. But, again, I think they wrote the book a bit too early when the community discussing patterns (I wasn't there yet) had an incomplete idea of what a software pattern should be.

Focusing too much on the solution or the structure (UML, say) can leave you with unusable tools, since you need to be able to recognize the context in a given situation to be able to apply it and to know if the forces at play are actually the same (or close to) the forces that the given solution balances. If you don't see the context, you don't know which tool to reach for. If you get the forces wrong, you pick up the wrong tool for the task.

In particular, since it is complicated and since your students are young and somewhat inexperienced, one pattern per team seems right. Lots of discussion and feedback seems right. But you will need to guide it. But if they can put the pattern into "outline" form they will have a good basis and discussion can resolve around that, not around details of some implementation.

I would also suggest that you pick a set of patterns for your students that work together to build things. Some patterns are frequently used together and others are sort of esoteric. Pick the more common ones. The goal should be a mini "pattern language" that can form the core of their programming projects.

I suggest you get a copy of Alexander's *A Pattern Language* and try to grok the background of the origin story of software patterns. A lot of libraries probably have copies. You certainly don't need to read it all, but the point of it was "livable spaces". Something worth thinking about in software.

> **Comments:**
> **username_0**: I'm checking out Livable Spaces.  It seems to be pdf'd on *many* professors' pages at universities.  You are correct that "forces" is the most unclear part of your list - I'm hoping to make some sense of it with the book you mentioned.  
> **username_1**: @BenI. The only way a search for Livable Spaces turned up anything useful was if I added Christopher Alexander to the search. He has a wikipedia page, also.  
> **username_2**: Regarding your essential components, I would also add an essential property: patterns should be part of a *pattern language*, which also implies that patterns have *relationships*. That's one of the biggest flaws of the GoF book: it *does* have relationships (although it misses some, such as Iterator and Subject/Observer being category-theoretic duals of each other), but it is not a pattern language.  
> **username_1**: @JörgWMittag, no, it isn't a pattern language. As I said, the GoF book was written too early. We learned a lot after that, but a lot of that learning was actually generated by the existence of the book. Note that the "Principle of Relativity" is due to Galileo (IIRC), but it took until Einstein for a deeper understanding.  

---

### Answer by username_3 on 2021-12-27. Score: 1

I'm a student, not a professional educator.

I think the resource that helped me understand design patterns the best was Game Programming Patterns <https://gameprogrammingpatterns.com/flyweight.html> which includes many original Go4 patterns as well as some gamedev-specific ones. You mentioned in a comment that this is already the textbook for the course, which I think is fantastic.

I might try taking a look at it to get some inspiration for what students might include in their presentation. In particular, the book focuses on practical applications for each design pattern.
It might be interesting for students to include in their presentation:

* A **non-UML** diagram of the design pattern (basically "describe the pattern in your own words/images")
* An existing app, program, or tool that they think uses their chosen design pattern, and what about the app that makes them think that design pattern is present.
* A mapping of their implementation/classes to each part of the design pattern (I think having them present both the original pattern and their implementation would probably accomplish this)
* An example scenario that would be very difficult/impossible to implement without their design pattern
* Sample scenarios in which the design pattern would be totally inappropriate.
* Their experiences working with the design pattern (did it make things easier, would it make things easier for a larger/smaller project)

I guess these suggestions generally highlight **identifying** design patterns in other contexts, instead of just reproducing them.

> **Comments:**
> **username_0**: Hi Tavi, thank you for your thoughts!  I like the distinction you've made about identifying versus reproducing, and I will modify my ask somewhat along these lines.  Game Programming Patterns is already our textbook, so that's a good start already!  
> **username_3**: I probably should have read the comment that mentioned your textbook oops. I'll try and reorganize/clean up my answer at some point.  

---

### Answer by username_4 on 2021-12-17. Score: 0

Beware the GOF book on design patterns: It has 3 problems.

# Claims that there are only about 20 patterns

It states that it have all design patterns that there are. About 20.

The original pattern book had about 240, and stated that this is by no means all of them.

The GOF book mentions model view controller, and discusses how it can be implemented using design patterns. It does not list MVC as a pattern.

# GUI confusion

All examples are for Graphical user interface design. This would continually confuse me. I would find a pattern that I thought was relevant. Start reading, and my brain would say “No this is not relevant”. My brain was matching to the GUI-ness of the pattern, and rejecting it. I could not train my self to overcome this. I have to re-write them (summarise them). The head-first book on the same patterns overcomes this.

# Singleton

Singleton is an anti-pattern. It violates the single responsibility principle.
It is both a factory, and whatever else you want it to be. Split out into a class for the main functionality and one of the factory patterns.

# Conclusion

Other than that, it is a good book (but get the head first version). It was a pioneer in the programming field (but see also the Chritopher Alexander original). There are now many other books on programming patterns (e.g. Plop series)

Use singleton and mono-state (not in the book). Only to wrap badly written code: e.g. code that assumes that every PC has one or zero serial ports.

> **Comments:**
> **username_0**: I'm currently only using chapter 1 of that book, because that is the document where the authors laid out, philosophically, why this should be an area of study, and provided a lot of interesting general insights.  No other book that I've seen has attempted the same.  For the actual patterns, we're mostly hewing to "Game Programming Patterns", which is a much more modern take.  
> **username_1**: I disagree about singleton. Preventing multiple instances is sometimes an essential requirement. And what "original" patterns book are your referring to?  
> **username_1**: The lack of coverage in GoF is due entirely to the early stage of understanding at which it was written. New design patterns are published every year at PLoP and at EuroPLoP among others.  
> **username_4**: @buffy https://arl.human.cornell.edu/linked%20docs/Alexander_A_Pattern_Language.pdf  
> **username_1**: I don't understand why you say the GoF patterns are primarily about GUI. I think the Observer pattern qualifies as it is a fundamental part of Model View Controller architecture. But I've use a lot of these "classic" patterns in building models with no UI components at all. I use Strategy and Decorator constantly (together). Iterator is used in many algorithms over data structures.  
> **username_4**: @buffy Preventing more than one, is almost always, mixing a factory with another class.  
> **username_4**: @username_1 no GOF patterns are not GUI pattern. However all the examples in the GOF book are GUI. I found it hard to separate from GUI, so had to re-write them in a way that I could read. I now use the head-first book when I need to refer to these patterns, (or other book for other patterns).  
> **username_1**: A Pattern Language wasn't about software at all. It took a leap of understanding to apply it to software. The required number of patterns in one field (physical architecture) is unrelated to that in another field. But yes, there are a lot more than 23 patterns as even the authors of GoF agree.  
> **username_1**: See the [Wikipedia page for Design Patterns](https://en.wikipedia.org/wiki/Design_Patterns) for more cogent criticisms of GoF and design patterns in general.  

---

