我不会写一个名为“Common”或“Utilities”或“Misc”或......的库,你明白了。 相反,我有一个名为“Lib”的目录,并将每个功能区域放在该目录下的单独库中。 例如,我可能有用于 C++ 项目的 Lib/Trace、Lib/UI、Lib/Net、Lib/Web。 对于 C#,我有 Lib/Acme.Trace、Lib/Acme.Windows.Forms、Lib/Acme.Net 等(假设您的顶级命名空间/公司称为“Acme”)。
亚格尼。 不要编写您可能需要的代码。
在两个或多个项目中使用过的东西之前,不要将它们放入共享库中。
I wouldn't write a library called 'Common' or 'Utilities' or 'Misc' or... You get the idea. Instead, I'd have a directory called 'Lib', and have each area of functionality in a separate library under that. For example, I might have Lib/Trace, Lib/UI, Lib/Net, Lib/Web for a C++ project. For C#, I'd have Lib/Acme.Trace, Lib/Acme.Windows.Forms, Lib/Acme.Net, etc. (assuming your top-level namespace/company is called 'Acme').
YAGNI. Don't go writing code that you might need.
Don't throw things into a shared library until you've used them in two or more projects.
Personally, I would put some of this functionality into separate libraries, as "utility" is a rather subjective term, what one person finds helpful is not so helpful to another.
If within the library it was broken up into descriptive namespaces, then I would say that's better (e.g. resize images would be in some sort of .Drawing namespace, or in a .Drawing.dll).
I'd suggest that instead of a "utility" library just make domain specific (graphics, authentication, validation, etc) libraries and only include them where they are needed. The key of course is decided how specific to be. More specificity is generally better.
Irregardless if it has no domain then you probably don't understand it fully meaning that you should re-evaluate what you are doing and trying to accomplish first.
Also, remember that what is useful in one or two projects may end up only being useful in one or two projects. Adding more classes than necessary only causes maintenance issues down the road.
Though I am just a fledgling developer myself I have found RegEx functions and SQL filters to be quite useful. I also have Merge Replication functionality for MSSQL that has been quite handy for me so far.
发布评论
评论(5)
就我个人而言,我会将其中一些功能放入单独的库中,因为“实用性”是一个相当主观的术语,一个人认为有用的东西对另一个人来说就没那么有帮助。
如果在库中它被分解为描述性命名空间,那么我会说这更好(例如,调整图像大小将位于某种 .Drawing 命名空间中,或在 .Drawing.dll 中)。
Personally, I would put some of this functionality into separate libraries, as "utility" is a rather subjective term, what one person finds helpful is not so helpful to another.
If within the library it was broken up into descriptive namespaces, then I would say that's better (e.g. resize images would be in some sort of .Drawing namespace, or in a .Drawing.dll).
我的类库中有很多东西可以在项目之间共享:
Tuple<..>
等。Set
、Heap
,以及大量用于处理各种类型集合的实用方法。当我需要更多东西时,会添加类库。
I have plenty of things in my class library which I share between projects:
Tuple<..>
etc.Set<T>
,Heap<T>
, as well as plenty of utility methods for dealing with various types of collectionsThe class library is added to when I need more stuff.
我建议不要创建“实用程序”库,而是创建特定于域的(图形、身份验证、验证等)库,并且只在需要的地方包含它们。 当然关键在于具体到什么程度。 通常越具体越好。
无论如何,如果它没有域,那么您可能没有完全理解它,这意味着您应该首先重新评估您正在做的事情并试图完成的事情。
另外,请记住,对一两个项目有用的东西最终可能只对一两个项目有用。 添加过多的类只会导致后续的维护问题。
I'd suggest that instead of a "utility" library just make domain specific (graphics, authentication, validation, etc) libraries and only include them where they are needed. The key of course is decided how specific to be. More specificity is generally better.
Irregardless if it has no domain then you probably don't understand it fully meaning that you should re-evaluate what you are doing and trying to accomplish first.
Also, remember that what is useful in one or two projects may end up only being useful in one or two projects. Adding more classes than necessary only causes maintenance issues down the road.
虽然我自己只是一个初出茅庐的开发人员,但我发现 RegEx 函数和 SQL 过滤器非常有用。 我还拥有 MSSQL 的合并复制功能,到目前为止这对我来说非常方便。
Though I am just a fledgling developer myself I have found RegEx functions and SQL filters to be quite useful. I also have Merge Replication functionality for MSSQL that has been quite handy for me so far.