|
Post by rubina9898 on Dec 25, 2023 5:36:21 GMT
Algorithm and passing additional parameters that are irrelevant from the point of view of business logic returning an response. This is a clear violation of the principle of single responsibility. In the above case ugly looking code is the least of your problems. As you continue working on the project this code will probably grow and new responsibilities connections and dependencies will be created. Business or technical requirements may also change. The code above is in no way prepared for this and as the project develops making changes Phone Number List to it will become more and more difficult more time consuming and less error resistant. The icing on the cake is the inability to test this code with unit tests. If the topic of testing is unfamiliar to you I encourage you to read the article discussing the basics of automated software testing. See what the code might look like after applying SRP. imp username password return d This code looks much better in my opinion. We managed to get rid of three out of four responsibilities. Validation is now done using previously prepared validators. Decorators were used for validation thanks to which the implementation details of validation were hidden. Database operations and hash generation have also been moved to another class.
|
|