Giter Site home page Giter Site logo

bolsdrinker / plc-design-patterns Goto Github PK

View Code? Open in Web Editor NEW

This project forked from runtimevic/plc-design-patterns

0.0 0.0 0.0 38.09 MB

A large repo containing various OOP design patterns for PLC development

License: BSD 2-Clause "Simplified" License

plc-design-patterns's Introduction

Software Design Patterns for TwinCAT PLC

Welcome to my series on software design patterns for PLC programming. This series will focus on the main design patterns that are used throughout the software industry but will show where they fit and how one would implement them in PLC type systems.

To start the series, I will be going through the design patterns noted by the reputable GoF (Gang of Four) authors. In 1994, the book Design Patterns: Elements of Reusable Object-Oriented Software was published and set up most of the industry standards for OOP design theory and practice. The book's authors are Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides with a foreword by Grady Booch. While the book shows examples in more mainstream languages, they can adapt to almost any OOP based architecture; thus the can also be implemented in IEC 61131-3 3rd edition PLC environment.

Starting off the series, I'd like to cover the question of What? and Why?

What is a design pattern?

A design pattern is a solution to commonly occurring problems in software design. Consider them as a blueprint that you can tweak to fit a reoccurring problem in your code.

Patterns are often confused with algorithms, mostly because both of them describe a solution to known problems. Algorithms can be followed many times without tweaking, as it's a clear set of actions to achieve some goal. A pattern, on the other hand, is much more of a high-level description of a system; the same base of code for pattern implementation in a problem today might be different for a problem tomorrow.

An analogy to an algorithm is a recipe; you have clear steps the achieve a goal. While a pattern is more like a blueprint; you can see the results, and it's features, but the implementation is up to you.

A pattern consists of the following:

  • Intent - briefly describes both the problem and solution
  • Motivation - further explains the problem and solution that the pattern makes possible
  • Structure - usually a UML diagram or some description that shows each part of the design, and how they relate to one another.
  • Example - a code example to illustrate the pattern implementation in various languages, for this series it will be IEC61131-3 Structured Text.

Why should I use or learn patterns?

With the introduction of OOP in the IEC61131-3 3rd edition standard, this opened the doors to many of the features the software engineering industry already uses. Both PLC and non-PLC programmers might go for many years without studying a single pattern. Some might even implement a design pattern without even knowing. So why would you spend time studying patterns?

Consider design patterns a toolkit, a tested and proved solution for many of the problems that arise in software design. If you ever encounter a problem, it's very advantageous to know that there is a solution already available and is easily solvable with object-oriented design principals. Design patterns also provide a common blueprint or language and allow teammates to communicate more efficiently.

Design Pattern Types

Follow the link to your desired design pattern type, inside there will be examples of the various design patterns.

  • Creational Design Patterns These patterns provide various object creation mechanisms, which increase flexibility and reuse of existing code.

  • Structural Design Patterns These patterns explain how to assemble objects and classes into larger structures while keeping this structures flexible and efficient.

  • Behavioral Design Patterns These patterns are concerned with algorithms and the assignment of responsibilities between objects.

plc-design-patterns's People

Contributors

0w8states avatar runtimevic avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.