Sobes.tech
Junior

What scope functions do you know in Kotlin?

sobes.tech AI

Answer from AI

  • Creational

    • Factory Method (creating objects via a factory method instead of directly through constructor)
    • Abstract Factory (interface for creating families of related objects without specifying their concrete classes)
    • Builder (step-by-step creation of complex objects, allowing different variants of the object using the same construction code)
    • Prototype (creating new objects by copying an existing sample)
    • Singleton (ensures only one instance of a class exists and provides a global access point)
  • Structural

    • Adapter (allows objects with incompatible interfaces to work together)
    • Bridge (separates abstraction and implementation, allowing them to vary independently)
    • Composite (treats individual objects and compositions uniformly)
    • Decorator (dynamically adds responsibilities to objects)
    • Facade (provides a unified interface to a set of interfaces in a subsystem)
    • Flyweight (efficiently manages a large number of small objects)
    • Proxy (provides a surrogate or placeholder for another object)
  • Behavioral

    • Chain of Responsibility (passes requests along a chain of handlers)
    • Command (encapsulates a request as an object, allowing parameterization, queuing, logging, and undo)
    • Iterator (provides a way to access elements sequentially without exposing internal structure)
    • Mediator (simplifies communication between objects by introducing a mediator object)
    • Memento (captures and externalizes an object's internal state without violating encapsulation)
    • Observer (defines a dependency between objects so that when one changes, others are notified)
    • State (allows an object to alter its behavior when its internal state changes)
    • Strategy (defines a family of algorithms, encapsulates each one, and makes them interchangeable)
    • Template Method (defines the skeleton of an algorithm in a base class, deferring some steps to subclasses)
    • Visitor (separates an algorithm from object structure, allowing new operations without changing classes)

In Android development, MVx patterns (MVP, MVVM) and patterns from Android Architecture Components (Room, ViewModel, LiveData, Navigation) are often used.

What scope functions do you know in Kotlin? — Android - sobes.tech