views:

448

answers:

11

I've been developing with PHP5/MySQL for years, but recent circumstances have pushed me to move towards the .NET platform.

I'd be interested to hear any advise from someone who has gone through this transition... What are some things you wish you knew when you started? I also have a Java background so I'm not scared of the OO aspect of it. My main concerns are:

  1. The differences between MySQL and MSSQL
  2. Learning the .NET libraries (hopefully similar to Sun's)
  3. The flow of .NET pages, which are event based, compared to PHP's linear top-to-bottom layout

I'd appreciate any advise. Thanks.


Edit: I agree with you guys that learning VB is kind of a step backwards, and I actually hesitated when told I wouldn't have the option to use C# instead...But in the end, the team they already have established are VB-heads so that's that.

As long as it uses the same libraries I think it'll be alright. What I'd really like is a PHP to VB or even a Java to VB cheatsheet... I was reading a VB to C# comparison sheet but there were some things I didn't understand such as delegates.

TLDR; No more C# comparisons please

+1  A: 

Welcome to the light :-)

  1. Legion, but it all depends on how complicated your schema and queries are. For basic things, you'll be up and running in no time.

  2. With the amount of samples and documentation available, don't worry. Just keep the Golden Rule Of New Frameworks in mind: if something feels deeply weird and/or stupid, there's probably a better way to do it.

  3. is the most important. Google around for the architecture behind ASP.NET. Without a through understanding of view state, you risk coding horrifically inefficient applications.

Stu
+3  A: 

I'm sort of in the same position, but I'm not actually building ASP.NET applications. I've been using .NET more for Web Services and Windows Applications. My advice is if you're familiar with a C-style language (PHP, Java, etc.) your best bet is to migrate into .NET in a C-style language, at first.

I tried migrating in through VB.NET and it ended up being a major turn-off because I was trying to learn a completely different language under a completely different architecture. Try going in under C# rather than VB, at first, and if you really want to do VB you can migrate to it after you get more comfortable with .NET. After using C# for about a year now, I intend to stick with it, rather than moving to VB. I'll probably learn enough VB just to have the general knowledge, but I'm enjoying C# quite a lot.

  1. That depends on the version you're using. More recent versions of MySQL seem to be slowly catching up to MSSQL's feature set, but more complex queries are pretty different between the two. Simple queries can easily be transitioned over to work on MSSQL.
  2. MSDN is going to be your best friend. The documentation and reference material for .NET there is very extensive.
  3. I can't offer any advice here, because I'm still developing in PHP for all of my web development. A setup that is working really well for me is using PHP on the frontend and .NET on the backend.
Jeremy Privett
+2  A: 

Start with C#.

Terrapin
A: 

My fist advice would be - Run!

Can't? Well, the only thing for you to look forward to is SQL Server. There are some minor differences like remembering to do SELECT TOP 10 foo FROM bar instead of SELECT foo FROM bar LIMIT 10, but the main thing is, SQL Server's optimizer is way better, the performance is way better, and most of the time you don't need to be knee deep in config settings to get any kind of decent performance.

I just can't stomach ASP .NET.

deadprogrammer
A: 

Disclaimer: This is not a bitch about VB.NET or how VB.NET guys aren't as clever as C# guys (I was a VB/MTS/COM+ kinda guy and loved it), it's also not intended to start a VB vs C# flame war etc etc etc. Classic COM VB5/6 gave me many years of love, joy and service and importantly paid the rent. But....if you're making the switch to .NET learn C# instead of VB.NET.

Sadly, VB in the incarnation of VB.NET has turned into a hideous boil of a language and you'll just hate .NET if you're learning it by way of VB.NET. Whilst there is no difference in terms of application performance between C# and VB.NET, for me personally it was just the look and design and sheer verbosity of VB.NET as a language. Also I was a C guy in the late 80's early 90's and did a some Java in the late 90's so the opportunity to get back to working in curly brace land was too much to resist.

Anyhoo, on a more positive note and a few words of advice, learn the fundamentals of the CLR, Common Type System and the Base Class Library and so on and know them well. A good grounding here goes a long way in the future. The following books are well worth picking up when you're just getting started:

  • CLR via C# by Jeff Richter Essential
  • ASP.NET 2.0 by Fritz Onion

In addition the http://www.asp.net website has a ton of tutorials to get you familiarised with ASP.NET.

Kev
+2  A: 

One thing to note that others have not mentioned is that MySQL can be used by .NET no problem. .NET's data access APIs are generic enough to work with most any data provider, including MySQL. See MySql's .NET connector.

So unless your team's already set on MSSQL, MySQL may remain an option for you.

Judah Himango
+1  A: 

About six months ago I moved from a job where I did mostly Perl CGI programming (with some PHP), to my current position which primarily uses the .NET framework.

Personally, I think events -- specifically, knowing when an event is supposed to fire -- is the hardest part of .NET development. I'm still not sure of the exact differences between Init, Load, and PreRender. With some trial and error, I've managed to get most of my pages to render and update the way I expect them to. I wish I had some resources to give you, but I'm still working on this myself.

.NET's method of handling database queries is very different from PHP's. It's worth taking the time to understand how it handles query parameters.

With my first .NET project, I found myself doing a lot of refactoring as I learned the new platform. I often found myself writing what was essentially translated Perl code, then going through the MSDN library to find a better way when something looked really ugly.

The MSDN library will be your best friend as you learn .NET.

Bruce Alderman
+2  A: 

Regarding the differences between developing PHP pages versus ASP.NET, ASP.NET is a much different beast than what you've been working with via PHP. ASP.NET (using WebForms) is an abstraction that imposes an event/control based paradigm that apes the motion of traditional Windows forms development.

Some general concepts to research:

  • Server/Web/Html/User Controls
  • The ASP.NET page lifecycle
  • ViewState
  • Application configuration via the web.config
Rich Reuter
+5  A: 

All this vb / c# hate. They're both the same exact language, I don't get it. It all turns into that MSIL crap anyway.

Shawn Simon
A: 

Pick up a ASP.NET book (any of them would be fine). They start with the very basics of the .NET framework move to explaining ASP.NET (web controls vs. html controls, etc) and then elaborate on the different parts of the platform (membership providers, ado.net, caching, debugging, etc). Something like this book would be great help in your learning.

sestocker
+1  A: 

As Judah says, don't throw out MySQL just because you are moving from PHP.

I've done some work on trying to make a codebase work with both MySQL (where it was developed) and MSSQL and the differences can get very annoying:

CONCAT('some', 'string', 'fragments')
NOW()
DATE_FORMAT(NOW(), '%Y')

vs

'some' + 'string' + 'fragment'
CURRENT_TIMESTAMP
CAST(DATEPART(year, CURRENT_TIMESTAMP) AS VARCHAR)

I've got a few user defined functions set up so that I can call dbo.DATE_ADD() and handle the differences in the database layer rather than having large differences between the queries for the different systems.

MSSQL also seems to lack any real time zone support - I haven't found any direct equivalent to

SELECT CONVERT_TZ(NOW(), 'AUSTRALIA/SYDNEY','AMERICA/NEW_YORK');

which gives the correct answer in MySQL, respecting Daylight Savings.

I'm not saying that MSSQL is worse (the GROUP BY/ORDER BY interaction in particular is a much better design than MySQL's more forgiving approach), but the differences when you have developed in one and are moving to the other can be larger than you'd think by considering them both as SQL. If you use the SET and ENUM field types, you'll need to change these as well.

Edit: Another difference I have literally just found out is:

SELECT UTC_TIMESTAMP()

becomes

SELECT GETUTCDATE()

so there is at least some timezone handling.

Cebjyre