PetRockBlock https://blog.petrockblock.com Fun Stuff for Technics Enthusiasts Tue, 14 Aug 2018 15:39:46 +0000 en-US hourly 1 Design Patterns with PlantUML: Template Pattern https://blog.petrockblock.com/2018/08/07/design-patterns-plantuml-template-pattern/ https://blog.petrockblock.com/2018/08/07/design-patterns-plantuml-template-pattern/#respond Tue, 07 Aug 2018 07:07:33 +0000 https://blog.petrockblock.com/?p=125303 This post gives a brief overview about the Template Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML. The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML …

The post Design Patterns with PlantUML: Template Pattern appeared first on PetRockBlock.

]]>
This post gives a brief overview about the Template Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML.

The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML diagram. Then, the second part provides the PlantUML code for the diagram so that these posts can also be used as a source of design patterns in PlantUML syntax.

What is the Template Pattern?

According to Wikipedia, the Template Pattern has two main parts, and typically uses object-oriented programming:

  • The “template method”, generally implemented as a base class (possibly an abstract class), which contains shared code and parts of the overall algorithm which are invariant. The template ensures that the overarching algorithm is always followed. In this class, “variant” portions are given a default implementation, or none at all.
  • Concrete implementations of the abstract class, which fill in the empty or “variant” parts of the “template” with specific algorithms that vary from implementation to implementation.

At run-time, a concrete class is instantiated. A main method inherited from the base class is called, which then may call other methods defined by both the base class and subclasses. This performs the overall algorithm in the same steps every time, but the details of some steps depend on which subclass was instantiated.

UML Diagram

The following diagram shows the Template Method Pattern in UML notation. It is based on the corresponding chapter in the book “Head First Design Patterns“:

PlantUML Syntax:
<p>@startuml<br />
class AbstractClass {<br />
templateMethod()<br />
{abstract} primitiveOperation1()<br />
{abstract} primitiveOperation2()<br />
}<br />
class ConcreteClass</p>
<p>ConcreteClass : primitiveOperation1()<br />
ConcreteClass : primitiveOperation2()</p>
<p>AbstractClass <|.. ConcreteClass</p>
<p>note left of AbstractClass<br />
The AbstractClass<br />
contains the template<br />
method.<br />
end note</p>
<p>note left of ConcreteClass<br />
There may be many<br />
ConcreteClasses, each<br />
implementing the full set of<br />
operations required by the<br />
template method.<br />
end note</p>
<p>note right of ConcreteClass<br />
The ConcreteClass implements<br />
the abstract operations,<br />
which are called when the<br />
templateMethod() needs them.<br />
end note</p>
<p>note right of AbstractClass::templateMethod<br />
The template method makes use of the<br />
primitiveOperations to implement an<br />
algorithm. It is decoupled from the actual<br />
implementation of the operations<br />
“”primitiveOperation1()””<br />
“”primitiveOperation2()””<br />
end note<br />
@enduml</p>

PlantUML Sources

PlantUML is a tool allowing users to create UML diagrams from a plain text language. Here are the PlantUML sources for the above software pattern:


@startuml
class AbstractClass {
templateMethod()
{abstract} primitiveOperation1()
{abstract} primitiveOperation2()
}
class ConcreteClass

ConcreteClass : primitiveOperation1()
ConcreteClass : primitiveOperation2()

AbstractClass &amp;lt;|.. ConcreteClass
@enduml

Other Design Patterns

In another article you find information about how to put together a single-side web application using PlantUML.

Template Pattern Design Patterns with PlantUML: Template Pattern - This post gives a brief overview about the Template Pattern. The post is part of a series about software design ... Read More
Facade Pattern Design Patterns with PlantUML: Facade Pattern - This post gives a brief overview about the Facade Pattern. The post is part of a series about software design ... Read More
Adapter Pattern Design Patterns with PlantUML: Adapter Pattern - This post gives a brief overview about the Adapter Pattern. The post is part of a series about software design ... Read More
Command Pattern Design Patterns with PlantUML: Command Pattern - This post gives a brief overview about the Command Pattern. The post is part of a series about software design ... Read More
Singleton Design Patterns with PlantUML: Singleton - This post gives a brief overview about the Singleton Pattern. The post is part of a series about software design ... Read More
Design Patterns with PlantUML: Abstract Factory Pattern - This post gives a brief overview about the Abstract Factory Pattern. The post is part of a series about software design ... Read More
Design Patterns with PlantUML: Factory Method Pattern - This post gives a brief overview about the Factory Method Pattern. The post is part of a series about software ... Read More
Decorator Pattern Design Patterns with PlantUML: Decorator Pattern - This post gives a brief overview about the Decorator Pattern. The post is part of a series about software design ... Read More
Observer Pattern Design Patterns with PlantUML: Observer Pattern - This post gives a brief overview about the Observer Pattern. The post is part of a series about software design ... Read More

The post Design Patterns with PlantUML: Template Pattern appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2018/08/07/design-patterns-plantuml-template-pattern/feed/ 0
Update for PowerBlock Driver: Pin Configuration and Logging https://blog.petrockblock.com/2018/08/03/update-powerblock-driver-1-5-0/ https://blog.petrockblock.com/2018/08/03/update-powerblock-driver-1-5-0/#respond Fri, 03 Aug 2018 13:22:26 +0000 https://blog.petrockblock.com/?p=125484 The driver of our popular Raspberry Pi Power Switch add-on board PowerBlock got a feature update! More configuration, more logging, faster shutdown. What comes with this Feature Update? So, what’s new in this update? Basically, these are the two things: The status and shutdown pins on the Raspberry side can now be configured. This allows …

The post Update for PowerBlock Driver: Pin Configuration and Logging appeared first on PetRockBlock.

]]>
The driver of our popular Raspberry Pi Power Switch add-on board PowerBlock got a feature update! More configuration, more logging, faster shutdown.

What comes with this Feature Update?

So, what’s new in this update? Basically, these are the two things:

  • The status and shutdown pins on the Raspberry side can now be configured. This allows to use other HATs that might use the default pin numbers 17 and 18. The configuration file can be found at /etc/powerblockconfig.cfg.
  • The PowerBlock driver now has its own logger so that you can follow every action of it, if you are interested. You can find it at /var/log/powerblock.log
