Key points
- Some good progress has the team achieved
- Some example via the coding workshop
- Analysis and next step
This is to continue on my previous post (Part 1) . And yeah, we have made a good progress on translating the abstract knowledge into working example throughout the workshop.
We started with the coding problem
![problem-code](https://dotnetsharing.wordpress.com/wp-content/uploads/2017/01/problem-code.jpg?w=1100)
Let’s say if we need to add in a new enhancement for the Message Type of ‘Skype’, how could we normally do it? Let’s see.
![enhancement-to-make-ui](https://dotnetsharing.wordpress.com/wp-content/uploads/2017/01/enhancement-to-make-ui.jpg?w=521&h=387)
![enhancement-problem-code](https://dotnetsharing.wordpress.com/wp-content/uploads/2017/01/enhancement-problem-code.jpg?w=1100)
Does it sounds familiar to you? It’s sadly that it’s usually the way we maintain the source code. In the way, we fail badly as a programmer. That is why we need some other better approach that would help us to create a better maintainable code. Have you got excited yet? I am so excited about the potential of our future code from the experience i had during the coding section. Let me share with you what the team come up with after a 1 hours coding workshop :).
Basically the team have identify following SOLID violations
- SRP – violated : This ‘MessageHelper’ class have four responsibilities
- OCP – violated : If there are new requirements coming, the existing class ‘MessageHelper’ must be modified
- LSP – No violation
- ISP – violated : this IMessage interface is too fat, clients won’t trigger all functions in one action
- DRP – violated : The email sending process relays on the ‘switch case’
Following are the enhancement code.
![refactor-1](https://dotnetsharing.wordpress.com/wp-content/uploads/2017/01/refactor-1.jpg?w=740&h=435)
![refactor-2](https://dotnetsharing.wordpress.com/wp-content/uploads/2017/01/refactor-2.jpg?w=727&h=396)
The next step would be to revisit our codes and identified the violated services so that we could capture them and formulate a plan to passively improve it. By doing so, we hope to improve our life and productivity by focusing our energy on the critical problems ahead.
One step at a time, and soon we get there.
Cheers,
Mike