Design It! From Business Requirements to System Design
Creating a clean software architecture should consider the solution complexity. Sometimes, the system, which at first glance seems to be simple, in fact, is not. On the other hand, those which seem too complex to visualize could be easy to understand. The best approach to fully understand this process is to prepare a system design. What does it mean to create a proper design? Contrary to appearances, it is not only diagrams but also a collection of business and technical information that allows a developer to see the full picture of the software being created. This kind of data helps to understand how business processes are implemented and what are the components of the system. Designing a solution provides benefits not only at the beginning of the project while working on its implementation. It could also be valuable when we already have a working product and want to comprehend it to a greater extent.
In addition to the presented theory, elements that a clean system design should contain, I would like to show the practical process of creating a design for an online library.
Description of business processes
Systems are designed to earn money, and they realize it by providing value using implemented business processes. The developers should not overlook the non-technical aspects they should also focus on. Full awareness of business processes is the critical determinant of a company's success in the market. One of the available methods to discover these processes is Event Storming, the workshops gathering domain experts and developers to cover both the business and technical aspects. The primary purpose of the event storming is business process mapping using simple sticky cards. (find more information about Event Storming here) In the case of large and complex processes, it is highly recommended to divide them into smaller sub-processes. This way, they become easier to understand and design.
Discovering business processes for a library system
Let’s assume that there is a system for e-book rental online. The system allows customers to borrow books in electronic form for a specified period of time. There is one requirement to borrow a book - an active account in the system. The user can view the available books, browse book suggestions and finally, add products to the cart. Each item added to the cart is included in later recommendations for this particular reader. Accepting the cart starts the payment process. After paying for the basket, the books are added to the user's virtual shelf for a selected period, and an invoice is sent to the user's mailbox.
Discovered business processes for the library system
Discovered domain contexts for the library system
The architecture of the system can be described on many levels. It is worth using at least two of them The architecture level, where we look at the system from a larger perspective, and the application level, where we focus on the details of one element of the system. The essence of the highest level is to collect the following data: the relationship between services, external systems in use and services included in the described system. At this stage, there is no implementation and analysis of individual services. It allows for a big picture of the system and is present in one diagram only.
At this point, it is worth mentioning about C4 model, which is a great design concept for describing architecture. This visualization technique will be further developed in the next article. Closing this thread, sequence diagrams cannot be forgotten because they describe how business processes are implemented in the architecture design.
Architecture context diagram for the library system
Process Diagrams for the library system
Acceptance test scenarios
Analysis of the business processes in the organization enables it to choose the most important of them, which are the most profitable. For such areas, the product team should prepare so-called acceptance test scenarios. It is essential to determine how to conduct the test and what results are expected. This data confirms that critical parts of the system are working correctly. Prepared scenarios can be an excellent base for building automatic tests or used in manual testing.
- Creating User Account
Given: Prepared new user details
When: The user creates an account
Then: Account Created
- Adding a book to the cart
Given: Presented book catalog
When: The user adds a book to the cart
Then: The cart updated
- Borrowing books
Given: Non-empty cart
When: User borrows a book
Then: Book added to user shelf
Having described the top level, let's move to the lower ones. By delving into the system, information about implementing individual services can be gathered. These operations can be easily visualized by a sequence diagram, which provides a simple description of the application flow. Apart from the sequence diagram, the component diagram should be prepared. It shows various elements in the application and the relations between them. To conclude, the collection of mapped processes and preparation of the component diagram allow to fully understand the operation, regardless of the degree of professional experience.
Cart Application diagram for the library system
Cart process diagrams for the library system
As already known, acceptance testing can ensure the system works properly. Nowadays, great importance is also attached to business metrics, which provide the organization with important information. Thanks to them, we can monitor user statistics or measure the technical aspects. For instance, it is possible to verify whether adding a new GUI to our library product catalog will affect the rental of books or not. Almost every software has alerts that report deviations in the processes. It increases the system observability and reduces the time needed to find issues.
Metrics for the library system
- How many users register accounts in our service in some period of time
- How many borrowed books we had in a selected period
- How many recommended books the users added to the cart
To sum up, the article aimed to show the idea of creating design and its value. It is worth taking the time to prepare the application design. Generally speaking, a well-thought-out and well-modelled design will be easy to develop and maintain.
Stay tuned for the following articles, in which I’ll cover details of this example by adding new business logic and discussing specific aspects of software development.
Dawid Cisowski, Senior Software Engineer at Grand Parade