PowerBlock Logging Messages
PowerBlock Logging Messages

Besides that, the shutdown time was optimised so that a shutdown is much faster (again) now.

The new driver has version 1.5.0.

You can update your driver by simply re-installing the driver as depicted in the Installation Instructions.

The post Update for PowerBlock Driver: Pin Configuration and Logging appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2018/08/03/update-powerblock-driver-1-5-0/feed/ 0
Design Patterns with PlantUML: Facade Pattern https://blog.petrockblock.com/2018/07/23/design-patterns-plantuml-facade-pattern/ https://blog.petrockblock.com/2018/07/23/design-patterns-plantuml-facade-pattern/#respond Mon, 23 Jul 2018 15:34:47 +0000 https://blog.petrockblock.com/?p=125300 This post gives a brief overview about the Facade Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML. The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML …

The post Design Patterns with PlantUML: Facade Pattern appeared first on PetRockBlock.

]]>
This post gives a brief overview about the Facade Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML.

The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML diagram. Then, the second part provides the PlantUML code for the diagram so that these posts can also be used as a source of design patterns in PlantUML syntax.

What is the Facade Pattern?

According to Wikipedia, a facade can:

  • make a software library easier to use, understand, and test, since the facade has convenient methods for common tasks
  • make the library more readable, for the same reason
  • reduce dependencies of outside code on the inner workings of a library, since most code uses the facade, thus allowing more flexibility in developing the system
  • wrap a, subjectively, poorly-designed collection of APIs with a single well-designed API

Implementors often use the facade design pattern when a system is very complex or difficult to understand because the system has a large number of interdependent classes or because its source code is unavailable. This pattern hides the complexities of the larger system and provides a simpler interface to the client.

What problems can the Facade design pattern solve?

  • To make a complex subsystem easier to use, a simple interface should be provided for a set of interfaces in the subsystem.
  • The dependencies on a subsystem should be minimized.

Clients that access a complex subsystem directly refer to (depend on) many different objects having different interfaces (tight coupling), which makes the clients hard to implement, change, test, and reuse.

What solution does the Facade design pattern describe?

Define a Facade object that

  • implements a simple interface in terms of (by delegating to) the interfaces in the subsystem and
  • may perform additional functionality before/after forwarding a request.

This enables to work through a Facade object to minimize the dependencies on a subsystem.

UML Diagram

The following diagram shows the Facade Pattern in UML notation. It is based on the corresponding chapter in the book “Head First Design Patterns“:

PlantUML Syntax:
<p>@startuml<br />
class Client<br />
class Facade<br />
Client -> Facade</p>
<p>package “Subsystem Classes” <<rectangle>> {</p>
<p>note “More complex subsystem” as n1</p>
<p>Facade — “class 1”<br />
Facade — “class 2”</p>
<p>package “class 1” <<rectangle>> {<br />
}</p>
<p>package “class 2” <<rectangle>> {<br />
}</p>
<p>package “class 3” <<rectangle>> {<br />
}</p>
<p>package “class 4” <<rectangle>> {<br />
}</p>
<p>package “class 5” <<rectangle>> {<br />
}</p>
<p>package “class 6” <<rectangle>> {<br />
}</p>
<p>“class 1” — “class 2”<br />
“class 1” — “class 3”<br />
“class 2” — “class 4”<br />
“class 3” — “class 5”<br />
“class 3” — “class 6”<br />
“class 4” — “class 5”<br />
“class 4” — “class 6”<br />
}</p>
<p>note left of Client<br />
Happy client whose<br />
job just became<br />
easier because of<br />
the facade.<br />
end note</p>
<p>note right of Facade<br />
Unified interface<br />
that is easier to use.<br />
end note<br />
@enduml</p>

PlantUML Sources

PlantUML is a tool allowing users to create UML diagrams from a plain text language. Here are the PlantUML sources for the above software pattern:


@startuml
class Client
class Facade
Client -> Facade

package "Subsystem Classes" <<rectangle>> {

note "More complex subsystem" as n1

Facade -- "class 1"
Facade -- "class 2"

package "class 1" <<rectangle>> {
}

package "class 2" <<rectangle>> {
}

package "class 3" <<rectangle>> {
}

package "class 4" <<rectangle>> {
}

package "class 5" <<rectangle>> {
}

package "class 6" <<rectangle>> {
}

"class 1" -- "class 2"
"class 1" -- "class 3"
"class 2" -- "class 4"
"class 3" -- "class 5"
"class 3" -- "class 6"
"class 4" -- "class 5"
"class 4" -- "class 6"
}

note left of Client
Happy client whose
job just became
easier because of
the facade.
end note

note right of Facade
Unified interface
that is easier to use.
end note
@enduml

Other Design Patterns

In another article you find information about how to put together a single-side web application using PlantUML.

Template Pattern Design Patterns with PlantUML: Template Pattern - This post gives a brief overview about the Template Pattern. The post is part of a series about software design ... Read More
Facade Pattern Design Patterns with PlantUML: Facade Pattern - This post gives a brief overview about the Facade Pattern. The post is part of a series about software design ... Read More
Adapter Pattern Design Patterns with PlantUML: Adapter Pattern - This post gives a brief overview about the Adapter Pattern. The post is part of a series about software design ... Read More
Command Pattern Design Patterns with PlantUML: Command Pattern - This post gives a brief overview about the Command Pattern. The post is part of a series about software design ... Read More
Singleton Design Patterns with PlantUML: Singleton - This post gives a brief overview about the Singleton Pattern. The post is part of a series about software design ... Read More
Design Patterns with PlantUML: Abstract Factory Pattern - This post gives a brief overview about the Abstract Factory Pattern. The post is part of a series about software design ... Read More
Design Patterns with PlantUML: Factory Method Pattern - This post gives a brief overview about the Factory Method Pattern. The post is part of a series about software ... Read More
Decorator Pattern Design Patterns with PlantUML: Decorator Pattern - This post gives a brief overview about the Decorator Pattern. The post is part of a series about software design ... Read More
Observer Pattern Design Patterns with PlantUML: Observer Pattern - This post gives a brief overview about the Observer Pattern. The post is part of a series about software design ... Read More

