Tags » Design Patterns

When we break the coding guides

A colleague asked me to help him learn java and object-oriented programming. He has solid background in VisualBasic and SQL. This is cool because I don’t need to explain things like the while loop or recursion. 555 more words

Programming

Design Patterns SAGA #4: Real Project Situations With Prototype

The Problem: We could solve the Prototype problem in an easy way, but we would have to write several setters and create a converter that passes all the information from… 825 more words

Design Patterns

Design Principle - Favor Composition Over Inheritance

Reviewed a project with legacy code base of more than a quarter million lines of code. This legacy project was under re-writing proposal phase.

Designed a proposal with high-level UML activity, component, and class diagrams. 146 more words

Design Patterns

Abstract Factory Design Pattern C#

Abstract Factory offers the interface for creating a family of related objects, without explicitly specifying their classes.

Florist:

    /// <summary>
    /// Product A
    /// </summary>
    public interface IFlorist { void DecorateFlowers(); }
    
    /// <summary>
    /// Product A1
    /// </summary>
    public class HighBudgetFlorist : IFlorist
    {
        public void DecorateFlowers()
        {
            Console.WriteLine("Florist: Thanks for choosing us to serve...");
        }
    }

    /// <summary>
    /// Product A1
    /// </summary>
    public class LowBudgetFlorist : IFlorist
    {
        public void DecorateFlowers()
        {
            Console.WriteLine("Florist: Thanks for giving us the chance to serve...");
        }
    }
… 190 more words

JavaScript IIFE (Immediately Invokable Function Expressions in JavaScript) Design Pattern

Mayank Gupta. CodeProject. 2017-06-15.
This post gives a small introduction about Singleton Pattern in JavaScript.
The post offer you more topics on Object Oriented JavaScript Design. 120 more words

Sin Categoría

Factory Method Design Pattern C#

Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.

namespace TestFactoryMethod
{
    class Program
    {
        static void Main(string[] args)
        {
            CarFactory carFactory = new SwiftCarFactory();
            ICar car = carFactory.GetCar();
            Console.ReadKey();
        }
    }

    /// <summary>
    /// Product
    /// </summary>
    public interface ICar
    {
        void BuildCar();
    }

    /// <summary>
    /// Concrete Product1
    /// </summary>
    public class SwiftCar : ICar
    {
        public SwiftCar()
        {
            Console.WriteLine("Swift car: Initialized...");
        }

        public void BuildCar()
        {
            Console.WriteLine("Swift car: Building...");
        }

        public void RunSwiftCarQualityCheck()
        {
            Console.WriteLine("Swift car: Quality Check is Successful...");
        }
    }

    /// <summary>
    /// Concrete Product2
    /// </summary>
    public class AltoCar : ICar
    {
        public AltoCar()
        {
            Console.WriteLine("Alto car: Initializing...");
        }

        public void BuildCar()
        {
            Console.WriteLine("Alto car: Building...");
        }

        public void RunAltoCarQualityCheck()
        {
            Console.WriteLine("Alto car: Quality Check is Successful...");
        }
    }

    /// <summary>
    /// Creator
    /// </summary>
    public abstract class CarFactory
    {
        public ICar GetCar()
        {
            ICar car = this.CreateCar();
            return car;
        }

        public abstract ICar CreateCar();
    }

    /// <summary>
    /// Concrete Creator1
    /// </summary>
    public class SwiftCarFactory : CarFactory
    {
        public override ICar CreateCar()
        {
            SwiftCar car = new SwiftCar();
            car.BuildCar();
            car.RunSwiftCarQualityCheck();
            return car;
        }
    }

    /// <summary>
    /// Concrete Creator2
    /// </summary>
    public class AltoCarFactory : CarFactory
    {
        public override ICar CreateCar()
        {
            AltoCar car = new AltoCar();
            car.BuildCar();
            car.RunAltoCarQualityCheck();
            return car;
        }
    }
}

Output:

Monad code generation and extension

… in Mathematica / Wolfram Language

Anton Antonov
MathematicaForPrediction at GitHub
MathematicaVsR at GitHub
June 2017

Introduction

This document aims to introduce monadic programming in Mathematica / Wolfram Language (WL) in a concise and code-direct manner. 4,257 more words

Mathematica