表单功能编码的最佳实践是什么 [英] what is the best practice for form functional coding

查看:57
本文介绍了表单功能编码的最佳实践是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用Windows窗体编程了两年了.不幸的是,我没有探讨在Forms.cs中处理大量代码的最佳实践是什么.我一直在为表单以外的单独类中的每个控件和事件处理程序使用Manager类.但是我不知道是否有更好的方法来管理许多单一形式的代码.保持最佳的内存利用率.我需要参考一些好的文章.你能帮我学习吗?
我正在开发ERP系统,其代码会随着时间而增加.
期待与您联系.

I have been programing in windows forms for two years. Unfortunately I didn''t explored what is the best practice to handle a lot of code in Forms.cs I have been using Manager classes for each controls and event handlers in seperate classes other than form. But I don''t know if there is some better way for managing a lot of code of a single form. keeping best memory utilization. I need references to some good articles. Can you help me learning.
I am developing ERP system whose code increase with time.
Looking forward to know from you.

推荐答案

好吧,与任何面向对象的编程语言一样,OOP概念总是一个好习惯.这并非特定于WinForms.
面向对象编程概念(OOP)简介及更多 [ OOD原理(SOLID) [ ^ ]

现在,在构建应用程序时多层体系结构 [多层体系结构 [ MVC(模型视图控制器) [ ^ ]和 MVP(模型视图演示者) [ ^ ].
这是有关WinForms两种方法的利弊的一些有趣的讨论:
WinForms模型视图演示器 [针对WinForms应用的MVC与MVP [ ^ ]
MVC/MVP是WinForms中的反模式吗? [ ^ ]
选择WinForms的MVC/MVP实现项目 [具有.NET的模型视图呈现器(MVP)设计模式-WinForms与ASP .NET WebForms [ ^ ]
选择一些:)

我希望可以给您一些最佳实践的想法,编写可维护和灵活的代码等.
顺便说一句,也有助于实现此目标的是保持您的代码一致. 命名约定和编程标准 [
Well, as goes with any Object Oriented Programming language the OOP conctepts are always a good practice. This is not specific to WinForms.
Introduction to Object Oriented Programming Concepts (OOP) and More[^]
Principles of OOD (SOLID)[^]

Now when building applications multi-layered architecture[^] keeps your data, business and presentation logic apart from each other. Actually the multi-tiered architecture[^] is also considered best practice (kind of extends or implements SOLID).

Now how does such stuff work in the presentation layer? For this there are a couple of well known patterns. In WinForms (but also web development) we have mostly MVC (Model View Controller)[^] and MVP (Model View Presenter)[^].
Here are some interesting discussions about the pro''s and cons to both approaches in WinForms:
WinForms Model View Presenter[^]
MVC vs. MVP for a WinForms app[^]
Is MVC/MVP an anti-patterns in WinForms?[^]
Selecting an MVC/MVP Implementation for a WinForms Project[^]
Model-View-Presenter (MVP) Design Pattern with .NET - WinForms vs. ASP.NET WebForms[^]
Pick a few :)

I hope that gives you some idea''s to best practices, writing maintainable and flexible code etc.
By the way, what also helps towards this goal is keeping your code consistent. Naming conventions and programming standards[^] help others to understand your code.
Hope it helps! :)


转到此处 [
Go here [^]

If you want to find articles on codeproject, just add "codeproject" to whatever you type in the search field.


这篇关于表单功能编码的最佳实践是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