The post Design Patterns with PlantUML: Facade Pattern appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2018/07/23/design-patterns-plantuml-facade-pattern/feed/ 0
Design Patterns with PlantUML: Adapter Pattern https://blog.petrockblock.com/2018/07/16/design-patterns-plantuml-adapter-pattern/ https://blog.petrockblock.com/2018/07/16/design-patterns-plantuml-adapter-pattern/#respond Mon, 16 Jul 2018 18:08:03 +0000 https://blog.petrockblock.com/?p=125298 This post gives a brief overview about the Adapter Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML. The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML …

The post Design Patterns with PlantUML: Adapter Pattern appeared first on PetRockBlock.

]]>
This post gives a brief overview about the Adapter Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML.

The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML diagram. Then, the second part provides the PlantUML code for the diagram so that these posts can also be used as a source of design patterns in PlantUML syntax.

What is the Adapter Pattern?

According to Wikipedia, the Adapter Pattern is a design patternthat allows the interface of an existing class to be used as another interface.

The Adapter design pattern solves problems like:

  • How can a class be reused that does not have an interface that a client requires?
  • How can classes that have incompatible interfaces work together?
  • How can an alternative interface be provided for a class?

Often an (already existing) class can’t be reused only because its interface doesn’t conform to the interface clients require.

The Adapter design pattern describes how to solve such problems:

  • Define a separate Adapter class that converts the (incompatible) interface of a class (Adaptee) into another interface (Target) clients require.
  • Work through an Adapter to work with (reuse) classes that do not have the required interface.

The key idea in this pattern is to work through a separate Adapter that adapts the interface of an (already existing) class without changing it. Clients don’t know whether they work with a Target class directly or through an Adapter with a class that does not have the Target interface.

UML Diagram

The following diagram shows the Adapter Pattern in UML notation. It is based on the corresponding chapter in the book “Head First Design Patterns“:

PlantUML Syntax:
<p>@startuml<br />
class Client<br />
class Target <<interface>><br />
class Adapter<br />
class Adaptee<br />
Target : request()<br />
Adapter : request()<br />
Adaptee : specificRequest()</p>
<p>Client -> Target<br />
Target <|.. Adapter<br />
Adapter -> Adaptee<br />
note on link<br />
Adapter is composed<br />
with the Adapter.<br />
end note</p>
<p>note bottom of Client<br />
The client sees only the<br />
Target interface<br />
end note</p>
<p>note “The Adapter implements\nthe Target interface.” as n1<br />
Target .. n1<br />
n1 .. Adapter</p>
<p>note bottom of Adaptee<br />
All requests get<br />
delegated to the<br />
Adaptee.<br />
end note<br />
@enduml</p>

PlantUML Sources

PlantUML is a tool allowing users to create UML diagrams from a plain text language. Here are the PlantUML sources for the above software pattern:


@startuml
class Client
class Target <<interface>>
class Adapter
class Adaptee
Target : request()
Adapter : request()
Adaptee : specificRequest()

Client -> Target
Target <|.. Adapter Adapter -> Adaptee
note on link
Adapter is composed
with the Adapter.
end note

note bottom of Client
The client sees only the
Target interface
end note

note "The Adapter implements\nthe Target interface." as n1
Target .. n1
n1 .. Adapter

note bottom of Adaptee
All requests get
delegated to the
Adaptee.
end note
@enduml

Other Design Patterns

In another article you find information about how to put together a single-side web application using PlantUML.

Template Pattern Design Patterns with PlantUML: Template Pattern - This post gives a brief overview about the Template Pattern. The post is part of a series about software design ... Read More
Facade Pattern Design Patterns with PlantUML: Facade Pattern - This post gives a brief overview about the Facade Pattern. The post is part of a series about software design ... Read More
Adapter Pattern Design Patterns with PlantUML: Adapter Pattern - This post gives a brief overview about the Adapter Pattern. The post is part of a series about software design ... Read More
Command Pattern Design Patterns with PlantUML: Command Pattern - This post gives a brief overview about the Command Pattern. The post is part of a series about software design ... Read More
Singleton Design Patterns with PlantUML: Singleton - This post gives a brief overview about the Singleton Pattern. The post is part of a series about software design ... Read More
Design Patterns with PlantUML: Abstract Factory Pattern - This post gives a brief overview about the Abstract Factory Pattern. The post is part of a series about software design ... Read More
Design Patterns with PlantUML: Factory Method Pattern - This post gives a brief overview about the Factory Method Pattern. The post is part of a series about software ... Read More
Decorator Pattern Design Patterns with PlantUML: Decorator Pattern - This post gives a brief overview about the Decorator Pattern. The post is part of a series about software design ... Read More
Observer Pattern Design Patterns with PlantUML: Observer Pattern - This post gives a brief overview about the Observer Pattern. The post is part of a series about software design ... Read More

The post Design Patterns with PlantUML: Adapter Pattern appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2018/07/16/design-patterns-plantuml-adapter-pattern/feed/ 0
Design Patterns with PlantUML: Command Pattern https://blog.petrockblock.com/2018/07/02/design-patterns-plantuml-command-pattern/ https://blog.petrockblock.com/2018/07/02/design-patterns-plantuml-command-pattern/#respond Mon, 02 Jul 2018 19:49:00 +0000 https://blog.petrockblock.com/?p=125294 This post gives a brief overview about the Command Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML. The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML …

The post Design Patterns with PlantUML: Command Pattern appeared first on PetRockBlock.

]]>
This post gives a brief overview about the Command Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML.

The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML diagram. Then, the second part provides the PlantUML code for the diagram so that these posts can also be used as a source of design patterns in PlantUML syntax.

What is the Command Pattern?

According to Wikipedia, the Command Pattern is a behavioral design pattern in which an object is used to encapsulate all information needed to perform an action or trigger an event at a later time. This information includes the method name, the object that owns the method and values for the method parameters.

The Command Pattern solves problems like:

  • Coupling the invoker of a request to a particular request should be avoided. That is, hard-wired requests should be avoided.
  • It should be possible to configure an object (that invokes a request) with a request.

Implementing (hard-wiring) a request directly into a class is inflexible because it couples the class to a particular request at compile-time, which makes it impossible to specify a request at run-time.

What solution does the Command design pattern describe?

  • Define separate (command) objects that encapsulate a request.
  • A class delegates a request to a command object instead of implementing a particular request directly.

This enables one to configure a class with a command object that is used to perform a request. The class is no longer coupled to a particular request and has no knowledge (is independent) of how the request is carried out.

UML Diagram

The following diagram shows the Command Pattern in UML notation. It is based on the corresponding chapter in the book “Head First Design Patterns“:

PlantUML Syntax:
<p>@startuml<br />
class Client<br />
class Invoker<br />
class Command <<interface>><br />
class Receiver<br />
class ConcreteCommand</p>
<p>Invoker : setCommand()<br />
Command : execute()<br />
Command : undo()<br />
Receiver : action()<br />
ConcreteCommand : execute()<br />
ConcreteCommand : undo()</p>
<p>Client -> Receiver<br />
Client -> ConcreteCommand<br />
Receiver <- ConcreteCommand<br />
Invoker -> Command<br />
Command <|.. ConcreteCommand</p>
<p>note left of Client<br />
The Client is responsible for<br />
creating a ConcreteCommand and<br />
setting its Receiver.<br />
end note</p>
<p>note bottom of Receiver<br />
The Receiver knows how to<br />
perform the work needed to<br />
carry out the request. Any class<br />
can act as a Receiver.<br />
end note</p>
<p>note bottom of ConcreteCommand<br />
The ConcreteCommand defines a binding between an action<br />
and a Receiver. The Invoker makes a request by calling<br />
execute() and the ConcreteCommand carries it out by<br />
calling one or more actions on the Receiver.<br />
end note</p>
<p>note left of Invoker<br />
The Invoker holds<br />
a command and at<br />
some point asks the<br />
command to carry<br />
out a request by<br />
calling its execute()<br />
method.<br />
end note</p>
<p>note top of Command<br />
Command declares an interface for all commands. A<br />
command is invoked through its execute() method,<br />
which asks a receiver to perform its action.<br />
end note</p>
<p>note right of ConcreteCommand::execute()<br />
The execute method invokes the action(s)<br />
on the receiver needed to fulfill the<br />
request;</p>
<p>“”public void execute() {“”<br />
“” receiver.action()””<br />
“”}””</p>
<p>end note<br />
@enduml</p>

PlantUML Sources

PlantUML is a tool allowing users to create UML diagrams from a plain text language. Here are the PlantUML sources for the above software pattern:


@startuml
class Client
class Invoker
class Command <<interface>>
class Receiver
class ConcreteCommand

Invoker : setCommand()
Command : execute()
Command : undo()
Receiver : action()
ConcreteCommand : execute()
ConcreteCommand : undo()

Client -> Receiver
Client -> ConcreteCommand
Receiver <- ConcreteCommand

Invoker -> Command
Command <|.. ConcreteCommand

@enduml

Other Design Patterns

In another article you find information about how to put together a single-side web application using PlantUML.

Template Pattern Design Patterns with PlantUML: Template Pattern - This post gives a brief overview about the Template Pattern. The post is part of a series about software design ... Read More
Facade Pattern Design Patterns with PlantUML: Facade Pattern - This post gives a brief overview about the Facade Pattern. The post is part of a series about software design ... Read More
Adapter Pattern Design Patterns with PlantUML: Adapter Pattern - This post gives a brief overview about the Adapter Pattern. The post is part of a series about software design ... Read More
Command Pattern Design Patterns with PlantUML: Command Pattern - This post gives a brief overview about the Command Pattern. The post is part of a series about software design ... Read More
Singleton Design Patterns with PlantUML: Singleton - This post gives a brief overview about the Singleton Pattern. The post is part of a series about software design ... Read More
Design Patterns with PlantUML: Abstract Factory Pattern - This post gives a brief overview about the Abstract Factory Pattern. The post is part of a series about software design ... Read More
Design Patterns with PlantUML: Factory Method Pattern - This post gives a brief overview about the Factory Method Pattern. The post is part of a series about software ... Read More
Decorator Pattern Design Patterns with PlantUML: Decorator Pattern - This post gives a brief overview about the Decorator Pattern. The post is part of a series about software design ... Read More
Observer Pattern Design Patterns with PlantUML: Observer Pattern - This post gives a brief overview about the Observer Pattern. The post is part of a series about software design ... Read More

The post Design Patterns with PlantUML: Command Pattern appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2018/07/02/design-patterns-plantuml-command-pattern/feed/ 0
Design Patterns with PlantUML: Singleton https://blog.petrockblock.com/2018/06/28/design-patterns-plantuml-singleton/ https://blog.petrockblock.com/2018/06/28/design-patterns-plantuml-singleton/#respond Thu, 28 Jun 2018 19:28:30 +0000 https://blog.petrockblock.com/?p=125288 This post gives a brief overview about the Singleton Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML. The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML …

The post Design Patterns with PlantUML: Singleton appeared first on PetRockBlock.

]]>
This post gives a brief overview about the Singleton Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML.

The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML diagram. Then, the second part provides the PlantUML code for the diagram so that these posts can also be used as a source of design patterns in PlantUML syntax.

What is the Singleton Pattern?

According to Wikipedia, the Singleton Pattern is a software design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system.

The singleton pattern solves problems like:

  • How can it be ensured that a class has only one instance?
  • How can the sole instance of a class be accessed easily?
  • How can a class control its instantiation?
  • How can the number of instances of a class be restricted?

The singleton design pattern describes how to solve such problems:

  • Hide the constructor of the class.
  • Define a public static operation (getInstance()) that returns the sole instance of the class.

The key idea in this pattern is to make the class itself responsible for controlling its instantiation (that it is instantiated only once).
The hidden constructor (declared private) ensures that the class can never be instantiated from outside the class.
The public static operation can be accessed easily by using the class name and operation name (Singleton.getInstance()).

UML Diagram

The following diagram shows the Singleton Pattern in UML notation. It is based on the corresponding chapter in the book “Head First Design Patterns“:

