![]() Notice that in the sequence diagram the two classes become three, because we need to interact with the getInstance method (which is class scoped) and with the creation of the new instance. To explain how a singleton should function, we can create a sequence diagram which shows how the two classes in our class diagram interact: This is typical for utility classes and/or classes which manage resources. ![]() The singleton design pattern is a pattern used in OO when you want to allow the creation of one instance of a specific class. And I’ll start with the singleton design pattern. Why can’t we use sequence diagrams to describe these patterns? So after posting a question in stackoverflow on the subject, and receiving no answer, I decided to take on my challenge and provide the world with a repository of design patterns in sequence diagrams. But for me the most interesting (and strange thing) was that all the patterns are described using only class diagrams (which can only express structure) while the functionality provided by the patters was regularly explained either in words, with examples and with code. Printing the nice one-page reference that can be found on Mark Gregory’s site was also very helpful. Another great source was the c2 design patterns entry. I found some sources, one of them obviously Wikipedia, but the best one (in my view) is sourcemaking, which gives good explanations and examples. Although I already knew some of them, I searched for some place where there is a full reference of the most popular design patterns, what are their uses and how they should be implemented. I decided that one important subject the students should learn (and was not taught in previous semesters) was design patterns. Last semester I taught an undergraduate course on system analysis and design using graphical modeling ( UML and OPM).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |