局部类和运行时加载 [英] Partial classes and runtime loading

查看:87
本文介绍了局部类和运行时加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

局部类非常易于阅读,可以将UI/逻辑,团队等分开,但是:

将类的不同逻辑部分保存/拆分为不同的文件是否对运行时有好处(例如,使用内存,加载UI(WinForms)),还是我问这个问题是一个糟糕的设计故事(我的类需要重构)?

项目方案:单个开发人员,桌面开发人员,winform显示不同类型的文件搜索(本地计算机)的结果.某些搜索逻辑分隔在dll中,其余部分嵌入在winform代码中.在我分开线程逻辑,过滤等之前,最初以您将在本周末结束"开始,后来变成"Shure,我知道UML".

TIA
Per Rollvang
-------------
发生错误时进入地狱

Hi all!

Partial classes is excellent for readability, separating UI / logic, teams, etc. , but:

Is there any runtime benefits (i.e. memory use, loading UI (WinForms)) of saving / splitting different logical parts of a class into different files, or are me asking this question a tell-tale of poor design (my class need refactoring)?

Project scenario: Single developer, desktop-dev, winform displaying results of different types of filesearch (local computer). Some of the search-logic separated in a dll, rest is embedded in the winform-code. What started as a "You''ll have it by the end of the week", became "Shure, I know UML" before I parted the threading logic, filtering, etc.

TIA
Per Rollvang
-------------
On Error Goto Hell

推荐答案

没有好处也没有缺点(例如速度,内存等).
No benefits and no drawbacks whatsoever (as speed, memory and so on).


如果由于需要将您的类分解为不同的文件,因为它具有不同的逻辑"部分,因此您可能需要将类重构为多个类,每个类在项目中均扮演更具体的角色.确实应该按照方法的方式来对待类.使用方法时,名称应具有描述性,方法应完全按照其说的去做,仅此而已.一个班级应该做同样的事情.它应该定义一个对象,并且只做与自己直接相关的事情,并且可以在不了解域中其他对象的情况下进行操作.需要了解多个对象的逻辑应该在第三类中,而不是在那些其他对象中.
If you feel the need to break apart your class into different files because it has different "logical" parts, you probably need to refactor the class into multiple classes that each perform a more specific role in the project. Classes really should be treated a little along the lines of how methods should be. With methods, the name should be descriptive and the method should do exactly what it says it does and nothing more. A class should do the same. It should define an object and only do stuff that is directly relevant to itself and that it can do without knowledge of other objects in the domain. Logic that needs to have knowledge of multiple objects should be in a third class, not in one of those other objects.


这篇关于局部类和运行时加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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