PlantUML Syntax:
<p>@startuml<br />
title Singleton</p>
<p>class Singleton</p>
<p>Singleton : {static} uniqueInstance<br />
Singleton : // other useful Singleton data …<br />
Singleton : {static} getInstance() : Singleton<br />
Singleton : // other useful Singleton methods()</p>
<p>note right of Singleton<br />
The uniqueInstance<br />
class variable holds our<br />
one and only instance<br />
of Singleton<br />
end note</p>
<p>note left of Singleton<br />
The getInstance() method is static,<br />
which means it’s a class method, so you<br />
can conveniently access this method<br />
from anywhere in your code using<br />
Singleton getInstance(). That’s just as<br />
easy as accessing a global variable, but<br />
we get benefit like lazy instantiation<br />
from the Singleton.<br />
end note</p>
<p>note bottom of Singleton<br />
A class implementing the Singleton<br />
Pattern is more than a Singleton;<br />
it is a purpose class with its<br />
own set of data and methdods.<br />
end note<br />
@enduml</p>

PlantUML Sources

PlantUML is a tool allowing users to create UML diagrams from a plain text language. Here are the PlantUML sources for the above software pattern:


@startuml
title Singleton

class Singleton

Singleton : {static} uniqueInstance
Singleton : // other useful Singleton data ...
Singleton : {static} getInstance() : Singleton
Singleton : // other useful Singleton methods()

@enduml

Other Design Patterns

In another article you find information about how to put together a single-side web application using PlantUML.

Template Pattern Design Patterns with PlantUML: Template Pattern - This post gives a brief overview about the Template Pattern. The post is part of a series about software design ... Read More
Facade Pattern Design Patterns with PlantUML: Facade Pattern - This post gives a brief overview about the Facade Pattern. The post is part of a series about software design ... Read More
Adapter Pattern Design Patterns with PlantUML: Adapter Pattern - This post gives a brief overview about the Adapter Pattern. The post is part of a series about software design ... Read More
Command Pattern Design Patterns with PlantUML: Command Pattern - This post gives a brief overview about the Command Pattern. The post is part of a series about software design ... Read More
Singleton Design Patterns with PlantUML: Singleton - This post gives a brief overview about the Singleton Pattern. The post is part of a series about software design ... Read More
Design Patterns with PlantUML: Abstract Factory Pattern - This post gives a brief overview about the Abstract Factory Pattern. The post is part of a series about software design ... Read More
Design Patterns with PlantUML: Factory Method Pattern - This post gives a brief overview about the Factory Method Pattern. The post is part of a series about software ... Read More
Decorator Pattern Design Patterns with PlantUML: Decorator Pattern - This post gives a brief overview about the Decorator Pattern. The post is part of a series about software design ... Read More
Observer Pattern Design Patterns with PlantUML: Observer Pattern - This post gives a brief overview about the Observer Pattern. The post is part of a series about software design ... Read More

The post Design Patterns with PlantUML: Singleton appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2018/06/28/design-patterns-plantuml-singleton/feed/ 0
Design Patterns with PlantUML: Abstract Factory Pattern https://blog.petrockblock.com/2018/06/27/design-patterns-plantuml-abstract-factory-pattern/ https://blog.petrockblock.com/2018/06/27/design-patterns-plantuml-abstract-factory-pattern/#respond Wed, 27 Jun 2018 19:11:55 +0000 https://blog.petrockblock.com/?p=125285 This post gives a brief overview about the Abstract Factory Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML. The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML …

The post Design Patterns with PlantUML: Abstract Factory Pattern appeared first on PetRockBlock.

]]>
This post gives a brief overview about the Abstract Factory Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML.

The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML diagram. Then, the second part provides the PlantUML code for the diagram so that these posts can also be used as a source of design patterns in PlantUML syntax.

What is the Abstract Factory Pattern?

According to Wikipedia, the Abstract Factory Pattern solves problems like:

  • How can an application be independent of how its objects are created?
  • How can a class be independent of how the objects it requires are created?
  • How can families of related or dependent objects be created?

Creating objects directly within the class that requires the objects is inflexible because it commits the class to particular objects and makes it impossible to change the instantiation later independently from (without having to change) the class. It stops the class from being reusable if other objects are required, and it makes the class hard to test because real objects can’t be replaced with mock objects.

The Abstract Factory design pattern describes how to solve such problems:

  • Encapsulate object creation in a separate (factory) object. That is, define an interface (AbstractFactory) for creating objects, and implement the interface.
  • A class delegates object creation to a factory object instead of creating objects directly.

UML Diagram

The following diagram shows the Factory Method Pattern in UML notation. It is based on the corresponding chapter in the book “Head First Design Patterns“:

PlantUML Syntax:
<p>@startuml<br />
skinparam componentStyle uml2</p>
<p>title Abstract Factory Pattern</p>
<p>class Client<br />
class AbstractFactory <<interface>><br />
class AbstractProductA <<interface>><br />
class ProductA2<br />
class ProductA1<br />
class ConcreteFactory1<br />
class ConcreteFactory2<br />
class AbstractProductB <<interface>><br />
class ProductB1<br />
class ProductB2</p>
<p>AbstractFactory <– Client<br />
Client –> AbstractProductA<br />
Client –> AbstractProductB<br />
AbstractFactory <|.. ConcreteFactory1<br />
AbstractFactory <|.. ConcreteFactory2<br />
AbstractProductA <|.. ProductA1<br />
AbstractProductA <|.. ProductA2<br />
AbstractProductB <|.. ProductB1<br />
AbstractProductB <|.. ProductB2<br />
ProductA1 <– ConcreteFactory1<br />
ProductB1 <– ConcreteFactory1<br />
ProductA2 <– ConcreteFactory2<br />
ProductB2 <– ConcreteFactory2</p>
<p>note right of Client<br />
The Client is written against the<br />
abstract factory and then composed at<br />
runtime with an actual factory.<br />
end note</p>
<p>note left of AbstractFactory<br />
The AbstractFactory defines<br />
the interface that all Concrete<br />
factories must implement which<br />
consists of a set of methods<br />
for producing products.<br />
end note</p>
<p>note “The concrete factories implement the\ndifferent product families. To create a\nproduct the client uses one of these factories,\nso it never has to instantiate a product object.” as n1<br />
ConcreteFactory1 .. n1<br />
ConcreteFactory2 .. n1</p>
<p>note “This is the product\nfamily. Each concrete\nfactory can produce an\nentire set of products.” as n2<br />
AbstractProductA .. n2<br />
AbstractProductB .. n2<br />
@enduml</p>

