3

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 inheritance,is this is object oriented(because the language is object oriented) or not?

asked Jun 23, 2011 at 6:42
2
  • 1
    What's the issue with not programming in an object-oriented way using an "object-oriented" language? Commented Jun 23, 2011 at 6:44
  • @Alex: +1. I didn't get the memo about OO being the only acceptable paradigm (in C# or anywhere else). Commented Jun 23, 2011 at 6:51

6 Answers 6

11

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.

answered Jun 23, 2011 at 6:50
1
  • 5
    For reference, Grady Booch invented the "Booch method" (which was eventualy absorbed into UML), and wrote the foreword for the GoF book. Just saying...you picked a heck of a guy to disagree with about OO. :) Commented Jun 23, 2011 at 7:01
4

All classes in C# inherit from object so yes its object oriented :)

answered Jun 23, 2011 at 6:44
2
  • This is more a case of purity. You can go the Java route (primitives and objects) simula (no primitives) or C# (lets make primitives look like objects even though they aren't.) Commented Jun 23, 2011 at 6:46
  • 1
    Documentation for object base class : msdn.microsoft.com/en-us/library/9kkx3h3c(v=VS.100).aspx Commented Jun 23, 2011 at 6:51
3

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.

answered Jun 23, 2011 at 7:01
2

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

Jalal Said
16.2k8 gold badges47 silver badges68 bronze badges
answered Jun 23, 2011 at 6:45
1

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.

answered Jan 10, 2012 at 18:39
3
  • I agree with the part about *Composition over Inheritance Commented Aug 10, 2017 at 19:49
  • Of course not everything should be OOP. It is a technology not a universal panacea. Commented May 20, 2022 at 2:02
  • @SamanthaAtkins Totally agree. I was just suggesting not calling it OO code if you aren't doing OO, C# has the ability to use other development paradigms. Commented May 20, 2022 at 2:46
0

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.

answered Jun 23, 2011 at 6:45
2
  • you are using - but not necessarily doing - have a look on my answer. Commented Jun 23, 2011 at 22:46
  • So when I create a SqlConnection class and then create a connection this isn't OOP? Thats what I meant, the .Net framework is designed using OOP, so if you use it you are inherently using OO. However you can then create a procedural mess of static methods on top of that if you feel so inclined. Commented Jun 23, 2011 at 23:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.