Hi,
Reading about ‘programming against interfaces’, single responsibility, ISP, clean code, etc I created a (very) small c# (winforms) test project which I hope somebody can have a look at and give me feedback.
The objective was to create reusable code that is as loosely coupled as possible (implementing the knowledge gained so far)
To make it concrete I build a simple login form (you know the one where you are asked for a username/password).
Code I now wrote about 10 time for multiple applications, every time thinking ‘oh, well lets write it again, is faster than digging up the previous one’
I created a test project with a form and 1 button to start the real thing (the login form)
I separated the login view from the login ‘handler’ (in order to prevent confusion regarding MVC & MVP, I called it handler)
Both have their own interfaces so only know each other’s interfaces.
And yes I had a look at MVC & MVP for windows forms, but what I saw so far I didn’t like (in one, the default forms designer couldn’t be used. All buttons/labels/etc are created manually which is not my idea of productivity, and in the other there is a coupling between the two). Other things where mainly focusing on ASP.
If anybody has some good links regarding MVC/MVP for c# winForms, I would be grateful.
The idea is that we can test the handler without the view and both can change independently (as long as the interfaces don’t change).
So main objectives:
-testable code (test handler without testing the view)
-reusable code (loosely coupled, swap one view for another with the same handler, or swap handlers for same view, etc)
But the point is that most of the changes I can imagine at this stage, do need the interface to change, meaning that older code will have to implement the new interface changes which on its turn makes me ask if this is useful at al.
Let say we would like to add a label that warns if the caps locks key is down, this means we need a label on the form, we could handle the logic in the view as well but not sure that is nice. And if we change the interface in order for the handler to handle it, we are not backward compatible.
Code can be downloaded via this link:
https://www.dropbox.com/s/vih7q03ulyepoba/loginTester_v2.zip
Feedback on code & mainly on architecture are appreciated,
Regards,