PlantUML Sources

PlantUML is a tool allowing users to create UML diagrams from a plain text language. Here are the PlantUML sources for the above software pattern:


@startuml
skinparam componentStyle uml2

title Abstract Factory Pattern

class Client
class AbstractFactory <<interface>>
class AbstractProductA <<interface>>
class ProductA2
class ProductA1
class ConcreteFactory1
class ConcreteFactory2
class AbstractProductB <<interface>>
class ProductB1
class ProductB2

AbstractFactory <-- Client
Client --> AbstractProductA
Client --> AbstractProductB
AbstractFactory <|.. ConcreteFactory1
AbstractFactory <|.. ConcreteFactory2
AbstractProductA <|.. ProductA1
AbstractProductA <|.. ProductA2
AbstractProductB <|.. ProductB1
AbstractProductB <|.. ProductB2
ProductA1 <-- ConcreteFactory1
ProductB1 <-- ConcreteFactory1
ProductA2 <-- ConcreteFactory2
ProductB2 <-- ConcreteFactory2
@enduml

The post Design Patterns with PlantUML: Abstract Factory Pattern appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2018/06/27/design-patterns-plantuml-abstract-factory-pattern/feed/ 0
Design Patterns with PlantUML: Factory Method Pattern https://blog.petrockblock.com/2018/06/25/design-patterns-plantuml-factory-method-pattern/ https://blog.petrockblock.com/2018/06/25/design-patterns-plantuml-factory-method-pattern/#respond Mon, 25 Jun 2018 18:27:38 +0000 https://blog.petrockblock.com/?p=125280 This post gives a brief overview about the Factory Method Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML. The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a …

The post Design Patterns with PlantUML: Factory Method Pattern appeared first on PetRockBlock.

]]>
This post gives a brief overview about the Factory Method Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML.

The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML diagram. Then, the second part provides the PlantUML code for the diagram so that these posts can also be used as a source of design patterns in PlantUML syntax.

What is the Factory Method Pattern?

According to Wikipedia, the factory method pattern is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be created. This is done by creating objects by calling a factory method—either specified in an interface and implemented by child classes, or implemented in a base class and optionally overridden by derived classes—rather than by calling a constructor.

UML Diagram

The following diagram shows the Factory Method Pattern in UML notation. It is based on the corresponding chapter in the book “Head First Design Patterns“:

PlantUML Syntax:
<p>@startuml</p>
<p>title Factory Method Pattern</p>
<p>class Product<br />
class Creator<br />
class ConcreteProduct<br />
class ConcreteCreator</p>
<p>Creator : factoryMethod()<br />
Creator : anOperation()<br />
ConcreteCreator : factoryMethod()</p>
<p>Creator <|– ConcreteCreator<br />
Product <|– ConcreteProduct<br />
ConcreteProduct <- ConcreteCreator</p>
<p>note top of Creator<br />
The Creator is a class that contains<br />
the implementation for all of the<br />
methods to manipulate products,<br />
except for the factory method.<br />
end note</p>
<p>note right of Creator<br />
The abstract factoryMethod()<br />
is what all Creator subclasses<br />
must implement.<br />
end note</p>
<p>note right of ConcreteCreator<br />
The ConcreteCreator<br />
implements the<br />
factoryMethod(), which is<br />
the method that actually<br />
produces products.<br />
end note</p>
<p>note “The ConcreteCreator is responsible for\ncreating one or more concrete products. It\nis the only class that has the knowledge of\nhow to create these products.” as n1<br />
ConcreteProduct .. n1<br />
ConcreteCreator .. n1</p>
<p>note “All products must implement\nthe same interface so that the\nclasses which use the products\ncan refer to the interface,\nnot the concrete class.” as n2<br />
n2 . ConcreteProduct<br />
n2 . Product</p>
<p>@enduml</p>

PlantUML Sources

PlantUML is a tool allowing users to create UML diagrams from a plain text language. Here are the PlantUML sources for the above software pattern:


@startuml

title Factory Method Pattern

class Product
class Creator
class ConcreteProduct
class ConcreteCreator

Creator : factoryMethod()
Creator : anOperation()
ConcreteCreator : factoryMethod()

Creator <|-- ConcreteCreator
Product <|-- ConcreteProduct
ConcreteProduct <- ConcreteCreator

@enduml

Other Design Patterns

In another article you find information about how to put together a single-side web application using PlantUML.

Template Pattern Design Patterns with PlantUML: Template Pattern - This post gives a brief overview about the Template Pattern. The post is part of a series about software design ... Read More
Facade Pattern Design Patterns with PlantUML: Facade Pattern - This post gives a brief overview about the Facade Pattern. The post is part of a series about software design ... Read More
Adapter Pattern Design Patterns with PlantUML: Adapter Pattern - This post gives a brief overview about the Adapter Pattern. The post is part of a series about software design ... Read More
Command Pattern Design Patterns with PlantUML: Command Pattern - This post gives a brief overview about the Command Pattern. The post is part of a series about software design ... Read More
Singleton Design Patterns with PlantUML: Singleton - This post gives a brief overview about the Singleton Pattern. The post is part of a series about software design ... Read More
Design Patterns with PlantUML: Abstract Factory Pattern - This post gives a brief overview about the Abstract Factory Pattern. The post is part of a series about software design ... Read More
Design Patterns with PlantUML: Factory Method Pattern - This post gives a brief overview about the Factory Method Pattern. The post is part of a series about software ... Read More
Decorator Pattern Design Patterns with PlantUML: Decorator Pattern - This post gives a brief overview about the Decorator Pattern. The post is part of a series about software design ... Read More
Observer Pattern Design Patterns with PlantUML: Observer Pattern - This post gives a brief overview about the Observer Pattern. The post is part of a series about software design ... Read More

