Is the C# 2.0 to C# 3.0 transition worth it for this project? [closed]
Asked Answered
A

16

17

I have read on Stack Overflow some people that have converting to C#2.0 to C#3, but is it really worth it?

I have a project that is done at 75% before going in maintenance phase. I am asking to myself if it is worth it to switch to C#3.0?

Update:

The project will have a web interface now so before entering the maintenance phase we have to develop the web part (all was done for internal purposes with Windows Forms). Most parts will be resused (back-end). Most people have said that it wasn't worth it in the past because it was already at 75%... but now do you still think it's not worth it?

What have been done finally

Finally since we are continuing the project with the web interface we will update to 3.5 for the new year. Thank you everybody for all your input.

Attraction answered 4/10, 2008 at 16:10 Comment(4)
Just for completeness, .NET 2.0 and 3.0 have the C# 2.0 compiler, while .NET 3.5 has the C# 3.0 compiler. There is no such thing like a C# 3.5 compiler.Menial
@Daok:There is no such thing as C#3.5.Jarmon
Programming C# with Framework 3.5. That must work... I think you have all the mental capacity to figure the sense of the question. Example, if someone write Java1.6 ... the 1.6 is not the syntax of Java version but the framework version... I might not have written the good way for you, but it'S ok.Attraction
@Daok: I think it would be appropriate to clarify your question rather than expect others to work out that C#2.0, C#3 and C#3.5 really means C# with .NET 2, C# with .Net3 and C# with .NET3.5. It is not clear and hence, confusion arises.Jarmon
F
23

No, I would advise not. I would advise starting 3.5 on new projects only, unless there is a specific reason otherwise. You will not have any benefit from 3.5 by just recompiling, since your code is already written (or at least 75% of it).

If you need to migrate to 3.5 in the future, you can easily do it. Of course, you will have code in 2.0 style, but what is done is done.

  • Be conservative, don't do something unless you need it.
  • An application which is 75% in C#2.0 and 25% in C#3.0 is not exactly a nice beast to maintain. A 100% C#2.0 application is certainly more maintainable.

When you are going to start a new project, then by all means switch! The new framework version is very interesting and the switch is hotly recommended.

Footling answered 4/10, 2008 at 16:14 Comment(4)
I disagree. Do you have specific (even anecdotal) evidence to support your otherwise subjective advice? Why limit yourself for no reason, or do you assume Daok is coding by coincidence and doesn't unit test? If it's so easily done, why wait?Rhombic
I think the confusion comes from mixing .NET versions with C# versions.Jarmon
Nop, I was talking about the framework version. Using C# with .Net 2 and was asking if it was good idea to change to C# with .Net 3.5...Attraction
While I haven't had any issues upgrading projects, I can appreciate how awkward the code base might be if 25% had v3.5 things things and the other 75% didn't.Biagi
J
52

Clarification
C# 3.5 doesn't exist. There is C#1.0, C#2.0 and C#3.0.

Then there is .NET 1.0, .NET 1.1, .NET 2.0, .NET 3.0, and .NET 3.5.

We should not confuse the two.

C# 3.0 vs C#2.0
Now, is C#3.0 worth the move? I would say that with the existence of Extension methods and Lambda expressions, the answer is yes. These two features alone make for easier to read and quicker to write code. Add that to auto-implemented properties, LINQ, and partial methods, and C#3.0 shows itself to be an advantageous move.

However, it is not necessarily beneficial to move an existing project. You have to weigh the pros and the cons, especially with regards to introducing new bugs and instability, before deciding to migrate existing work. For new projects, I'd say start with C#3.0.

Jarmon answered 4/10, 2008 at 16:38 Comment(4)
Damn... you beat me by 18 seconds.....Mallorymallow
Wow, get out of my head!Jarmon
.NET 2.0 is the runtime for everything 2.0 and above. The only con to moving to 3.5 to get C#3.0 features is the time it takes to flip the drop down in Project Properties. Seriously takes all of 10 seconds per project...Manxman
@sliderhouserules: That's not true. The CLR in .NET 2.0 is used in frameworks 2.0 and above. The framework and the CLR are not the same thing.Jarmon
F
23

No, I would advise not. I would advise starting 3.5 on new projects only, unless there is a specific reason otherwise. You will not have any benefit from 3.5 by just recompiling, since your code is already written (or at least 75% of it).

If you need to migrate to 3.5 in the future, you can easily do it. Of course, you will have code in 2.0 style, but what is done is done.

  • Be conservative, don't do something unless you need it.
  • An application which is 75% in C#2.0 and 25% in C#3.0 is not exactly a nice beast to maintain. A 100% C#2.0 application is certainly more maintainable.

When you are going to start a new project, then by all means switch! The new framework version is very interesting and the switch is hotly recommended.

Footling answered 4/10, 2008 at 16:14 Comment(4)
I disagree. Do you have specific (even anecdotal) evidence to support your otherwise subjective advice? Why limit yourself for no reason, or do you assume Daok is coding by coincidence and doesn't unit test? If it's so easily done, why wait?Rhombic
I think the confusion comes from mixing .NET versions with C# versions.Jarmon
Nop, I was talking about the framework version. Using C# with .Net 2 and was asking if it was good idea to change to C# with .Net 3.5...Attraction
While I haven't had any issues upgrading projects, I can appreciate how awkward the code base might be if 25% had v3.5 things things and the other 75% didn't.Biagi
W
12

Is there any C# 3.5 feature you want badly at this stage? :)

If it is LINQ, you can give LINQBridge a try.. With Studio's multi-targeting and LINQBridge, you'll be able to write local (LINQ to Objects) queries using the full power of the C# 3.0 compiler—and yet your programs will require only Framework 2.0.

Wirewove answered 4/10, 2008 at 16:13 Comment(1)
I'd manually back-ported some of the methods myself. Thanks for the heads up about linqbridge. The less code I have to maintain, the better!Anaclinal
S
6

I think a lot of this will come down to your personal style. IMHO, the best features of C# 3.5 really come down to the following

  1. Lambda Expressions
  2. LINQ
  3. Extension Methods

My OO code still tends to look a bit functional oriented. Therefore I see 3.5 as a huge benefit and it's definately worth the upgrade.

What's even better is it's possible to use the 3.5 compiler to down target CLR 2.0. This allows you to deploy based on a 2.0 install (vs a 3.0/3.5 install) using the new framework. All of the above can be done in this scenario if you're willing to add the appropriate types into your program.

Sixteenmo answered 4/10, 2008 at 16:14 Comment(0)
A
3

In my opinion, there's no good reason not to switch to 3.5.

The real killer feature is that you can continue to target older versions of the runtime (2.0+) while using all the new language features. So you can use the new lambda expressions, extension methods, anonymous types, and all the other good stuff. And if your customers are still primarily using the 2.0 framework, you can continue targeting the earlier runtime.

