简体   繁体   English

将现有代码从C#2.0移植到C#3.0和.Net 3.5(可能是.net 4.0)

[英]Porting existing code from C# 2.0 to C#3.0 and .Net 3.5 (possibly .net 4.0)

Our one and only enterprise application suite has been developed over last 3 years using C# 2.0 on .Net 3.0. 我们唯一的企业应用程序套件是在过去3年中使用.Net 3.0上的C#2.0开发的。 We use winforms and WCF heavily. 我们大量使用winforms和WCF。 The development tools is VS 2005 Pro / TFS 2005 / Resharper 3.1 开发工具是VS 2005 Pro / TFS 2005 / Resharper 3.1

As technical lead I obviously understand the benefits in a move to C#3.0 and .Net 3.5. 作为技术主管,我明显了解迁移到C#3.0和.Net 3.5的好处。 But I want to convince management for a move to C#3.0, .Net 3.5, VS 2008 and TFS 2008. They will obviously be interested in things like productivity, cost, quality etc. Please suggest me some ideas on how best to make my case. 但我想说服管理层转向C#3.0,.Net 3.5,VS 2008和TFS 2008.他们显然会对生产力,成本,质量等问题感兴趣。请告诉我一些关于如何最好地制作我的想法的建议案件。

Given that this may not happen till mid next year am I better off to hold till VS 2010 and .Net 4.0 is out. 鉴于这可能不会发生到明年年中,我最好坚持到VS 2010和.Net 4.0出局。

“如果我们不升级到更新的技术,聘请优秀的开发人员会更加困难,那些我们已经拥有的人将很快逃离......可能包括我自己......”

Is there much in .NET 4.0 which will benefit you? .NET 4.0中有哪些对您有益吗? C# 4 itself doesn't have many new features... whereas I'd expect you could make good use of the C# 3 features. C#4本身没有很多新功能......但我希望你能充分利用C#3的功能。 .NET 4.0 does have some very cool things (in particular Code Contracts and Parallel Extensions) but you should really look at what you would use. .NET 4.0确实有一些非常酷的东西(特别是Code Contracts和Parallel Extensions),但你应该看看会使用什么。

If management is nervous about changing framework version, you could upgrade to VS2008 and use C# 3 but still target .NET 2.0. 如果管理层对更改框架版本感到紧张,您可以升级到VS2008并使用C#3但仍然以.NET 2.0为目标。 (Most of the C# 3 features still work when targeting .NET 2.0.) Using LINQBridge you could even still use LINQ to Objects, which is hugely beneficial IMO. (当针对.NET 2.0时,大多数C#3功能仍然有效。)使用LINQBridge,您甚至可以使用LINQ to Objects,这对IMO非常有益。

Of course if you can upgrade to .NET 3.5, you'll clearly get more opportunities for LINQ goodness, etc. 当然,如果你可以升级到.NET 3.5,你显然会获得更多LINQ善良等机会。

  1. Whip out the Microsoft expiration schedule on technologies, figure out how long your current solution set will be supported. 制定有关技术的Microsoft过期计划,确定支持当前解决方案集的时间。
  2. Look to things like Linq-to-Entities. 看看Linq-to-Entities之类的东西。 If you don't currently have an ORM, this is a huge time saver. 如果您目前没有ORM,这可以节省大量时间。
  3. It's always easier to upgrade version by version than it is to jump several versions. 按版本升级版本比跳转多个版本更容易。 I learned this over time. 我随着时间的推移了解到了 Step by step upgrades were almost always painless. 逐步升级几乎总是无痛。 Upgrades that jumped multiple versions required a signficantly larger amount of extra code and testing. 跳过多个版本的升级需要显着更多的额外代码和测试。
  4. Identify the top 5 features in your "nice to have list". 确定“最好的清单”中的前5个功能。 How many of them are only provided by, or provided in a better way, by the new version? 其中有多少只是由新版本提供或以更好的方式提供?
  5. Don't push for bleeding edge. 不要推动前沿。 There's a cost to being on the very edge of emerging technology. 处于新兴技术的最前沿需要付出代价。 That cost is often very hard to justify from a business standpoint. 从商业角度来看,这种成本通常很难证明是合理的。
  6. You have change code anyways. 无论如何你都有改变代码。 Figure up the cost of the next X feature changes. 计算下一个X功能更改的成本。 Try to roll it into a release. 尝试将其转换为版本。 "We can do it as part of XYZ release with only NN extra hours, saving MM hours over the next six months". “我们可以作为XYZ发布的一部分,只需NN额外的小时,在未来六个月内节省MM小时”。
  7. Look around the web for stats on code rollover. 查看网络上的代码翻转统计信息。 Most custom systems are "rewritten" gradually over time as the business process changes. 随着业务流程的变化,大多数自定义系统会随着时间的推移逐渐“重写”。 However management tends to view software as a "write once, use forever" endeavor with only some maintenance costs. 然而,管理层倾向于将软件视为“一次编写,永远使用”的努力,只需要一些维护成本。 Make sure they understand that this is them taking control of the upgrade process, and them guiding the future of their tool in a planned fashion, as opposed to just whatever comes out after dozens of minor changes. 确保他们理解这是他们控制升级过程,并且他们以有计划的方式指导他们的工具的未来,而不是在几十次微小变化之后发生的任何事情。

Edit: This all assumes that there actually is a cost justification, which you will hopefully answer for yourself while going down this list. 编辑:这一切都假定实际存在成本合理性,您希望在下列此列表时自己回答。

I don't think any productivity gained by going from C# 2.0 to C# 3.0 can be easily justified for a particular project. 我不认为从C#2.0到C#3.0获得的任何生产力都可以很容易地证明特定项目的合理性。 Rather than try to justify moving to the new version of the language, think about why you wouldn't? 而不是试图证明移动到新版本的语言,考虑为什么你不会?

  1. Does the group want to stay with VS2005 forever, or are they planning on moving to VS2008 some day. 该组织是否希望永远使用VS2005,或者他们是否计划有一天转移到VS2008。 If they want to stay at VS2005, consider the fact that that compiler is now on extended support, pretty soon it won't be supported at all, and you won't be able to get even security updates, similar to VC6. 如果他们想要留在VS2005,请考虑这个编译器现在处于扩展支持的事实,很快它就不会得到支持,并且你将无法获得类似于VC6的安全更新。 Furthermore, the new version of Microsoft's SDL (5.0) requires the use VS2008 or later. 此外,新版本的Microsoft SDL(5.0)需要使用VS2008或更高版本。

  2. If the group is willing to move to VS2008 eventually, then determine if you can work in a mixed mode environment. 如果该组最终愿意转移到VS2008,那么确定您是否可以在混合模式环境中工作。 This can work effectively if you have a large code base, so new components are built with the newer tools. 如果您拥有大量代码库,这可以有效地工作,因此使用较新的工具构建新组件。

  3. Once the team / project has moved to VS2008, then using C# 3.0 features as opposed to sticking to the C# 2.0 subset shouldn't really be an issue. 一旦团队/项目转移到VS2008,那么使用C#3.0功能而不是坚持使用C#2.0子集应该不是问题。

  4. For VSTS, the best thing to do is to try to use it on a new project. 对于VSTS,最好的办法是尝试在新项目中使用它。

You will have to upgrade from C# 2.0 to get LINQ. 您必须从C#2.0升级才能获得LINQ。 This technology is very powerful, not only for querying databases, but for development in general. 这项技术非常强大,不仅适用于查询数据库,也适用于一般的开发。

Upgrading should (at least in theory) be easy. 升级应该(至少在理论上)应该很容易。 You recompile and pay attention to warnings about obsoleted calls. 您重新编译并注意有关已废弃呼叫的警告。

The biggest problems I've ever run into when trying to upgrade an enterprise application and convincing management was because of the deployment cost. 我尝试升级企业应用程序和说服管理时遇到的最大问题是部署成本。 When you upgrade to .NET 3.5, all your clients will have to get the 3.5 framework. 升级到.NET 3.5时,所有客户端都必须获得3.5框架。 Depending on your end user audience, this could be a big deal. 根据您的最终用户受众,这可能是一个大问题。 That was the holding factor for management whenever we tried to pitch it. 无论何时我们试图推销它,这都是管理层的控制因素。 The language features, framework features, and other benefits/costs really didn't matter much to them. 语言功能,框架功能和其他好处/成本对他们来说并不重要。 The deployment cost kept ringing in their ears. 部署成本不断响起。 If you can make the deployment cost minimal (ie you might roll the 3.5 framework into the next install or something), then you'll probably be able to show that the productivity benefits far outweight the costs. 如果您可以将部署成本降至最低(即您可以将3.5框架推送到下一个安装或其他东西),那么您可能能够证明生产力的好处远远超过了成本。 Otherwise you might find yourself in the situation I found myself in. 否则你可能会发现自己处于我发现自己的境地。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM