-
-
Notifications
You must be signed in to change notification settings - Fork 0
Codespace cautious engine 4g567p67wpp35rxp #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a Factory Method design pattern implementation with documentation, example code, and removes an unused extension from the devcontainer configuration.
- Adds comprehensive documentation explaining the Factory Method pattern's concepts, use cases, benefits, and drawbacks
- Implements the Factory Method pattern in C++ with Transport/Logistics example demonstrating the pattern
- Removes the unused
llvm-vs-code-extensions.vscode-clangdextension from devcontainer configuration
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| design_patterns/creational/factory_method/index.md | Documentation for the Factory Method pattern including key concepts, use cases, benefits, and drawbacks |
| design_patterns/creational/factory_method/factory_method.hpp | Header file implementing the Factory Method pattern with Transport and Logistics classes |
| design_patterns/creational/factory_method/factory_method.cpp | Implementation file with main function demonstrating the pattern usage |
| .devcontainer/devcontainer.json | Removes unused clangd extension from the devcontainer |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public: | ||
| Transport *createTransport() const override { |
Copilot
AI
Nov 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning a raw pointer from a local std::shared_ptr causes a dangling pointer. When truckPtr goes out of scope, the managed object is destroyed, leaving the returned pointer invalid. Return new Truck() directly or change the return type to std::unique_ptr<Transport>.
| if (logistics == nullptr) { | ||
| throw std::invalid_argument("Logistics pointer cannot be null"); |
Copilot
AI
Nov 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning a raw pointer from a local std::shared_ptr causes a dangling pointer. When shipPtr goes out of scope, the managed object is destroyed, leaving the returned pointer invalid. Return new Ship() directly or change the return type to std::unique_ptr<Transport>.
| * Class Methods Definitions | ||
| **************************************************************************************/ | ||
|
|
||
| int main(int argc, char const *argv[]) { |
Copilot
AI
Nov 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The argc and argv parameters are declared but never used. Since this is a simple demonstration with no command-line argument processing, use int main() instead to match the style in the singleton example.
| int main(int argc, char const *argv[]) { | |
| int main() { |
|



This pull request introduces a complete implementation and documentation of the Factory Method design pattern in C++. It adds well-structured header and source files, including clear class definitions, usage example, and comprehensive documentation. Additionally, it provides a concise Markdown overview explaining the pattern, its use cases, benefits, and drawbacks. There is also a minor update to the devcontainer configuration.
Factory Method Pattern Implementation:
factory_method.hppcontaining:Transport) and concrete products (Truck,Ship)Logistics) and concrete creators (RoadLogistics,SeaLogistics)LogisticServiceclass to demonstrate usagefactory_method.cppwith:Documentation:
index.mdwith an overview of the Factory Method pattern, including key concepts, when to use it, benefits, drawbacks, and a conclusionDevelopment Environment:
llvm-vs-code-extensions.vscode-clangdextension from.devcontainer/devcontainer.jsonto update the recommended VS Code extensions