Skip to main content
a z C o d e l a n d

Blog

  • a cute dog

    Builder Design Pattern

    Created: August 2nd, 2024

    The Builder pattern is a creational design pattern that allows for the step-by-step construction of complex objects. It separates the construction of an object from its representation, which enables the same construction process to create different representations of the same object. The pattern consists of a Builder Interface, a Product class, one or more Concrete Builder classes, and optionally, one or more Director classes. The Concrete Builder classes implement the Builder Interface, which contains all the methods to create different parts of the complex Product object. The Director classes, if used, employ these methods in a step-by-step manner to construct the final representation of a complex Product object variant. This approach, where Director classes construct a complex object in a step-by-step manner, results in the construction of an object being separate from its representation. This is in contrast to a constructor method of a class using passed-in parameters to initialize an object's initial state; in such a scenario, there is no separation between the class that constructs the object and the object itself.

  • a cute dog

    Abstract Factory Design Pattern

    Created: July 27th, 2024

    Updated: July 30th, 2024

    The Abstract Factory Design Pattern is a creational design pattern that provides an abstract interface to be implemented by classes and collectively, these class implementations become known as concrete factory class variants. The implemented methods, collectively, of each variant create a set of related or dependent objects, that are known as a family of objects, which belong to the specific concrete factory class variant they were created from. The Abstract Factory Design Pattern is also referred to as a "Factory of Factories" or a "Super-Factory" because it provides an interface that other classes implement to become factories.

  • a cute dog

    Factory Design Pattern

    Created: July 20th, 2024

    Updated: July 22nd, 2024

    The Factory Design Pattern is a creational design pattern that encapsulates logic for instantiating instances of various classes. However, the pattern does not encapsulate the logic for initializing the state and/or behavior of those instances; those implementation details are delegated to the classes of the instances themselves. Therefore, the pattern doesn't know the inner workings of the classes it instantiates instances of; it's decoupled from those classes.

  • a cute dog

    Prototype Design Pattern

    Created: July 19th, 2024

    The Prototype Design Pattern is a creational design pattern that provides the ability to create a new object by cloning an original object, known as the prototype. Since the newly created object is a copy of the prototype, it inherits the properties and methods defined on that prototype. This results in less duplicate code since, by copying, we're creating references to existing properties and methods rather than defining the same properties and methods on the new object, and that also results in memory efficiency. Altogether, it leads to better code readability and maintainability, as we have less code to review and changes to make since properties and methods inherited by all objects only need to be changed in one location, which is on the prototype.

  • a cute dog

    Singleton Design Pattern

    Created: July 5th, 2024

    Updated: July 12th, 2024

    In OOP, the Singleton Design Pattern restricts the ability of a class from being able to instantiate multiple instances to only a single instance. Normally, a class can instantiate as many instances as desired but in some scenarios it's crucial that only a single instance of a class exists. Since the constructor method of a class is responsible for instantiating new instances, the logic for the Singleton pattern is implemented there. The logic checks if an instance already exists, if so, it returns the reference to that instance, otherwise the constructor creates a new instance. The Singleton pattern provides a global point of access to the single instance, regardless of where within your codebase you try to instantiate a new instance, you always get the same instance back.

  • a cute dog

    Module Design Pattern

    Created: July 3th, 2024

    Updated: July 7th, 2024

    The Module Design Pattern encapsulates related state and logic within a module. If the module has any exports, named or default, then those exports form the public interface of the module, and the remaining non-exported code forms the private interface, which is only accessible within the module. External code can interact with the module's encapsulated code through the controlled exported public interface.

  • a cute dog

    Constructor Design Pattern

    Created: June 30th, 2024

    Updated: July 22nd, 2024

    The Constructor Design Pattern is a creational design pattern and it is automatically invoked every time we instantiate a new instance of a class using the new operator. This method is responsible for initializing the state of the newly created instance by assigning its initial properties and methods. If the class is a subclass, meaning it inherits from a superclass, the constructor invokes the superclass's constructor to ensure newly created instances are assigned the properties and methods of the superclass.

  • a cute dog

    Design Patterns

    Created: June 25th, 2021

    This is an introduction to a series of posts on design patterns in software development - patterns in the creational, structural and behavioral categories. It's a way for me to help myself learn better by documenting it and to have a future reference in my own words. Each post will include explanations, analogies, and code examples using Javascript and Python.

© 2024 NazCodeland