← Back to list

You should DRY with PLC Programming

DRY, or Don’t Repeat Yourself, is a popular methodology in traditional computer programming. Like the name implies, this is a methodology…

Adesuwa Dawodu in Coffee☕ And Code💚 · 2026-06-29 09:13 · 67 claps · 1.6 min read
#dont-repeat-yourself #plc-programming #plc #object-oriented
Open on Medium ↗
Wiki topics: 💻 · Programming

You should DRY with PLC Programming

DRY, or Don’t Repeat Yourself, is a popular methodology in traditional computer programming. Like the name implies, this is a methodology that prods the programmer to pack code into reusable units, like functions or methods. The biggest benefit is maintenability: a piece of code that is DRY-ed needs to be updated in only one place.

In PLC programming, DRY can also be applied and used to improve your system. Pretty much all the PLC programming platforms will help you DRY, you just need to use the features available. Codesys and Siemens PLC platforms both support Object-Oriented programming. Allen Bradley’s Rockwell platform, however, does not support OOP.

  • Functions and Function Blocks (FB): These are program units that can be called in other program units. They are a very straightforward way to create repeatable code that can be used cleanly in multiple places. These are a universal plc programming feature, so they are available in all PLC pogramming platforms.
  • Inheritance: A quick indicator that this is being used is the word “extends” at the top of a program. Codesys and the Siemens PLC platforms both fully support this. In fact, if you are following a standard like the ISA-88 one, you can implement base level equipment and control modules and then extend those for specific equipment and control function blocks. For example, in my conveyor sort project, I created a Conveyor function block (FB) and then extended that to create function blocks for lanes in the system.
  • Interface: This is a great way to standardize the methods and properties that a program will have. Again, both Codesys and Siemens (TIA Portal, Step 7) support this.

Other ways to DRY are Add-On Instructions in Rockwell Studio, custom data structures typically called User Defined Dataypes (UDT) or Data Unit Type (DUT) in Codesys, and libraries. Depending on the PLC programming software you are using, there will be features that you can use to ensure your code is repeatable.

The benefits to doing this are many. DRY can be problematic if not handled correctly, however, that is no reason to not do it.


메타데이터
post_id
e7f85c685d90
slug
you-should-dry-with-plc-programming-e7f85c685d90
url
https://medium.com/techtrends-digest/you-should-dry-with-plc-programming-e7f85c685d90
canonical_url
https://medium.com/techtrends-digest/you-should-dry-with-plc-programming-e7f85c685d90
author_url
https://medium.com/@adesuwa-dawodu
status
ok
fetched_at
2026-08-09 17:14:00