---
title: "Discussion on \"Factory Design Pattern\" | Hashnode"
description: "Discussion on \"Factory Design Pattern\". In software engineering, Creational Design Patterns deal with object creation mechanisms, i.e. try to create objects in a manner suitable to the situation. In addition to this basic or ordinary form of object creation could result in design problems ..."
url: "https://hashnode.com/posts/factory-design-pattern/5ef9e6eca78de8267c2b26cb"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Factory Design Pattern](https://hashnode.com/post/factory-design-pattern?utm_source=hashnode&utm_medium=feed)

In software engineering, Creational Design Patterns deal with object creation mechanisms, i.e. try to create objects in a manner suitable to the situation. In addition to this basic or ordinary form of object creation could result in design problems ...

Jun 29, 2020 · 12 min read · hashnode.com  
Read the article

-   [#design-patterns](https://hashnode.com/tag/design-patterns)
-   [#coding](https://hashnode.com/tag/coding)
-   [#cpp-ck4ra5k7300nlv2s1jbkdp2qh](https://hashnode.com/tag/cpp-ck4ra5k7300nlv2s1jbkdp2qh)
-   [#programming-ciovqvfcb008mb253jrczo9ye](https://hashnode.com/tag/programming-ciovqvfcb008mb253jrczo9ye)

## Written by

[Vishal Chovatiya](https://hashnode.com/@Vishesh_Patel)

@Vishesh\_Patel · Bengaluru, India

  
[View profile](https://hashnode.com/@Vishesh_Patel)

Software Developer⌨, Fitness Freak🏋, Geek🤓, Hipster🕴, Blogger👨‍💻, Productivity Hacker⌚, Always a Student👨‍🎓 & Learning Junkie📚.

Experienced Enthusiast: C++, System Software, Firmware &amp; SoC Modeling

## Responses 1

Markdown supported · ⌘↵ to post

[Paweł Kubik](https://hashnode.com/@pkubik)

[Jul 21, 2020](https://hashnode.com/posts/factory-design-pattern/5ef9e6eca78de8267c2b26cb/comment/5f176ec54f0ccd6b8b03beb1)

The last point seems like a premature optimization. I doubt that dynamically-allocated `std::map` is any faster than whatever partially-compile-time mechanism is being used by C++ compiler behind the scenes to handle virtual polymorphism.

Besides, I think you've missed an important point of a factory, which is to encode some object configuration within the factory class. You can have a bullet factory for a game, which is configured to create either red or grey bullets. Then you insert the red bullet factory to a `LaserGun` and the other one to a `BallisticGun`. You kind of did this with the `Point2D`/`Point3D` example but I don't think you've made it explicit enough.

Other than that, great introductory article. Keep going!
