Library tutorials & articles
The Quick & Dirty .NET Guide to C#/VB OOP
Object Orientated Programming
Object Oriented Programming is the concept of programming with objects. What are objects? The computer your seeing this on, the paper you may have printed this on, the printer, your car, TV, etc. are all objects, you get the idea. Moreover, they contain features as well as other objects within them as well. Now the great thing about .NET is that it is itself one huge object-oriented collection. Objects not quite like the ones we'll create and mention, but of a different kind, i.e. Data Objects, System Objects, String Objects, etc. However, unless the objects created are used in concert with other objects they defeat their true nature.
There are two good reasons why you would love programming OOP objects. One is that you have full control over how anyone would use the object you created, and two, encapsulation , in other words your hard earned OOP code is protected and hidden from everyone - systematized together. No one could modify it or change it, certainly anyone not qualified. They simply are available for a specific use, and this is key.
Take for example, if you build one great functional object that does all sorts of math computations, data retrieval and string formatting, and it's going to be used in your company. By not only compiling it, but also by virtue of programming it the OOP way, you protect your intellectual property long after you're gone.
OOP techniques promote the idea of reusability and further allow for all involved in knowing the object's uses, concealing the inner working of your code from inexperienced programmers, simply permitting the object its task alone.
In the old ASP/VB days, you would've had to have created a compiled COM component to realize some of the aforementioned benefits and any gains in performance. However, with .NET this isn't the case since the entire framework is compiled, every page and so forth. Thus building objects in .NET is that and so much more. You have the ability to create new super objects, modularize common code and design lightly coded, cleanly laid out pages. The bottom line is a strong, clean architecture from which stems greater productivity and fewer headaches. No wonder .NET's code-behind, template driven environment espouses all this!
In Object-Oriented Programming, you are dealing with objects. Now, when you embark on any new project you obviously hope in doing the least work possible. Consequently, upon any modifications to your project you don't have to make those changes a thousand times!
Aside from the examples we'll explore how these techniques can apply to everything you are going to work with. Take data access for instance, why not create a data-accessing object with properties whose parameters are the connection string and the query string? In turn, this could be placed throughout your application thus avoiding maintenance headaches and promoting a much cleaner design.
Related articles
Related discussion
-
hey developers out there
by pitsophera (0 replies)
-
How can i develop opc server using .net?
by vairajaig (1 replies)
-
Creating a Windows Service in VB.NET
by davidvanr (108 replies)
-
High-Performance .NET Application Development & Architecture
by Manjot Bawa (0 replies)
-
An Introduction to VB.NET and Database Programming
by carlosmen (14 replies)
Related podcasts
-
A Practical Look at Silverlight 2 Part 1
Now that Silverlight 2 is at the Olympics and making a big splash, we wanted to explore this fascinating technology more. Microsoft Silverlight 2 is a cross-browser, cross-platform, and cross-device plug-in for delivering the next generation of .NET based media experiences and rich interactive ap...
Events coming up
-
Dec
9
GL.net Group Meeting - December 2009
Gloucester, United Kingdom
The beginning of this year holiday season will belong to mocks. Ronnie and Stephen will take us for a tour around exciting world of unit testing.
hello,
I am very impressed by your tutorial as it finally allowed me to grasp the syntax behind OOP programming with .net.
Only what I did not understand is how and where do I complile the .cs to a dll? I cannot do it on the server. Do I do it on my local computer and then upload?
http://www.developerfusion.co.uk/show/4341/5/
Honestly I believe that the basic idea of the OOP was really great, but to be able to use it one really has to have the head as a water melon. There is too much theory, too many therms and the class theory really feels like puting each part of the program into a separate box and then figuring out how to drill a way between them. I started to learn C++ OOP at least 20 time and after a couple of weeks I did not even had an idea what it is about (note: I am not a proffesional programmer)...
I believe that: "The use of a programming language should be as simple as a pie and the algorithm should be the part where people spend the most of their time..."
When I do C# programming I do all public and it works great for me. Simply keep it simple!!!
Is there any web page or book where I could find how to do Non-OOP C# programming?
Sincerely,
Gabor Gorcsos
Though from personal experience I'd say 99.99% of the time, you'd want private member variables and public properties...
Hi Ehx,
That's true, and it's funny that in all my other articles I always write all private variables with public properties. i.e. - Building a Full-Featured Custom DataGrid Control. It's just one of those overlooked things. Oh well.
After reading your article, http://www.developerfusion.com/show/4341/6/
I got realy confused!!
from what I know from the book below, I declare private property, then declare public (get , set )
What you presented in your article is you declared public property,then made the (get,set) private)
I have put this simple comparison code , so please advice your point, What is the logic behind reversing the modifier(public to private and vis versa).
thanks
Ehx
// what is in the book (Begining Asp.Net Database using C# p 321)
private string Country;
public string Country
{
get{return _Country;}
set{Country= value;}
}
// what is in web article ( in your article)
public string Name;
private string _Name
{
get{return Name;}
set{Name= value;}
}
This thread is for discussions of The Quick & Dirty .NET Guide to C#/VB OOP.