DEV Community

Cover image for Object Oriented Programming
Eckehard
Eckehard

Posted on • Updated on

Object Oriented Programming

This is a submission for DEV Computer Science Challenge v24.06.12: One Byte Explainer.

Explainer

Class based OOP is a paradigm that uses classes as templates for reusable code modules (objects). Objects can have their own private data and functions. Inheriting child classes is the way to extend functionality while keeping the existing codebase stable.

Top comments (18)

Collapse
 
lincpa profile image
Lin Pengcheng • Edited

It’s better to have 100 functions operate on one data structure than 10 functions on 10 data structures.

---- Alan Perlis, the first recipient of the Turing Award (1966), a founding father of Computer Science as a separate discipline

So, the best object-oriented system is a system with only one object ---- warehouse/workshop model.

Collapse
 
jwp profile image
John Peters • Edited

Yes this would enforce the favor composition over inheritance theroy. However we see plenty of instances of inheritance which worked perfectly. Jusy look at the masiive C# class library.

The trick is to know the hard rules of what inheritance is and never misuse it. Tires aren't Cars, they are parts of Cars.

Collapse
 
efpage profile image
Eckehard

OOP is just a tool like a hammer or a circle saw. If you know how to use it, it can be most beneficial. But in the wrong hands or applied to the wrong task, using it can be dangerous. But a good craftsman (or craftswoman) can operate many tools.

Collapse
 
lincpa profile image
Lin Pengcheng

The most important point is that my theory is to give everyone a common way of constructing a system, according to which everyone can get a consistent optimal design solution under the same conditions. And it is possible to demonstrate the advantages and disadvantages of different design schemes in this way, without having to wait until the end of the project construction to find out that it is not good and cannot meet the needs.

Thread Thread
 
efpage profile image
Eckehard

Hello Lin Peng, your theory is a theory, and obviously not even a very good one:

Object-oriented and functional programming completely do not meet these three beauty requirements. The strange shapes and chaotic logic of OO&FP are not only unsightly, difficult to read and understand, and completely incompatible with the simple and repeatable requirements of industrial production. Source

I can fully accept that you do not understand these "strange shapes", maybe it was good to finish reading your books first. But what do you think you can give to the people if you do not have any practical experience at all?

By the way: your comment is off-topic. The question here is the quality of the explanation, not your personal preference about programming.

Collapse
 
efpage profile image
Eckehard

Are you a ruminant?

Collapse
 
lincpa profile image
Lin Pengcheng

I don't understand what you mean, and I'd love to get your scientific, logical, and well-founded evaluation of my theory.

Thread Thread
 
efpage profile image
Eckehard

Most of the common operation systems like Windows or Linux have been built using OOP methods, even the DOM features and OOP based approach. But you tell us: bumblebees canΒ΄t fly.

There are some theorists who think their theory is the only correct one. For me it is enough that it works practically.

Thread Thread
 
lincpa profile image
Lin Pengcheng • Edited

So we don't need to talk about science, mathematics, logic, we just need to conform to the herd or authority, we don't need scientific skepticism, we don't need independent thinking, so geocentrism is correct, Bruno should be burned, right?

Thread Thread
 
efpage profile image
Eckehard

No, we just know that bumblebees can fly.

Collapse
 
vivekanand_tulaskar_96a40 profile image
Vivekanand Tulaskar

Good .

Inheritance is a fundamental concept in OOP that allows one class (the subclass or child) to inherit properties and behavior from another class (the superclass or parent). The subclass inherits all the fields and methods of the superclass and can also add new fields and methods or override the ones inherited from the superclass.

Collapse
 
efpage profile image
Eckehard

If you are developing software, inheritance has a double effect:

Never change a winning team: Inheritance allows to extend functionality without changing the base class. This can be important to avoid unwanted side effects. If a class hierarchy grows, this can be a life saver.

DonΒ΄t repeat yourself: Not only the child class inherits new features, but also the childs of the childs. So, you try to create new features only once, while the whole family can benefit from the extension.

Well done, inheritance can make code much more maintainable. It is just not so easy to do things right here.

Collapse
 
jonrandy profile image
Jon Randy πŸŽ–οΈ • Edited

This isn't actually correct. You've described class based OOP, not OOP generally.

Collapse
 
efpage profile image
Eckehard • Edited

Do you think i should change my submission and call it "Class Based OOP"?

Collapse
 
jonrandy profile image
Jon Randy πŸŽ–οΈ

Probably

Collapse
 
neurabot profile image
Neurabot

And the inheriting child classes are from main classes.

Collapse
 
efpage profile image
Eckehard

Not necessarily. You can also use an abstract class to inherit from, but going into details would exceed the limit of 256 characters which were achieved exactly.

Collapse
 
neurabot profile image
Neurabot

Right.