Why Software needs an Architecture ? - Testability, Modifiablity, Readability, Maintainability etc.. All abilities !
Hello Enthusiasts ! Happy to see you back :-) !
Trust me its going to be the best day today with a worthy read on "a buzz word, that we hear every day in our work or in the world around us often", "a word that never been changed for years and years and stays strong changing the life of human kind", a word that is being the base of any system in the world or even to the universe as a system".
Fine I can hear from your minds to reveal the interesting, core word of the this read and that most valuable word - "Architecture".
Wikipedia says about architecture as -
"Architecture is both the process and the product of planning, designing, and constructing buildings or any other structures. Architectural works, in the material form of buildings, are often perceived as cultural symbols and as works of art. Historical civilizations are often identified with their surviving architectural achievements."
:-O Yuhoooo !! Architects out there ! Be proud that we change the world and be the leader of art identified by our architectural works. Being said that the famous book on Software Architecture - "Software Architecture in Practice" by Len Bass 3rd Edition brings out the fact that tomorrow's world and our life is decided by the architects of today !
"Good judgment is usually the result of experience.
And experience is frequently the result of bad
judgment. But to learn from the experience of
others requires those who have the experience to
share the knowledge with those who follow.
-Barry LePatner"
Agenda:
- What is software architecture & its Importance?
- Is it a responsibility of Architects alone ?
- Proof for the claim - Software Architecture is important - Code Example
Something we build, say a building or any product can be built how ever we want. But in practical real life situations, those products are going to be running or operated in the more critical realistic situations. Lets consider a software product being built to a customer, with lots of constraints of budget while maintaining the reliability and other requirements and they keep changing over the period of time ? Keep on building the floors without deciding the load to the basement would result in a serious risk, same applies in software too.
A Software Architecture helps decide the fundamental structure of a software product being the frame or the structural element deciding the load it can take, the changes it can adopt, the more maintainable it makes the software and decides the abilities of the software to suit all the constraints.
Architects - as the designation mentions, they architect the software product to suit the needs of the customer. They put in all the experience and the knowledge on the technology, tools in the market, latest trends in the domain, solutions that are available as re-usable etc to frame the so called the architecture. An Architect is a true key person in the industry who influence the customer, vendor and the software and finally the end users through the products that they architect.
Though they are proud that they architect-ed a good structure, their next ability is to communicate the structure to the customer in the way that customer is benefiting, to the vendor in a way that the vendor company is getting the profit, to the developers in a way that the developers can understand to implement the same in the code that they do. Mostly architects makes use of the visualizations to make this happen, the famous "4+1 view" and UML standards are handy tools of an Architect to bring the system to the visualization explaining the,
- High level of the system
- Requirements satisfied by the system
- Benefits given by the system
- Use cases the system covers
- Non functional requirements for the system
- How the system will be deployed
- How the system will interact with each other
- What is the challenges and risk and mitigation structure and etc etc etc
OMG !! A lot of work goes in there, finally when the developer does the code in the way developer likes to do so, its like constructing the building or a bridge on the fly without prior plan.
So Developers now I guess, the importance of you in translating the architecture into the implementation is the most precious job that brings life to the product with all the abilities proposed.
Okay !! I can get the murmuring minds, "I know the syntax and to apply any requirement the client ask for, why these are important ?" Let me prove this with the example below.
Okay !! theories apart, lets get dirty into code.
To give the spark on the importance of architecture implementation, I am taking a use case - a simple one to send the OTP to the email or SMS or both.
Requirements goes like this,
I need to send the encrypted OTP to the user in the mail or in the SMS.
Lets write the code for this in a straight forward approach as below,
Above code have both the proper and improper structure, Lets look into the improper one first.
Lets see what are the problems it gives us,
Problems that are commonly found in this.
- Re-usability ? - No none of the functions like generating the OTP cannot be re-used, if I am extending to another channel
- Modifiablity ? - Since it is a small use case we can, but imagine this is going to be a very big file with 1000 of lines, then the modifiability is an issue, we can't keep track of what the problem is and where the changes need to be done.
- Coupling ? Yes it has all the functionalities coupled into one
- Single responsibility ? No all the responsibility is given to the OTPGenerator, even to encrypt the OTP .
- Change managed ? Changing any thing will affect any part of code, changes cannot be arrested to certain level.
- TESTABLE ? Yes we can test but only if the email is sent or not, we are not able to test if the otp is generated of length 4, OTP is encrypted?, is mail transporter or channel is working or throwing error ? if throwing error, is my system handling ? Does changing the configuration, is it changing the behavior in sending the OTP ? etc.
- etc., A lot more !!
Below is the unit test written for this, clearly shows that it can only test if the sendOtp is passed or not by throwing the exception and nothing else can be tested.
So we can understand the problems, what is the solution ? Solution is to think on applying the experience through the architecture in the name of patterns and tactics.
Though the use case is small, Let me write all the applicable patterns to make this more reliable. In real world, making such over covered or less covered is a problem, finding the balance between the two extremes gives a good low coupling, good cohesive code and that comes out of the experience.
Lets make use of the strategy pattern, factory pattern / Creator Pattern, Manager / Controller Pattern and lets see how the same use case gets evolved better.
Though the use case is small, Let me write all the applicable patterns to make this more reliable. In real world, making such over covered or less covered is a problem, finding the balance between the two extremes gives a good low coupling, good cohesive code and that comes out of the experience.
Lets make use of the strategy pattern, factory pattern / Creator Pattern, Manager / Controller Pattern and lets see how the same use case gets evolved better.
Comments
Post a Comment