The post Design Patterns with PlantUML: Factory Method Pattern appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2018/06/25/design-patterns-plantuml-factory-method-pattern/feed/ 0
Design Patterns with PlantUML: Decorator Pattern https://blog.petrockblock.com/2018/06/24/design-patterns-plantuml-decorator-pattern/ https://blog.petrockblock.com/2018/06/24/design-patterns-plantuml-decorator-pattern/#respond Sun, 24 Jun 2018 18:35:04 +0000 https://blog.petrockblock.com/?p=125257 This post gives a brief overview about the Decorator Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML. The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML …

The post Design Patterns with PlantUML: Decorator Pattern appeared first on PetRockBlock.

]]>
This post gives a brief overview about the Decorator Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML. The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML diagram. Then, the second part provides the PlantUML code for the diagram so that these posts can also be used as a source of design patterns in PlantUML syntax.

What is the Decorator Pattern?

According to Wikipedia, the decorator pattern is a design pattern that allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class. The decorator pattern is often useful for adhering to the Single Responsibility Principle, as it allows functionality to be divided between classes with unique areas of concern.

UML Diagram

The following diagram shows the Decorator Pattern in UML notation. It is based on the corresponding chapter in the book “Head First Design Patterns“:

PlantUML Syntax:
<p>@startuml<br />
skinparam componentStyle uml2</p>
<p>class Component<br />
class ConcreteComponent<br />
class Decorator<br />
class ConcreteDecoratorA<br />
class ConcreteDecoratorB</p>
<p>Component : methodA()<br />
Component : methodB()<br />
Component : // otherMethods()</p>
<p>ConcreteComponent : methodA()<br />
ConcreteComponent : methodB()<br />
ConcreteComponent : // otherMethods()</p>
<p>Decorator : methodA()<br />
Decorator : methodB()<br />
Decorator : // otherMethods()</p>
<p>ConcreteDecoratorA : Component wrappedObject<br />
ConcreteDecoratorA : methodA()<br />
ConcreteDecoratorA : methodB()<br />
ConcreteDecoratorA : newBehavior()<br />
ConcreteDecoratorA : // otherMethods()</p>
<p>ConcreteDecoratorB : Component wrappedObject<br />
ConcreteDecoratorB : Object newState<br />
ConcreteDecoratorB : methodA()<br />
ConcreteDecoratorB : methodB()<br />
ConcreteDecoratorB : // otherMethods()</p>
<p>Component <|– ConcreteComponent<br />
Component <|– Decorator<br />
Decorator <|– ConcreteDecoratorA<br />
Decorator <|– ConcreteDecoratorB<br />
Decorator –> Component : component<br />
note right on link<br />
Each component can be used on its<br />
own, or wrapped by a decorator<br />
component<br />
end note</p>
<p>note bottom of ConcreteComponent<br />
The ConreteComponent<br />
is the object we are going<br />
to dynamically add new<br />
behavior to it. It extends<br />
Component.<br />
end note</p>
<p>note bottom of Decorator<br />
Decorators implement the<br />
same interface or abstract<br />
class as the component they<br />
are going to decorate.<br />
end note</p>
<p>note bottom of ConcreteDecoratorB<br />
Decorators can extend the<br />
state of the component<br />
end note</p>
<p>note bottom of ConcreteDecoratorB<br />
Decorators can add new methods;<br />
however, new behavior is typically<br />
added by doing computation<br />
before or after an existing method<br />
in the component.<br />
end note</p>
<p>note bottom of ConcreteDecoratorA<br />
The ConcreteDecorator has an<br />
instance variable for the thing<br />
it decorates (the Component the<br />
Decorator wraps).<br />
end note<br />
@enduml</p>

PlantUML Sources

PlantUML is a tool allowing users to create UML diagrams from a plain text language. Here are the PlantUML sources for the above software pattern:


@startuml
skinparam componentStyle uml2

class Component
class ConcreteComponent
class Decorator
class ConcreteDecoratorA
class ConcreteDecoratorB

Component : methodA()
Component : methodB()
Component : // otherMethods()

ConcreteComponent : methodA()
ConcreteComponent : methodB()
ConcreteComponent : // otherMethods()

Decorator : methodA()
Decorator : methodB()
Decorator : // otherMethods()

ConcreteDecoratorA : Component wrappedObject
ConcreteDecoratorA : methodA()
ConcreteDecoratorA : methodB()
ConcreteDecoratorA : newBehavior()
ConcreteDecoratorA : // otherMethods()

ConcreteDecoratorB : Component wrappedObject
ConcreteDecoratorB : Object newState
ConcreteDecoratorB : methodA()
ConcreteDecoratorB : methodB()
ConcreteDecoratorB : // otherMethods()

Component <|-- ConcreteComponent
Component <|-- Decorator
Decorator <|-- ConcreteDecoratorA
Decorator <|-- ConcreteDecoratorB
Decorator --> Component : component

@enduml

Other Design Patterns

In another article you find information about how to put together a single-side web application using PlantUML.

Template Pattern Design Patterns with PlantUML: Template Pattern - This post gives a brief overview about the Template Pattern. The post is part of a series about software design ... Read More
Facade Pattern Design Patterns with PlantUML: Facade Pattern - This post gives a brief overview about the Facade Pattern. The post is part of a series about software design ... Read More
Adapter Pattern Design Patterns with PlantUML: Adapter Pattern - This post gives a brief overview about the Adapter Pattern. The post is part of a series about software design ... Read More
Command Pattern Design Patterns with PlantUML: Command Pattern - This post gives a brief overview about the Command Pattern. The post is part of a series about software design ... Read More
Singleton Design Patterns with PlantUML: Singleton - This post gives a brief overview about the Singleton Pattern. The post is part of a series about software design ... Read More
Design Patterns with PlantUML: Abstract Factory Pattern - This post gives a brief overview about the Abstract Factory Pattern. The post is part of a series about software design ... Read More
Design Patterns with PlantUML: Factory Method Pattern - This post gives a brief overview about the Factory Method Pattern. The post is part of a series about software ... Read More
Decorator Pattern Design Patterns with PlantUML: Decorator Pattern - This post gives a brief overview about the Decorator Pattern. The post is part of a series about software design ... Read More
Observer Pattern Design Patterns with PlantUML: Observer Pattern - This post gives a brief overview about the Observer Pattern. The post is part of a series about software design ... Read More

