|

Software Design II

Talking more about software design, in my personal experience, this is a subject that gets overlooked rather dramatically, but it’s crazy! 🤯

When it comes to implementing clean software, design is key, there are many ways in which you can design software, we have many patterns that exist in the world of software engineering. Some are used for very niche cases, others are used to ensure that the flow of our software is easy & simple.

In this article, I’ll be giving more of a hands on example, in this specific example I’ll be talking about how & when patterns such as a chain of responsibility rocks. So without further ado, I’ll get right to it, rather than baffle on & on, I’ll spare you the boredom, here’s the basic idea of how my example works:

In this example, you can see that it’s using some type called Link, to provide more context about what a so called ‘link’ is, here’s what I’ve implemented:

Quite simple, it’s essentially a more bespoke or precise implementation of an Iterator. But what I love about this precise pattern is that at run time, you can dictate what the next link in the chain will be, in scenarios like where you want to allow many different POJO’s to be used. In my current role, working for a company that primarily sells car insurance, you can imagine that the requests from external services will vary to some extent or another.

Due to the fact that these requests vary, it makes sense, to have some implementation like this, you may want to have specific business logic in place for specific requests, where the chains vary, you may want to make certain database interactions in very specific cases.

Rather than including some complex logic, a tonne of if statements, you can just implement specific Link classes, where in the process method, it can do very niche business logic. I mean you could extend this further, you could have say some more logic in place, such as allowing to set the next link, etc. The sky really is the limit, but talking about very complex business processes, you could include all kinds of design patterns, an example being how you could include factories, maybe even abstract factories that allow you to have many different processes in place, an example being how you could have a factory that dictates what adapter is being used. You could then have a factory in place also that dictates which chain of responsibility is to be used, etc.

But one thing that makes me love clean & well designed software is that it makes life so simple when it comes to implementing tests. Not just unit tests, but integration tests, system tests, etc, since you can drill down to incredibly precise states, you can include logging which would also make life much easier when it comes to debugging.

Conclusion

As stated, this would be a short one, I’ve tried to refrain from blabbering on & on, but if you spend some time, writing well designed, clean & simple software, not only will you set yourself up for success. But your colleagues will thank you, your predecessors will thank you, the list goes on, the easier you make other peoples lives, the better. As I’ve also stated, if you make it super precise, super clean & if you implement plenty of logging, then you’ll have a breeze debugging your code also, what’s not to love? 😍

Similar Posts

  • |

    Empowering The Backend

    Introduction I’ve been involved in all kinds of web-based projects throughout my career so far. I hope that pattern continues & I even hope that someday, I can even go out of my comfort zone & deal with technologies beyond the web. Be that embedded systems programming for IoT devices or just building some silly…

  • JPA: Entity without an ID

    A problem that I’ve recently encountered myself not so long ago, I wanted to know how to query a table that essentially had no ID/primary key column. I had to do this since the table(s)/view(s) that I needed to query could be considered legacy, they perform rather poorly & generally, from a DB perspective need…

  • Functional Java?

    Okay, so one of the things that I’ve been trying to master is the Java ecosystem as my current role consists of me utilising a lot of tools & technologies from the Java EE ecosystem, ranging from standard technologies such as Hibernate & Spring to bespoke technologies & design patterns. From working with Java, specifically…

  • JVM – Garbage Collection

    Introduction WARNING! – A lot of this content is just regurgitated content from the java magazine article that’s referenced below, if you’d like more detail, please refer to the article, this is a shortened overview at most. I’ve written this article to help educate myself & hopefully others! 🙂 Having read an article from Java…

  • |

    Why I Like Spring II

    Okay, so in my previous article, I stated some of the things that I like about Spring, although, it doesn’t stop there, Spring is just beautiful for MSA and/or distributed applications. Not to mention how popular Spring is, Spring may just be the most popular Java framework at this moment in time, having used more…

Leave a Reply

Your email address will not be published. Required fields are marked *