Bridge Design Pattern
Videos
| Section | Video Links |
|---|---|
| Bridge Overview | |
| Bridge Use Case | |
| Python Tuple | |
| Python *args | |
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.
Bridge UML Diagram
Source Code
... Refer to Book, pause Video Lectures or subscribe to Medium Membership to read textual content.
Output
python ./bridge/bridge_concept.py ('a', 'b', 'c') a b c
Example Use Case
... Refer to Book, pause Video Lectures or subscribe to Medium Membership to read textual content.
Example UML Diagram
Output
python ./bridge/client.py
******
** **
* *
* *
* *
* *
** **
******
**************
* *
* *
* *
* *
* *
* *
**************New Coding Concepts
The *args Argument.
The *args argument takes all arguments that were sent to this method, and packs them into a Tuple.
It is useful when you don't know how many arguments, or what types, will be sent to a method, and you want the method to support any number of arguments or types being sent to it.
If you want your method to be strict about the types that it can accept, the set it specifically to accept List, Dictionary, Set or Tuple, and treat the argument as such within the method body, but the *args argument is another common option that you will see in source code throughout the internet.
E.g., when using the *args in your method signature, you can call it with any number of arguments of any type.
def my_method(*args): for arg in args: print(arg) my_method(1, 22, [3], {4})
Outputs
Python Tuple
A Python Tuple is similar to a List. Except that the items in the Tuple are ordered, unchangeable and allow duplicates.
A Tuple can be instantiated using the round brackets () or tuple() , verses [] for a List and {} for a Set or Dictionary.
PS> python >>> items = ("alpha", "bravo", "charlie", "alpha") >>> print(items) ('alpha', 'bravo', 'charlie', 'alpha') >>> print(len(items)) 4
Summary
... Refer to Book, pause Video Lectures or subscribe to Medium Membership to read textual content.



