July
17th,
2021
The Mediator's job is to organize communication between close classes. The `Mediator` pattern cuts out dependencies between components. It takes over the interaction between them, becoming the main communication hub for a group of classes. There is a reverse of the controls because components are now just telling 'what happened' instead of telling others to 'do something'. It can be found e.g. in the form of `ViewModel` in Android, where it separates UI interactions from data model changes.
kotlin
Mediator Pattern
design patterns
July
3rd,
2021
The `Decorator` pattern is used where creating separate classes which are a combination of all possibilities would result in their explosion. This pattern focuses on creating object layers to transparently and dynamically complement objects with new tasks. The decorator provides an object with the same interface as the decorated object.
kotlin
Decorator Pattern
design patterns
extension methods
Wrapper
June
26th,
2021
The Adapter or Wrapper Pattern allows you to `translate` one interface into another, expected by the client class. It is especially useful when the adapted object comes from 3rd party library, and you do not want to make your system depending on that interface, creating the so-called `anticorruption layer`. Adaptee interface changes will only affect the `Adapter` and not the rest of the code.
design patterns
Kotlin
Adapter Pattern
structural design pattern
June
21st,
2021
IntelliJ IDEA is pretty good at handling LaTeX. I dare say that it is an even better experience than TexStudio or Texmaker, which are dedicated to this type of project. However, the strength of IntelliJ is not in its out-of-the-box capabilities, but plugins and manual configuration of the build process.
IDE
plugins
IntelliJ
LaTeX
June
13th,
2021
The facade allows you to hide the details of the module from clients. It ensures compliance with `Law Demeter`. Using the generic interface and various implementations greatly simplifies testing. It blends well with other patterns like `Strategy`,` Template Method`, or construction patterns, allowing configuration of the object available for the clients. The facade is a good entry point for libraries, giving customers access to high-level functionality and hiding all internal logic and classes.
design patterns
Kotlin
Facade Pattern
structural design pattern
June
5th,
2021
The `Strategy` pattern creates a family of algorithms, enclosing the differing logic in separate classes while hiding it from clients behind the interface. It enables the interchangeable use of implementations. The use of the strategy simplifies the customer code, avoids code duplication and conditional statements. Significantly simplifies testing - by separating client testing from strategy algorithms.
design patterns
Kotlin
Strategy Pattern
behavioral design pattern
May
18th,
2021
The template method is a very simple design pattern, that separates shared class parts from changing ones. The core idea is to have an abstract parent class containing the algorithm steps and allowing inheriting classes to overwrite individual steps, but not the algorithm that uses those steps itself.
design patterns
Kotlin
Template Method
behavioral design pattern
March
8th,
2021
The factory of factories, 'Abstract Factory' makes creating objects that are part of some 'family' easy. It is another layer over concrete factories delivering client the factory instance for creating objects of a certain variant.
design patterns
Kotlin
Abstract Factory
construction design pattern
February
26th,
2021
After the `Static Factory Method` it's time for classic `Factory`. Factory is very useful and often used construction design pattern. Kotlin has interesting advantage thanks to `sealed` and `internal` classes, that are missing in Java.
design patterns
Kotlin
Factory Method
construction design pattern
February
15th,
2021
`Static Factory Methods` known from Java have their place also in Kotlin, although they look and behave a bit different because there is no `static` word in Kotlin. Here I'll try to show how to use `companion object` for `Static Factory Methods` and more. PS: This whole post was supposed to be about `Factory Method` with just a short mention about static factory methods, but the topic becomes more interesting than I thought :)
design patterns
Kotlin
Static Factory Methods
construction design pattern