nCircle Tech | Blogs | Factory Design patterns for CAD developments
Spread the word

There’s never a boring day in a software developer’s life. We always have a challenge waiting for us, and more often than not, these problems are somewhat similar. This happens especially with object oriented programming, and the solutions for these problems need to be derived from object oriented programming itself. You may often hear the term ‘Design patterns’ being used as programmers try to derive innovative, long term solutions. Singleton and Factory design patterns are mostly used instead of regular class constructors and prove to be very e very useful in the long run. Let’s take a look at how factory design patterns can be used while developing CAD plugins for different CAD platforms.

What is a Factory Design Pattern?

The factory method design pattern is one of the Gang of Four design patterns that aim to solve recurring design problems to design flexible and reusable object oriented software. This method replicates the SOLID method of programming and decouples the construction of objects from themselves. It manipulates the creation process and returns the object to the caller, hiding the object from caller and making it abstract. Abstraction is a very important concept of the OOPs process as it gives us the freedom to manipulate the final implementation according to our convenience. 

Let’s look at this like a company that manufactures a large number of products, and each product can be made of any number of components. Its unique. Workers know what the inventory has, but don’t know what the end products will look like. Just like that, code is also unique, and developers can use the factory method pattern to create different objects without recurring processes. 

Why use factory design patterns?

This method is used when a class cannot anticipate the type of objects it needs to create beforehand, when a class needs its subclasses to specify the objects to be created and when developers want to localize the logic to instantiate a complex object.
Now, let’s go one step ahead and see how Factory Design patterns can help while implementing plugins for different CAD platforms like AutoCAD, Inventor, Revit.  While developing a CAD plugin, let’s consider the most common entities or objects provided by CAD platform SDKs like Point, Line, Plane, Vector, Matrix. These objects will need to be brought in from different platforms. The factory method can be used to get these objects based on the type of the platform that will be passed to the method. This method differs a little from the traditional. Instead of getting the objects directly, we get them through the classes that hold methods to procure these objects (Point, Line etc). This will be the base class that represents a general CAD platform. 

Person Encoding in Laptop

Advantages of using factory design

  • As the Factory design pattern provides abstraction, it gives users more freedom to manipulate the object creation process. In our case, we can integrate new CAD platform SDKs and get CAD entity objects in return
  • It is more more useful than having multiple classes and calling them individually. A factory decides on certain criteria to create/return objects. In the absence of a factory design, developers would need to use the same code repeatedly in different locations
  • As the Object creation process is loosely coupled with user (plugin DLL), users need not make changes if the platform SDK classes are modified as a part of a new update. It is also possible to maintain multiple versions of platform SDK that will be coupled with plugin DLL. This is so much more convenient if the plugin needs to be run with a range of CAD platform versions (Ex. AutoCAD 2015,2016, 2017…)
  • With CAD, it can create digital factory models and layouts that help developers communicate their vision effectively for industries like manufacturing and AEC

Business impact

1. Using the factory design pattern gives developers a better analysis of models and layouts as compared to traditional design patterns, thus saving the resource’s time and energy. They can focus on creating better models innovatively and spend more time developing new ideas

2. It is highly efficient since users don’t have to focus on recurring code and the problems that come along with it. This means higher developer productivity, both in terms of individuals and teams, and better written code that can be tested easily

3. The process of creating factory designs is a dynamic one and in the end, it leads to a higher level of customer satisfaction since it is faster and shows results in real time. A great customer experience speaks for itself! 

Author: Gaurav Deshmukh

Want to know more? Get in touch with us and we’d love to take you through it all!

Contact us

nCircle Tech (inCorporated in 2012) empowers passionate innovators to create impactful 3D visualization software for desktop, mobile and cloud. Our domain expertise in CAD customization driving automation with the ability to integrate advanced technologies like AI/ML and VR/AR; empowers our clients to reduce time to market and meet business goals. nCircle has a proven track record of technology consulting and advisory services for the AEC and Manufacturing industry across the globe. Our team of dedicated engineers, partner ecosystem and industry veterans are on a mission to redefine how you design and visualize.

Over the last 7+ years, the organisation has worked on more than 150 large and complex projects for 50+ customers across 15 countries.

Spread the word