(Just don't use any of the classes from the 3.5 framework, if you have to target earlier runtime versions.)

Personally, I think if you're doing a desktop GUI app, your best bet is to use the 3.0 or 3.5 framework, since WPF is the best user interface library I've ever worked with (by a long shot).

On the other hand, if you've already written most of your GUI in WinForms, then you might be interested in the 3.5 framework, which allows (limited) intermingling of WinForms and WPF GUI elements. You can keep the work you've already done, but add a few nice touches here and there, wherever it makes sense, with WPF controls.

Another handy feature of the 3.5 framework is "Collection Initializers". Check this out:

var myDictionary = new Dictionary<String, String> {
   { "key-1", "value-1" },
   { "key-2", "value-2" },
   { "key-3", "value-3" },
};

Neat, huh?

I'd have liked it a little better if it was a little more JSON-like. But it's very convenient functionality anyhow.

Any you can event target that code for the 2.0 runtime!

Aparri answered 4/10, 2008 at 21:7 Comment(0)
P
2

If your project is nearly complete, you will probably not benefit from the new features of 3.5. For new projects, it is certainly worth a look.

Preengage answered 4/10, 2008 at 16:14 Comment(0)
M
2

It really depends on the project, who it's intended for, and what it does.

It would be safe to guess that the .NET Framework 2.0 is on many more computers than version 3.5.

Additionally, is there anything you need from .NET 3.5 that isn't available in 2.0 (such as LINQ)? If you are dealing with a lot of queries and data, I would switch. But again, depends on the customer and if you intended to maintain this application for the foreseeable future.

Macrophage answered 4/10, 2008 at 16:15 Comment(0)
R
2

From a technology standpoint, it's all framework version 2 and it's very little effort to achieve. The differences in 2.0, 3.0 and 3.5 are just additional library code and some compiler syntactic sugar.

It's not like you need to change anything over; by targeting framework 3.5 you have more options.

From your teams point of view: Yes it's worth it. Nobody wants to work on old code-bases. While you're in the heat of development, you might as well utilize the most current stable technology.

Rhombic answered 8/10, 2008 at 23:13 Comment(0)
I
2

It really depends on what you need to do. If your project requires Lambda Expressions where you're query objects with a clear syntax, you should look at 3.0.

I am currently reading C# In Depth by Jon Skeet, and he takes the approach of laying out a solution in C# 1.15, then evolves the solution to depict the new and useful functionality that you get in 2.0 and 3.0. This type of progression would be a perfect means to answer your questions. The book reads well too so I am finding I am getting through it quickly.

Interpellant answered 8/10, 2008 at 23:44 Comment(1)
great book BTW. Well worth a read.Extricate
M
2

You have to weigh cost versus benefit. You don't provide enough information about your project to allow us to advice you here, but consider:

  • cost of conversion is pretty small. C# 3.0 is almost completely backwardly compatible with 2.0 and run on framework 2.0
  • benefit is also pretty small if the coding is almost finished, but might grow in the long run. A new feature you might have to implement in the future might turn out to be much easier implemented using Linq, for example.
Munch answered 29/10, 2008 at 17:30 Comment(0)
E
2

I've made the conversion many times. Mostly because the clear syntax from lambda expressions makes the code easier to follow (for me anyway).

I do use ReSharper which makes using new 3.5 features a snap as quite a few show up as refactoring suggestions by ReSharper. Using a tool like that makes this transition so much easier.

Extricate answered 1/11, 2008 at 2:12 Comment(0)
V
1

3.5 builds on top of 2.0, so you have no issues jumping directly to 3.5.

Vinegarish answered 4/10, 2008 at 16:21 Comment(0)
F
1

I would... there's no harm and you get some benefits from the new features

Flapjack answered 4/10, 2008 at 18:9 Comment(0)
M
1

I don't understand all you people saying don't do it. .NET 2.0 is the current (CLR) runtime. .NET 3.0 and .NET 3.5 both run on the 2.0 runtime. Moving to .NET 3.5 to get the C# 3.0 features is literally a matter of changing a single dropdown in your project properties. (OK, and deploying the 3.5 runtime to your target machines if you use some 3.5 features such as LINQ, etc. If installing 3.5 is an issue then it's not such an easy answer.)

Manxman answered 1/11, 2008 at 1:38 Comment(0)
S
0

I wouldn't change anything unless you have a good reason to do so; i.e. there is a bug that you can't work-around in 2.0.

Upgrading the framework at such a late point in the project is likely to cause some problems which you really don't need at the moment.

Shrivel answered 29/10, 2008 at 17:23 Comment(0)
K
0

If you have an extension to the project, it might be a good thing to switch now to the newest version of .NET, otherwise I wouldn't.

Karlin answered 21/11, 2008 at 13:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.