Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 51,859 times

Contents

Related Categories

The Quick & Dirty .NET Guide to C#/VB OOP - Object Orientated Programming

DMarko1

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.

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 desktop applications. Till now Jimmy has authored nearly two dozen .NET articles, published on Dot Net Junkies, 4 Guys From Rolla, Sitepoint, MSDN Academic Alliance, Developers.NET, The Official Microsoft ASP.NET Site, and here on Developer Fusion, covering various unique and advanced techniques on .NET.

Comments

  • Re: [4341] The Quick & Dirty .NET Guide to C#/VB OOP

    Posted by Yoenuts on 25 Jul 2006

    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 ...

  • Re: [4341] The Quick & Dirty .NET Guide to C#/VB OOP

    Posted by ggorcsos on 22 Jun 2006

    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 ther...

  • Posted by James Crowley on 20 May 2005

    Though from personal experience I'd say 99.99% of the time, you'd want private member variables and public properties... ;)

  • Posted by DMarko1 on 22 Apr 2005

    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. - [url="http://www.developerfusion.co.uk/show/4676/1/"]Building a...

  • Confusion about this article (Get ,Set)

    Posted by aalhussein on 22 Apr 2005

    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 )
    W...