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
Info
|
[3821] A Twisted Look at Object Oriented Programming in C#
Last post 01-09-2007 10:08 AM by saurabhsri. 14 replies.
-
01-01-1999 12:00 AM
|
|
Advertisement
|
|
-
-
-
zip


- Joined on 08-29-2003

- Points 5
|
Quote:What a shame the author never learnt to use a sensible standard for naming variables.
...it is a good article and Microsoft does advocate clearer naming of Object variables.
It's a shame you never LEARNED proper grammer.
|
|
-
-
-
-
AlbertaSmith


- Joined on 11-05-2003

- Points 20
|
Very good analogy about interfaces. But ......why do we need them?
One of the questions that still persists for me, (and something I have never seen a discussion on) is what real benefit Interfaces offer; it seems they offer some, but that it is somewhat limited. Let me give an analogy, in the form of an old joke. An engineer, a phycicist and an economist were on a desert island with a can of pineapple that had survived the boat wreck. Both the engineer and the physicist made multiple attempts using their scientific knowledge to open the can of pineapple, but to no avail. After some time the economist remarked: "This shouldn't be a difficult problem to solve." "Well, tell us", replied the engineer and physicist in unison. Said the economist, " Assume a can opener."
This is what economists do. They make assumptions and think they have contributed something. Is this not like Interfaces, whose job, it appears, is to make policy statements without ever getting around to implementing anything? All the same amount of coding has to be done whether the interface is used or not; in fact there may be considerable duplication of code if minor changes to an implementation are needed. So what has been achieved? Not nearly as much, it seems, as inheritance would offer, were full inheritance of pure methods possible. This is perhaps why an Abstract class seems to be more useful.
I would appreciate anyone who can resolve my perplexity here. I could learn something.
|
|
-
-
PepeGSay


- Joined on 11-11-2003

- Points 5
|
Just another, analogy... more Interface explanatio
An interface allows a developer, but more specifically a designer, to say "These features must be implemented." It is then up to the developer to work out the details of how to deliver on those features/abilities. It creates a boundary of expectation from other users of the object.
They can say "Oh I i see it implements IInterface, therefore it will definitely have X, Y and Z". It is quite useful when you wnat to implement *concepts* in multiple objects instead of concrete functionality. For instance, say you had two types of collections one was a tree and one was a jagged array of parent/child IDs (which in many ways is a tree represented another way but they are syntactically different). If you wanted to implement something like "GetParent", you couldn't (well maybe you could, but go with me for the sake of example) implement one generic function for "GetParent" that would work for both the Jagged Array and the Tree. YOu could however have both objects implement an interface, and then have the developer do the syntactic details of returning an items parent.
Anyway, more half baked analogies.
|
|
-
-
-
rrios


- Joined on 12-19-2003

- Points 5
|
Inheritance is rigid. It´s like being born into the royal family. Sure, you get alot of privileges without doing anything, but you carry all the baggage and stigmas that come with your family name. You can´t JOIN the royal family. You have to be born into it.
Interfaces are democratic. A system that declares an interface is saying "I dont care who you are or how big or small you are: if you agree to these rules you may join the club". Think of your drivers license. The DVM declares an interface and ANYONE can use the road system as long as they stick to the rules (implement the interface).
In programming terms, suppose you are using two systems, in one you have created a Vehicle class and have several child classes like Car, Bicycle, and Bus. In the other you have cooking items, say for a recipe system. You may have classes like Flour, Eggs, Carrot. These two groups of classes have nothing to do with each other.
You create a third point of sale system for a retail store, and you plan to sell among other things, bicycles and flour. Your point of sale system could declare an IRetail interface that defines to other classes what they need to implement in order to participate in the Point of Sales system like Price(), TaxKey() and UPC().
This means you can reuse your Bicycle and Flour classes, just by adding the implementation of the IRetail interface in order to use them in the Point of Sale system. This new system will be capable of handling any kind of object as long as it implements IRetail.
So Interfaces are an advantage to both the system that declares the interface (they dont care what class of object they are handling) and to the classes that implement them (they can participate in any system as long as they agree to the rules).
|
|
-
-
-
-
pwbyrne


- Joined on 03-22-2004

- Points 5
|
Really good fast track article for OO concepts in
Moving from VB toC#? Looking for a lot of practical explanations of OO topics? Read this article. Really good OO 'shot gun' intro to using C# with OO methodology. This format should be used by publishers like O'Reilly to create a nice tidy OO break down, in a book. This kind of material, to the point, all in one spot, explanation is sadly missing from most OO explanations. The worst part about OO is buying into it. If you come from a non OO or just didn't really use OO background, like I did, your probably looking for the 'why' as much as the 'how'. This article, in what has to be said is few pages, really helped me see the worth and implementation of OO in C#. I think that that is because the author uses the whole development approach to explain topics. Meaning, not only is the raw abilities, the 'how' of OO shown (e.g like inheritance) but the author uses patterns to show the 'why'. This article finally flicked the old proverbial light switch for me. Obviously there is much more to OO than just how to program with a language that supports OO. For me the missing link, was the connection with patterns.
Read the article even if you work with OO, give it to people that are just starting OO.
I'd really like to see this article as the core of explaining more OO topics, in the same format.
|
|
-
-
-
Pkulek


- Joined on 06-22-2006
- United States

- Points 5
|
Re: [3821] A Twisted Look at Object Oriented Programming in C#
If you have tried developing large extensible business applications where data needs are in the gigabytes if not terabytes in any static OO based programming language, then you are in for a lot of headaches. OOP does not lend itself well to this type of development as so called real world objects do not translate well into OO objects, most so called real world objects in the business world translate to data. This fact is lost on many managers, developers and analysts.
Most applications in the real world are business related and not some academic project.
I have been privy to many failed projects because of the selection of high level development language invariably they have always been statically typed.
The one overlooked programming paradigm that has been neglected because of the OO hype is table or data driven programming. This form lends itself well to business related applications and can be used in conjunction with any programming paradigm but work wonders with a dynamically type languages. It is easily extensible, scalable and can be easily modified without throwing hundreds of users of the network.
As for Interfaces, function overloading, generics, templates, reflection, RTTI, default parameters, adding scripting etc, these are kludges to make a static language do what a dynamic language already does, and done badly at that.
|
|
-
-
saurabhsri


- Joined on 01-09-2007

- Points 5
|
Re: [3821] A Twisted Look at Object Oriented Programming in C#
thanks for the useful info
regards
|
|
Page 1 of 1 (15 items)
|
Search
Code Samples
New Members
|