Joseph Evans
Joseph Evans

Software Engineer

Blogger

Web Developer

Mentor

Joseph Evans

Software Engineer

Blogger

Web Developer

Mentor

Blog Post

Software Design II

February 6, 2020 architecture, design
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? 😍

Taggs:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments