implement the creational builder pattern #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Currently,
run.py
is quite large, making it difficult for developers to understand it at first look. Building an object within this file only adds to the complexity, which goes against coding best practices.Solution
A solution to this is to apply the creational design pattern of builder. The builder pattern is the most efficient solution to this problem as it allows the creation of an object that has several working parts, of which each part needs to come together to create one single object.
How?
I have created the file
multisim_run_builder.py
which creates a run object through using the builder pattern. In this file, I have theIBuilder
class, which contains the necessary methods for the run object. TheProduct
class then creates the object. TheBuilder
class then builds the object. And finally, theDirector
class which runs each method.