The first step in meeting the Single Responsibility SOLID principles in our source code is by delegating the functions and responsibility to other classes or methods. As we may understand from the code below, the caller able to solve the problem and produce the same result but the task now is delegated to a different methods in a different classes with specific functions and responsibilities.
Next lets dive deep on each of the methods implementation.
As we can see, the algorithm to solve the problem is now been separated into 3 task
1. ConvertToList ( Convert Stream data type to List of Strings )
2. ConvertToSampleDataType ( Convert the List of Strings to List of SampleDataType )
3. InjectToDatabase ( Save the data to a database )
This is a common first step when refactoring our source code to meet the Single Responsibility SOLID principles. By doing this, it doesn't mean that we actually meet the SOLID principles, but it is a good start where we now able to separate each responsibility into a separate method.
Ref no : DTC-WPUB-000097
Comments
Post a Comment