nic-dgl104-winter-2024 / pattern-library

A multi-language library containing implementations of common software design and architecture patterns
4 stars 37 forks source link

Factory Design Pattern and Facade Design Pattern #77

Closed nazrinzuwair closed 7 months ago

nazrinzuwair commented 7 months ago

Hi @ash-teach

I've created PR #77, which includes updates for both the Factory Design Pattern and the Facade Design Pattern:

  1. Created folders named "Factory-Design-Pattern" and "Facade-Pattern" inside the PATTERN-LIBRARY directory. Each folder contains a README.md file and JavaScript files (factory-method.js and facade-pattern.js).
  2. Added a README.md file in the "Factory-Design-Pattern" folder with a summary of implementing the Factory Design Pattern in JavaScript using the factory design method. Included a code snippet example related to "Creating Foods" and listed additional programming languages where the Factory Design Pattern can be implemented.
  3. Included a README.md file in the "Facade-Pattern" folder with explanations and code examples for implementing the Facade Design Pattern in JavaScript.
  4. Added a reference section in the README.md files of both folders with links to websites browsed during research.
  5. Linked the "Factory-Design-Pattern" and "Facade-Pattern" folders into the README.md main file for easy navigation.
nazrinzuwair commented 7 months ago

@ash-teach Could you please review this.

kattsky commented 7 months ago

Hi @nazrinzuwair I've reviewed your code, and overall, it's very well-structured and maintains good object-oriented principles. I also like to commend your detailed documentation of your implementation that made it easy to grasp the goal and functionality of the facade pattern.

Building upon the foundation of a well-documented code, one aspect to consider exploring to enhance flexibility is create instances of the subsystem classes outside of the SoftwareFacade class,.

As an alternative to creating instances of SoftwareDeveloper, Designer, and DatabaseEngineer within the SoftwareFacade constructor, these can be passed as parameters. The benefit of creating instances of the subsystem classes externally rather than internal implementation helps SoftwareFacade object (being the mediator between the client code and the subsystem classes) to access them in the software development process which aligns with facade pattern's goal to provide simplified interface to a complex system.

:raised_hands: Fantastic work, @nazrinzuwair

nazrinzuwair commented 7 months ago

Thanks for your feedback @kattsky :)

ash-teach commented 7 months ago

Great work, @nazrinzuwair! Very well documented and structured. I have very few comments, other than primarily some styling related notes. Though I do want to highlight @kattsky's comment as valid (quoted below), and worth considering.

As an alternative to creating instances of SoftwareDeveloper, Designer, and DatabaseEngineer within the SoftwareFacade constructor, these can be passed as parameters. The benefit of creating instances of the subsystem classes externally rather than internal implementation helps SoftwareFacade object (being the mediator between the client code and the subsystem classes) to access them in the software development process which aligns with facade pattern's goal to provide simplified interface to a complex system.

As a further note, I would normally suggest that you do not need to reproduce all code as part of your documentation (the user can easily visit the actual code afterall). However, in this case, you've done such a great job of discussing the code, I would prefer to leave it as-is. Fantastic work!

nazrinzuwair commented 7 months ago

Hi @kattsky and @ash-teach Thanks for your valuable feedback. I have made the changes and it is ready for your review. Thank You!

kattsky commented 7 months ago

Thanks for catching those details, @nazrinzuwair. Got nothing else to add from my end.