Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am making a windows application using C#.NET.
But I am concerned about the architecture of the software.
Now, I am writing all the logic & data access codes in a class, and Form UI will call the function, and set property values for the class.
Is it the right method ? Is it test friendly ?
Posted

The first thought I have in reaction to your design is that you might consider having UI elements/Controls on the Form(s) raise Events that your business logic would subscribe to rather than ... if I understand you correctly ... allowing UI control Events at run-time to directly set properties in the class.

Marc Clifton, one of CodeProject's MVP's, and long-time major contributor, has just published a free e-book through SyncFusion titled: "Unit Testing Succinctly" which you can download here: [^]. I think reading/studying this book will really help you get oriented in terms of evaluating the somewhat "slippery" term "test friendly."
 
Share this answer
 
Comments
Andreas Gieriet 19-Oct-14 21:21pm    
My 5!
Cheers
Andi
BillWoodruff 19-Oct-14 21:24pm    
Thank you !
Maciej Los 20-Oct-14 1:50am    
+5
BillWoodruff 21-Oct-14 22:00pm    
Thank you !
Quote:
writing all the logic & data access codes in a class,
I hope you don't think of one class, rather use different classes for each concept in business logic and data access. As for data access, you may look at the repository pattern.
When you create your business logic, just think of later replacing your Windows Forms GUI by e.g. a web interface - can you still use those classes, or do you need to re-write them? That idea will help you do it correctly.
Keep your classes small, and keep all the functions small. One class for one concept, and one function does only one thing within that class. Such small items can be tested. Keep dependencies low - you may need to "mock" some objects.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900