Translate

Sunday, January 30, 2011

.NET introduction (.net basics)


What do I need to know before I learn .net?
If you are absolutely new to the world of software, I would strongly recommend going thru Programming Methodology from Stanford and CS 61B: Data Structures  video tutorials from UC Berkley ( both available on youtube). It will save you a lot of time learning .net in the future. Its totally worth it.

What is .net?
Microsoft .net is a piece of software that makes it easier for you to build software that is meant to run on Windows based machines. If you want to build windows desk top applications or web sites that run on windows servers, you would use .net.

If I have a Mac or Linux, what are my options?
You should install the .net mono framework, which is meant for .net development on Mac and Linux.  However, at this point I must mention, I have never commercially developed any application using the .net mono framework. If you are particular about using a Linux based machine, I would recommend at looking at alternatives such as Java EE.

Why use .net?
The biggest advantage of using a .net technology is that Microsoft offers a lot of products that integrate well with .net. Also Microsoft supports all these products (you can't call anyone for support if you use apache for a webserver :)   ) The development time for a product in a Microsoft technology is much shorter as compared to java. With the introduction of LINQ, the productivity of a C# developer has taken another giant leap. The only downside is that, while technologies like php and apache webservers are free,  using Microsoft technologies for commercial deployment costs money. But considering the overall development and maintenance cost, Microsoft always works out cheaper.

How does .net work?
This example will explain how it works. Suppose I want to write a simple program that displays “Welcome to the magical world of .net “. This is what I would do.
I will install Microsoft .net 4.0 framework and Visual studio 2010 on my machine (Visual studio is a development tool that makes it easier to develop a .net based application).  I will then write a program (in this case a console application) in Visual studio using C# ( read as C sharp) as the programming language. After I write the program , when I run it, this is what happens.




Figure 1. How a .net application works

When run, the output of the above program looks like this

Figure 2. Output window

Visual Studio targets the C# compiler (csc.exe) which comes with the .net framework. The compiler converts the code into an exe file which is in Common Intermediate language (earlier known as Microsoft intermediate Language or MSIL). This code is taken by Just in time compiler (which is a part of the Common Language Runtime aka CLR ) of the .net framework and converts it into instructions for the processor of the machine.  So basically, the .net CLR is the one who tells the hardware, to display a screen that reads “Welcome to the magical world of .net”.

When you write code in C# you can leverage pre existing code in the .net framework class library. For instance, in the above program I have used the function Console.WriteLine(). Without a definition for Console.WriteLine() in the .net Class Library, the CLR wouldn’t know what instructions should be given to the operating system.

Do I need Visual Studio to run .net based Applications?
 No you don’t need Visual Studio to run .net based applications. You need it only to build .net based applications. To run a .net based application, you just need the .net framework.
Consider the example above. Suppose I want to send this application to a friend. This is what I would do. I would take the exe file that Visual Studio generated while running the program (this by default resides in the bin folder on the application). I would send that exe file to my friend and ask him to make sure he has installed .net framework 4.0 before he tries to run my exe file. After he installs the.net framework 4.0 when he double clicks on the exe file I sent him, he will see the output window shown in Figure 2 above.

If I don’t want to buy Visual Studio what are my options for development in .net?
You have a couple of options for a free development environment.
  • Use Visual Studio 2010 Express: This is a free scaled down version of Visual studio. Visual studio Express comes in a few flavors (Visual Web developer express, Visual C# express and a few more). This has almost everything that a beginner needs. In fact I even know of some relatively small companies that exclusively use the free Visual Web developer express edition for all their internal website development.
  • You can write code in notepad and compile it using the command line compiler. The command line compiler is a part of the .net sdk.
Of the two I would strongly recommend the first option.

What all can I build using Visual studio and .net framework?
There are many kinds of applications that you can build using Visual Studio and the .net framework. Some of them are listed below
1>Console Applications (the example above is a console application)
2>Windows Desktop Applications (For example, certain commercial tax softwares that you can download, are written using .net)
3>Websites
4>Web Services
5>Windows Services
6>Windows Mobile applications (You can build applications for Windows Mobile smart phones and Windows Pocket PC)

If you have Microsoft SQL server also installed on your machine, you can build the below applications too
7>SQL Server Integrated Services applications (An ETL tool that you can use to write text files and import text files into your SQL Server database)
8>Analysis Services Application (A software tool for performing certain activities in SQL server)
9>Reporting Services Application (A tool that makes it easier to create complex reports off of SQL server)



If I build a website using asp.net how do I make it live?
There are a couple of options
  • Deploy it on a windows machine you own and open the necessary ports to make it acessible to the world
  • Deploy the website on a hosting provider. You can find some providers on the Microsoft website http://www.microsoft.com/web/Hosting/Home
If you are developing a personal website, I would recommend the latter option. It is more economical.

Can you name some big companies  that use .net ?
Based on the clients that I have myself worked for or my friends have worked for in the past, I have compiled this small list of big employers who use .net .
  • Microsoft
  • HP
  • Intel
  • Verizon
  • AT&T
  • Deloitte
  • Bank of America
  • GE
  • TJX
  • UPS
  • Myspace.com
  • Nasdaq.com
  • Geico
  • G4S
  • stackoverflow.com
  • Intuit (maker of turbo tax)
  • Bain (A company founded by Mitt Romney)
  • Bingham (One of the best 100 companies to work for according to CNN)
  • Box
  • VMWare


What are the typical billing rates for .net developers?
Based on the experience and expertise of the developer, I have seen clients offering hourly billing rate between $30/hr (for 1 year of experience) to $250/hr (for rock star level .net experts with over 15 years of overall IT experience). The most typical rate that I have seen, that clients willing to pay for a .net consultant, is about $80/hour.

For full time associates this can vary between 60k (for junior developers) to 200k (for rock star developers working at google). The most typical rate for experienced developers is between $100-$125 k.

Keep in mind that these rates were relevant at the time this article was written :)

What are some good books to learn .net?
I personally go to amazon.com and sort the books by popularity. The books with high number of good ratings are usually the books I go with.

 I would recommend getting at least one book so that you would know what curriculum to follow. With over 13,000 classes in the .net framework, its mandatory that you select a subset to begin with. With a good book, that selection is taken care of for you.

If you are interested in .net, C# is a language that you have to be good at. Of all the books that I have read on C# (books from Microsoft,Wrox and Jon Skeet to name a few) the book C# in a nutshell by Joseph Albahari, Ben Albahari, has by far been my favorite. It is very simple to understand and yet very comprehensive.

If you are planing to pursue a career in asp.net, I would recommend the following reading list. The reading list below is timeless, they cover the fundamentals which wouldn't change even 10 years from now.

What happens when you visit a website?

How Does the Internet Work?

Internet Technologies Video Tutorials

CS61A: Structure and Interpretation of Computer Programs

CS 61B: Data Structures (Highly recommended for all software students)

SQL Tutorial

Database Normalization Tutorial

How Does SSL Work?

What should every programmer know about web development?

http://8085.codeplex.com/ (An 8085 microprocessor simulator. Helps you understand how programming works at the lowest level)



Of all the technology books I have read, these are some of my favorites


HTTP: The Definitive Guide  
David Gourley (Author), Brian Totty (Author)

Pro ASP.NET MVC Framework  
Steven Sanderson (Author)

Essential LINQ 
Charlie Calvert (Author), Dinesh Kulkarni (Author)

Beginning Database Design Solutions (Wrox Programmer to Programmer)  Rod Stephens (Author)

Professional SQL Server 2005 Integration Services (Programmer to Programmer) 
Brian Knight (Author), Allan Mitchell (Author), Darren Green (Author), Douglas Hinson (Author), Kathi Kellenberger (Author), Andy Leonard (Author), Erik Veerman (Author), Jason Gerard (Author), Haidong Ji (Author), Mike Murphy (Author)

NoSQL Distilled: A Brief Guide to the Emerging World of Polyglot Persistence
Pramod J. Sadalage (Author), Martin Fowler (Author)

Head First Design Patterns 
Elisabeth Freeman (Author), Eric Freeman (Author), Bert Bates (Author), Kathy Sierra (Author), Elisabeth Robson (Author)

Dependency Injection in .NET  
Mark Seemann (Author)

Design Patterns Elements of Reusable Object-Oriented Software  
Erich Gamma (Author), Richard Helm (Author), Ralph Johnson (Author), John Vlissides (Author)


Don't Make Me Think: A Common Sense Approach to Web Usability (2009)
Steve Krug (Author)

Code Complete 2nd Edition (2004)
 Steve McConnell (Author)

Implementing Domain Driven Design (2013)
Vaughn Vernon (Author)



A piece of advice before I end this article. Every time you learn something new in programming, go ahead and actually try it out. Its about 10 times simpler to understand when you actually play around with it. Plus it will register a lot better in your long term memory. Learning to use some popular tools such as the process explorer (sysinternal tools from Microsoft), fiddler, wireshark and so on, will help you learn how software works even better. Happy coding :) .


Futher Reading:
Microsoft .NET Framework FAQ:
http://msdn.microsoft.com/en-us/library/ms973850.aspx

Free Online Computer Science courses from IIT( The most prestegious engineering college in India)
http://nptel.iitm.ac.in/courses.php?disciplineId=106

Overview of the .NET Framework 4.0:
http://msdn.microsoft.com/en-us/library/a4t23ktk(v=VS.100).aspx

Some Good Questions and answers on OOP:
http://stackoverflow.com/questions/tagged/oop