The post Design Patterns with PlantUML: Decorator Pattern appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2018/06/24/design-patterns-plantuml-decorator-pattern/feed/ 0
Design Patterns with PlantUML: Observer Pattern https://blog.petrockblock.com/2018/06/24/design-patterns-plantuml-observer-pattern/ https://blog.petrockblock.com/2018/06/24/design-patterns-plantuml-observer-pattern/#respond Sun, 24 Jun 2018 18:25:35 +0000 https://blog.petrockblock.com/?p=125241 This post gives a brief overview about the Observer Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML. The post aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML …

The post Design Patterns with PlantUML: Observer Pattern appeared first on PetRockBlock.

]]>
This post gives a brief overview about the Observer Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML. The post aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML diagram. Then, the second part provides the PlantUML code for the diagram so that these posts can also be used as a source of design patterns in PlantUML syntax.

What is the Observer Pattern?

According to Wikipedia, the observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. It is mainly used to implement distributed event handling systems, in “event driven” software.

The pattern addresses these problems:

  • A one-to-many dependency between objects should be defined without making the objects tightly coupled.
  • It should be ensured that when one object changes state an open-ended number of dependent objects are updated automatically.
  • It should be possible that one object can notify an open-ended number of other objects.

UML Diagram

The following diagram shows the Observer Pattern in UML notation. It is based on the corresponding chapter in the book “Head First Design Patterns“:

PlantUML Syntax:
<p>@startuml</p>
<p>title Observer Pattern</p>
<p>class Subject <<interface>><br />
class Observer <<interface>><br />
class ConcreteSubject<br />
class ConcreteObserver</p>
<p>Subject : registerObserver(Observer)<br />
Subject : removeObserver(Observer)<br />
Subject : notifyObservers()</p>
<p>Observer : update()<br />
ConcreteObserver : update()<br />
ConcreteObserver : // otherObserverMethods()</p>
<p>ConcreteSubject : registerObserver(Observer) {…}<br />
ConcreteSubject : removeObserver(Observer) {…}<br />
ConcreteSubject : notifyObservers() {…}</p>
<p>Subject “1” -right-> “*” Observer : “observers”</p>
<p>ConcreteSubject <-left- ConcreteObserver : “subject”<br />
Subject <|– ConcreteSubject<br />
Observer <|— ConcreteObserver</p>
<p>note left of Subject<br />
The Subject Interface<br />
Objects use this interface to register<br />
as observers and also to remove<br />
themselves from being observers.<br />
end note</p>
<p>note left of ConcreteSubject<br />
A concrete subject always<br />
implements the Subject<br />
interface. In addition to<br />
the register and remove<br />
methods, the concrete subject<br />
implements a notifyObservers()<br />
method that is used to update<br />
all the current observers<br />
whenever state changes.<br />
end note</p>
<p>note bottom of ConcreteSubject<br />
The conrete subject<br />
may also have methods for<br />
setting and getting its state.<br />
end note</p>
<p>note bottom of ConcreteObserver<br />
Concrete observers can be<br />
any class that implements the<br />
Observer interface. Each<br />
observer registers with a concrete<br />
subject to receive updates.<br />
end note</p>
<p>note top of Observer<br />
All potential observers need<br />
to implement the Observer<br />
interface. This interface<br />
just has one method, update(),<br />
that gets called when the<br />
Subject’s state changes.<br />
end note</p>
<p>@enduml</p>

PlantUML Sources

PlantUML is a tool allowing users to create UML diagrams from a plain text language. Here are the PlantUML sources for the above software pattern:

@startuml
title Observer Pattern

class Subject <<interface>>
class Observer <<interface>>
class ConcreteSubject
class ConcreteObserver

Subject : registerObserver(Observer)
Subject : removeObserver(Observer)
Subject : notifyObservers()

Observer : update()
ConcreteObserver : update()
ConcreteObserver : // otherObserverMethods()

ConcreteSubject : registerObserver(Observer) {...}
ConcreteSubject : removeObserver(Observer) {...}
ConcreteSubject : notifyObservers() {...}

Subject "1" -right-> "*" Observer : "observers"

ConcreteSubject <-left- ConcreteObserver : "subject"
Subject <|-- ConcreteSubject
Observer <|-- ConcreteObserver
@enduml 

Other Design Patterns

In another article you find information about how to put together a single-side web application using PlantUML.

Here is a list of posts with other Design Patterns:

Template Pattern Design Patterns with PlantUML: Template Pattern - This post gives a brief overview about the Template Pattern. The post is part of a series about software design ... Read More
Facade Pattern Design Patterns with PlantUML: Facade Pattern - This post gives a brief overview about the Facade Pattern. The post is part of a series about software design ... Read More
Adapter Pattern Design Patterns with PlantUML: Adapter Pattern - This post gives a brief overview about the Adapter Pattern. The post is part of a series about software design ... Read More
Command Pattern Design Patterns with PlantUML: Command Pattern - This post gives a brief overview about the Command Pattern. The post is part of a series about software design ... Read More
Singleton Design Patterns with PlantUML: Singleton - This post gives a brief overview about the Singleton Pattern. The post is part of a series about software design ... Read More
Design Patterns with PlantUML: Abstract Factory Pattern - This post gives a brief overview about the Abstract Factory Pattern. The post is part of a series about software design ... Read More
Design Patterns with PlantUML: Factory Method Pattern - This post gives a brief overview about the Factory Method Pattern. The post is part of a series about software ... Read More
Decorator Pattern Design Patterns with PlantUML: Decorator Pattern - This post gives a brief overview about the Decorator Pattern. The post is part of a series about software design ... Read More
Observer Pattern Design Patterns with PlantUML: Observer Pattern - This post gives a brief overview about the Observer Pattern. The post is part of a series about software design ... Read More

The post Design Patterns with PlantUML: Observer Pattern appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2018/06/24/design-patterns-plantuml-observer-pattern/feed/ 0