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.

You might also like...

Comments

About the author

Dimitrios Markatos

Dimitrios Markatos United States

Dimitrios, or Jimmy as his friends call him, is a .NET developer/architect who specializes in Microsoft Technologies for creating high-performance and scalable data-driven enterprise Web and des...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There are 10 types of people in the world, those who can read binary, and those who can't.”