Author: Lucas Fugisawa
-
Kotlin Design Patterns: Using Cool Features To Simplify Other Design Patterns
In the previous articles, we’ve seen cases where Kotlin’s features can profoundly alter traditional design patterns to a simpler, more concise and expressive solution. In this final article of the series, we’ll explore how Kotlin’s capabilities can help simplify other patterns. The changes and impact shown here can seem to be not so expressive as…
-
Kotlin Design Patterns: Simplifying the Observer Pattern
The Observer Pattern is a behavioral design pattern where an object (the subject) maintains a list of its dependents (observers), and notifies them automatically of any state changes. This pattern ensures that multiple objects are notified when certain state changes occur. It’s widely used in implementing distributed event handling systems. The Observer Pattern decouples the…
-
Kotlin Design Patterns: Simplifying the Proxy Pattern
The Proxy Pattern is a structural design pattern in object-oriented programming. It provides a surrogate or placeholder for another object to control access to it. This pattern creates a ‘proxy’ object that acts as an intermediary between the client and the real object. It is useful when direct access to an object is impractical or…
-
Kotlin Design Patterns: Simplifying the Decorator Pattern
The Decorator Pattern is a flexible alternative to subclassing for extending functionality. It allows behavior to be added to individual objects without affecting the other objects from the same class. It is particularly useful when changes are needed during runtime. Also, it’s useful when subclassing would result in an exponential rise of new classes. The…
-
Kotlin Design Patterns: Simplifying the Prototype Pattern
We use the Prototype Pattern when creating new instances from scratch is more expensive than copying existing ones. So, instead of instantiating new objects, you can have a prototype from which clones / copies are made. Traditional Approach in Java: In this Java example, GraphicElement represents a complex graphic element with complex initialization logic, such…
-
Kotlin Design Patterns: Simplifying the Builder Pattern
The Builder pattern is a design pattern used to construct complex objects step by step. It separates the construction of an object from its representation, allowing the same construction process to create different types. When creating complex objects, direct construction using constructors might involve many parameters, leading to unclear code and difficult error handling. Also,…
-
Kotlin Design Patterns: Simplifying the Traditional Solutions (plus: Simplifying the Singleton Pattern)
Kotlin Design Patterns: Simplifying the Singleton Pattern The Singleton pattern is a design pattern that ensures a class has only one instance, while providing a global point of access to it. This pattern is used when exactly one object is needed to coordinate actions across the system. This is useful in scenarios like configuration managers,…
-
From Java to Kotlin: Elevating Back-End Development with Conciseness and Expressivity
In the evolving world of back-end development, the choice of programming language plays a pivotal role in defining the efficiency, expressiveness, and overall experience of a developer. Kotlin, a modern language that interops seamlessly with Java, has emerged as a game-changer. Why is this transition important? It’s because Kotlin offers an amalgamation of concise syntax and expressive features that significantly enhance developer productivity…