Art and Cycle

30 Nov 2021

What is Pattern?

When I think of a pattern, two meaning comes up in my head. One of them is art. For instance, there are some fancy patterns on the clothes, and there are some delicate patterns on the architecture. Another meaning of the pattern for me, is the cycle. Every day, I wake up and pick up my dog’s poop, and I consider this is a pattern that how I start my day.

Now, come back to the programming, I have not heard of design patterns until this week. More surprisingly, I have used it in my previous courses and kept on using it in ICS314. I was not familiar with the term, but when I saw the example codes - it was not a new theme. The meaning of the design pattern is the ‘solutions that can be used when problems often arise in a particular context when designing software’. To be more precise, we can reuse the solution to commonly occurring problems when we develop a software. I believe design patterns are related to the meaning that I stated above. Art and cycle. We can artistically design the pattern to deal with the common problems, and it forms a cycle that can solve the problems.

What did I use? When did I use?

When I took the ICS212, we had to implement the code to find the area, surface area, and volume of the different shapes. That was my first encounter with design patterns. We used a factory design pattern (although I did not know it was a design pattern) and performed the calculations for each shape. It was very useful method because I was able to return objects from different classes (shapes) and return multiple objects (area, surface area, and volume) without recalculating it.

Moreover, I am still using design patterns on my final project. One example will be the singleton design pattern. We create a new profile of users (students and companies) and export it as a singleton instance of the profile collection. Therefore, we can invoke methods and manipulate the collection.

Overall, there are 23 design patterns, and I am still trying to understand how to use factory and singleton design patterns more precisely. I have 21 more design patterns to learn to form an artistic cycle on my code.