Categories: All - languages - inheritance - polymorphism

by Harol Rodriguez 2 years ago

170

Object Oriented Programming (OOP)

Object-oriented programming (OOP) is a paradigm that structures software design around data, or objects, rather than functions and logic. This approach focuses on the relationships and interactions between objects, employing techniques such as polymorphism, inheritance, and operator overloading.

Object Oriented Programming (OOP)

Object Oriented Programming (OOP)

Object oriented programming languages

C++
C++ is a programming language that comes from the extension of the C language so that it could manipulate objects
Python
Python is a high-level programming language used to develop applications of all kinds. Unlike other languages like Java or . NET, is an interpreted language, it is not necessary to compile it to run applications written in Python, but rather run directly by the computer using a program called an interpreter
Java
Java is a type of programming language and a computer platform, created and marketed by Sun Microsystems in 1995. Constituted as an object-oriented language, it is intended to allow application developers to write the program only once and run it on any device.

OOP TECHNIQUES

Now that you know the basics, and what objects are and how they work, you can spend some time looking at some of the other features of objects. This section covers all of the following:
Reference versus value types
Events
Operator overloading
Relationships between objects
Polymorphism
Inheritance
Interfaces

Why OOP?

Objects are able to interact and modify the values contained in their fields or attributes (state) through their methods (behavior).
It allows code to be reusable, organized and easy to maintain. It follows the software development principle used by many programmers DRY (Don't Repeat Yourself), to avoid duplicating code and thus create efficient programs.

How do you think of objects?

Thinking in terms of objects is very similar to how we would do in real life, for example we will think of a car to try to model it in a POO scheme, we would say that the car is the main element that has a number of features, such as color, the model or brand, also has a number of associated functionalities, such as starting, stopping or parking, in a POO scheme the car would be the object, the properties would be the characteristics as the color or the model and the methods would be the functionalities associated as to start or stop

In UML

The Unified Modeling Language is the best known and most widely used software system modeling language in use today; it is supported by the Object Management Group. It is a graphical language for visualizing, specifying, building and documenting a system.

OOP IN DESKTOP APPLICATIONS

In Chapter 2, you created a simple desktop application in C# using Windows Presentation Foundation (WPF). WPF desktop applications are heavily dependent on OOP techniques, and this section takes a look at this to illustrate some of the points made in this chapter. The following Try It Out enables you to work through a simple example.

Constructors

As well as fields, properties and methods, can be public or private. The code external to the fields, properties and methods of a class can be public or private. Code external to a class cannot instantiate an object using a private constructor; it must use a public constructor.