Seeing the Patterns

04 Dec 2024

Design Patterns - What’s the Issue?

As an aspiring software developer, over the course of 314, I’ve discovered the hard way that there’s an infinite amount of issues you can run into while making and maintaining an app. But thankfully, for every problem, there’s a solution. This is where Design Patterns come in. Design Patterns don’t only help to simplify and expand code, but will also save you time and reduce bugs and errors to aid you in the long run.

Exploring Design Patterns

There are 3 main types of Design Patterns: Creational, Structural, and Behavioral. Creational Design Patterns focus on object creation, which increases flexibility and reuse of existing code. An example of this would be the Singleton, which ensures only one instance of a class is created and should be available through the code. Structural Patterns on the other hand deal with organization and composition of classes and objects to form larger structures. This includes the Observer, which defines a dependency between objects so that when one changes, all the dependents are notified and updated automatically. Behavioral Patterns manage algorithms, and support the communication between objects and classes.

My Steps for Implementing Design Patterns

To be completely honest, I haven’t utilized Design Patterns to their fullest potential, much less more than once or twice. It’s still a relatively new concept to me and we haven’t talked about them in class, so I don’t find myself thinking about it when writing code. But after reading over Design Patterns and what they are, I’ve drawn out steps for implementing them in the future.

  1. Identify the Problem and/or Goal: Just like any organized software developer, before starting, I need to know what the goal of the code is and have a general plan for what pages or functions I need to implement. Having this concrete idea is important before I can move on to the next step.
  2. Match the Pattern - This next step is essential, as it obviously decides what Design Pattern I want to use and will be most useful to me. After having that concrete plan, I should look over all the available Patterns and take into account their functions, benefits, and will keep my code structured the way I want. It’s important to remember the flexibility of the Pattern as that could affect the project as more and more code is added over time.
  3. Implement the Pattern - The last and obvious step is to implement the pattern. While implementing, I should be conscious if this Pattern is really useful to me, and is helping me. If not, I should probably reevaluate and choose another pattern that will fit my goals more.

Conclusion

While I haven’t used Design Patterns yet, I can see myself benefitting from them in the future. I tend to be a bit all over the place and quickly get overwhelmed by my code, and kind of regret not using them sooner. Hopefully implementing them will make my life a lot easier in the future. It may seem kind of annoying to think about what patterns I should use when I just want to jump right into the project, but the journey will definitely become a lot smoother once I get used to following the steps.