常用例程的最佳做法 [英] Best practices for common routines

查看:69
本文介绍了常用例程的最佳做法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

放置将被广泛使用的通用例程的最佳实践是什么?迄今为止,我倾向于在每个项目中都简单地拥有一个ModGlue.vb文件,在该文件中我需要放置任何文件,但是在项目之间移动类需要从ModGlue中查找并​​复制适当的内容,这有些乏味并且会如果没有更好的策略,我就会变得越长.

一些通用例程是这样的:

What is the best practice for placing general-purpose routines which will be widely used? To date, I''ve tended to simply have a ModGlue.vb file in each project, where I throw any that I need, but moving classes between projects requires locating and copying in the appropriate stuff from ModGlue, which is somewhat tedious and will become moreso the longer I go without a better strategy.

Some of the general-purpose routines are things like:

Function Byt(ByVal v as Integer) As Byte<br />  Return CByte(v and 255)<br />End Function<br /><br />Function HexArr(ByVal dat() as Byte) As String  '' Returns hex representation of array<br /><br />Function ByteString(ByVal dat() as Byte, ByVal Length As Integer) As String '' Converts bytes to string (by character code)<br /><br />Sub Zap(ByRef it as iDisposable)<br />  Dim oldIt as iDisposable<br />  oldIt = it<br />  If oldIt IsNot Nothing then<br />    oldIt.Dispose<br />    Threading.Interlocked.CompareExchange(it, Nothing, oldIt)<br />  EndIf<br />End Sub



在许多情况下,sorta应该是.NET框架的一部分,但不是.在将一个类从一个项目复制到另一个项目而又不会导致多余或重复的方法结束时,确保引入必要功能的最佳方法是什么?



In many cases, things that sorta should have been part of the .Net framework, but aren''t. What''s the best way to make sure that the necessary functions get brought in when copying a class from one project to another, without ending up with extraneous or duplicated methods?

推荐答案

构建一个导入到所有项目中的dll.

Build a dll you import into all your projects.


这篇关于常用例程的最佳做法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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