Command Design Pattern
Videos
| Section | Video Links |
|---|---|
| Command Overview | ![]() |
| Command Use Case | ![]() |
| Single Leading Underscore | ![]() |
Book
Overview
... Refer to Book, pause Video Lectures or subscribe to Medium Membership to read textual content.
Terminology
... Refer to Book, pause Video Lectures or subscribe to Medium Membership to read textual content.
Command Pattern UML Diagram
Source Code
... Refer to Book, pause Video Lectures or subscribe to Medium Membership to read textual content.
Output
python ./command/command_concept.py Executing Command 1 Executing Command 2 Executing Command 1 Executing Command 2
Example Use Case
... Refer to Book, pause Video Lectures or subscribe to Medium Membership to read textual content.
Example UML Diagram
Output
python ./command/client.py Light turned ON Light turned OFF Light turned ON Light turned OFF 11:23:35 : ON 11:23:35 : OFF 11:23:35 : ON 11:23:35 : OFF Light turned ON Light turned OFF
New Coding Concepts
_Single Leading Underscore
The single leading underscore _variable, on your class variables is a useful indicator to other developers that this property should be considered private.
Private, in C style languages, means that the variable/field/property is hidden and cannot be accessed outside of the class. It can only be used internally by its own class methods.
Python does not have a public/private accessor concept so the variable is not actually private and can still be used outside of the class in other modules.
It is just a useful construct that you will see developers use as a recommendation not to reference this variable directly outside of this class, but use a dedicated method or property instead.
Summary
... Refer to Book, pause Video Lectures or subscribe to Medium Membership to read textual content.



