All Applications developed using c# are not object oriented?
According to Grady Booch "Object oriented analysis and design", programming without inheritance is not object oriented that is called as programming with abstract data types. if am developing one application using c# with some classes with out inheri开发者_JAVA技巧tance,is this is object oriented(because the language is object oriented) or not?
Object-oriented programming is the concept of using objects, e.g. classes, structs with fields, properties and methods to encapsulate programming logic.
Inheritance is a feature of many OO languages, but not a necessity. The ommitance of that feature, doesn't make an OO language a non-OO language. So, I don't agree with Grady Booch's understanding of what OO is.
If you're programming with C#, you're using an OO language, you can't get away from that as everything inherits from System.Object
at least.
All classes in C# inherit from object so yes its object oriented :)
Refering to Object-oriented programming:
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance. Many modern programming languages now support OOP, at least as an option.
Simple, non-OOP programs may be one long list of commands. More complex programs will group lists of commands into functions or subroutines each of which might perform a particular task.
In contrast, the object-oriented approach encourages the programmer to place data where it is not directly accessible by the rest of the program. Instead the data is accessed by calling specially written functions, commonly called methods, which are either bundled in with the data or inherited from "class objects" and act as the intermediaries for retrieving or modifying those data.
An object-oriented program will usually contain different types of objects, each type corresponding to a particular kind of complex data to be managed or perhaps to a real-world object or concept such as a bank account, a hockey player, or a bulldozer.
Objects can be thought of as wrapping their data within a set of functions designed to ensure that the data are used appropriately, and to assist in that use.
So, inheritance is a key consept of the OOP but still you can write OOP applications without using it.
If you have developed some or one classes there is Object Oriented Programing , C# is the full OOP Language if you don't use inheritance by default your classes derived from base class object. There is no problem if you don't use inheritance any way if you create classes and object there is OOP design
There are many ways to look at it--everyone has their own definition of "Object Oriented".
To be an effective OO programmer, polymorphism must be a part of your toolkit, it's too useful to ignore--not only that but you should be able to use it effectively which means also making use of encapsulation over inheritance whenever possible.
It also means creating objects that have methods that modify their data before methods that hand up data to another object to be modified (Property style coding is bad OO in other words)
I guess I'm saying that you shouldn't force using inheritance all over the place but it's useful enough that if you aren't using it beyond everything inheriting from Object you really shouldn't be calling your code OO--this is true even of fairly small apps.
You can write bad code in any language...
Seriously though, if you are using the .Net framework with C# then this is built strongly on OOP principles. Every time you use a collection, windows forms, WCF any of the multitude of classes in the framework, you are using OOP.
精彩评论