Help in WPF programming

huffie

Senior Member
Joined
Mar 9, 2007
Messages
1,199
Reaction score
2
Relatively new to windows programming especially in WPF for office's in-house application. Would like to know for those who have done WPF, is it normal to have MainWindow.xaml.cs to be a huge file (probably more than a thousand lines of code) due to validation rules and some computation for display?
Am coming from J2EE background on servlet and some simple .Net mobile apps so not sure if I'm doing right, since for web-app validation can be done on the webpage itself than throwing everything to classes.
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
Relatively new to windows programming especially in WPF for office's in-house application. Would like to know for those who have done WPF, is it normal to have MainWindow.xaml.cs to be a huge file (probably more than a thousand lines of code) due to validation rules and some computation for display?
Am coming from J2EE background on servlet and some simple .Net mobile apps so not sure if I'm doing right, since for web-app validation can be done on the webpage itself than throwing everything to classes.

The need to factorise your codes and also to be modular are practices in any proper development exercises. It is not just Java or .NET. It is also not limited to web development or native application or even firmware development.

Using any encapsulating constructs offered by the programming languages may it be structure, classes, different modules, libraries and so forth are encouraged if you want your codes to be easily maintained and easy for other developers to follow up or even for yourself to carry on after weeks or months of not working on it.

Any web development not following these practices are either sloppy works, patchy works or just not doing it right. If you want your validation routines to be usable across various entry points of your web frameworks, you should consider placing them in libraries or different classes. Any programming languages that able reference to other codes via import or include or any form of modular programming will make it possible for you to do so.

If your validation codes are copy and paste across various webpages, then you should consider refactorise them.

A class having a few thousands lines is not wrong, but you have to ask yourself if you have did all you can within reasonable time frame and effort to refactor as and when possible. At the end of the day, it is about operational efficiency and on-going development works that makes you required to spend extra effort to maintain the readability of your codes.

I hope it is clear for you
 

weeyoung

Member
Joined
Aug 6, 2009
Messages
189
Reaction score
0
WPF is dealing more with MVVM - model-view-view model.
view is your xaml. xaml.cs should be your view model.

You can also break your main view down to different views or can do inheritance if need to.

PM me if you need more information
 
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top