Programming

Object Oriented Programming Javascript: Definition

The diversification of the fields of application of programming, gave rise to various types of languages. In this article we will discover what object-oriented programming is and what types of object-oriented programming languages ​​exist. Dare to expand your knowledge! object oriented programming javascript

Object Oriented Programming Javascript

object oriented programming javascript
object oriented programming javascript

Unlike Smalltalk and Java, it is a language that relies on prototyping or examples. It is interpreted and without types, that is, it does not perform type checks either at run time or at compile time. Creates objects in the dynamic memory area at run time. Since it lacks compilation, it becomes a dynamically checked language. object oriented programming javascript

It is a powerful language, thanks to its portability and integration, as well as its standard and simple programming techniques. In other words, JavaScript is a code that is embedded in a web page, the purpose of which is to improve the dynamism of that page. object oriented programming javascript

Object-oriented programming

In general, programming requires knowledge of a language in charge of transmitting commands to the computer, and an algorithm converted to a program, but what is programming?

Programming is a set of actions that lead to the writing of a code, capable of fulfilling the objective for which it was created. For its part, a source code is the internal representation of a program or software, and a program is a group of orders that govern the operation of computers.

Basically, a program goes through three stages: the editing of the program in a suitable language, the transformation of the source code into instructions for the machine, and the linking between the object codes and the function libraries, giving rise, finally, to what it is known as executable code.

A program must be written in a programming language that is understandable to the user. For this to happen, the programmer must adopt one of the many existing programming paradigms, which determine the vision and, therefore, the choice of the methods to follow in the construction of the same.

Programming paradigms

Advances in programming and technology have given rise to various programming methodologies or paradigms. These, in turn, have led to different styles of programming and different forms of problem solving. Here are the existing paradigms:

object oriented programming javascript
object oriented programming javascript

Imperative paradigm object oriented programming javascript

It states that programs are a strict sequence of instructions from top to bottom, which is only interrupted by the inclusion of a subprogram somewhere in it.

Structured paradigm

It enforces code structures grouped by blocks of procedures and functions. The code is reproduced in the form of a loop, dominated by a logical reason.

Declarative paradigm object oriented programming javascript

It does not establish the order to follow in carrying out the actions necessary to solve a problem. Within it, two types are distinguished: the functional paradigm, where the problem and the solution are described as functions, and the logical paradigm, based on a logical predicate.

Event programming paradigm

It is based on infinite iteration to detect the problem and establish how to solve it.

Parallel, distributed and concurrent paradigms object oriented programming javascript

The realization of the program requires several units of calculation. The routines run independently on other computing units.

Object-oriented paradigm

This type of programming is based on three basic principles: data encapsulation, object abstraction, and type checking according to the class hierarchy.

It is important to note that a programming language does not usually respond only to one paradigm, but can be the result of the combination of several types of them. However, below we will dedicate ourselves in detail only to defining what object-oriented programming is and what are the different object-oriented programming languages that exist. object oriented programming javascript

Qualities

It is the most widespread paradigm today, because it allows better management of complexity at a reasonable cost. Through it, the possibility of building in parts is proposed, that is, dividing the work based on components, which results in robust, portable and reusable applications, with long-term benefits.

Unlike other types of programming, object-oriented programming looks for parts in entities that arise from the problem domain, and not within the problem solution itself. The primary requirement is that each component behaves in an expected way, such that our development is not affected by the way it is implemented, and that we can know a priori the conditions offered by each component, as well as how to connect. with the. object oriented programming javascript

From another point of view, we can mention that object-oriented programming is related to the theory of knowledge, which states that man stores information according to predetermined schemes, the product of his experiences as a person. In this way, this type of programming makes it possible to represent knowledge in a heuristic or theoretical way, through the individual’s mental schemes, making use of previous knowledge stored in information units.

Source object oriented programming javascript

Object-oriented programming is a technique, style or methodology developed in the 1960s, as a result of the crisis generated by the impossibility of changing or modifying complex programs. Situation that was getting worse and worse due to the lack of specialized personnel willing to give maintenance to the programs.

The momentary solution to this crisis was in the hands of structured programming, which consisted of breaking down the programs into individual procedures that would perform specific tasks separately. This brought with it other drawbacks, generated mainly by how difficult it was to achieve coordination between the many developers who were involved in a project, since the greater the number of tasks involved, the greater the number of programmers. object oriented programming javascript

Without a doubt, the main disadvantage of this type of programming was the need to conceptually separate the data from the codes. A situation that was directly worsened by the size and complexity of the program.

Thus, in order to reduce the complexity of programs, object-oriented programming was born. Its main advantage is that it makes it possible to build complex programs using simpler objects. These objects make up the entities of the software oriented under this methodology. The ability to inherit both data and code from existing applications improves developer productivity. Likewise, it makes it easy to extend and reuse classes in other applications, without having to greatly modify the original code. object oriented programming javascript

features object oriented programming javascript

Object-oriented programming has multiple qualities, here are the main ones:

  • The basis of object-oriented programming is classes, not algorithms. These make up logical building blocks.
  • Each object is an instance of a class.
  • A program is perceived as a means to send and receive messages, through a set of objects that react to each other.
  • Each object must seek the best way to respond to each message received.
  • Each object may respond to messages in different ways.
  • It makes it easy to change the software because the components are interchangeable.
  • Partial and internal changes do not affect the behavior of the rest of the system.
  • If the basic principles of object-oriented programming are followed, the cost of building the system will be less than in cases where the parts are interdependent.
  • It is possible that classes derived from others inherit the knowledge and skills of their predecessors. Through inheritance, the classes are related to each other, and the way of working is exploited without the need to rewrite the code.
  • The methods of a class can do different things, even if they keep the same name. That is, through polymorphism, the programmer can implement several forms of the same method, depending on the class on which the implementation is made. This means that multiple methods can be accessed by the same name or access medium.

Differences: structured programming vs. Object-oriented programming

As we have already mentioned, object-oriented programming represents the evolution of structured programming, which does not mean that it is better than it, since each one has its utility depending on the type of system that will be developed. The basic differences that exist between the two are established below: object oriented programming javascript

Structured programming solves algorithmic problems, starting from the introduction of some data, an output is generated. Object-oriented programming is based on object modeling, very useful in the development of web applications.

The first focuses on a data structure, while the second is based on objects, with its own state and behavior.

The information within structured programming flows through structures and calls to functions, in object-oriented programming it is the result of the interaction between them, by sending and receiving messages. object oriented programming javascript

Basic principles

As a consequence of the concept of object-oriented programming, three basic principles of this paradigm emerge. These are:

Data encapsulation object oriented programming javascript

As we have already mentioned, objects are expected to know how to respond to the messages they receive, showing specific behavior. However, what we do not want is that whoever sends the message knows how they do it. The achievement of this objective is what is known as encapsulation of the data. In other words, what you want is that each part of the program knows only what interests it, thus avoiding collateral effects related to other objects. object oriented programming javascript

In short, with the encapsulation of the data, access to the components of the objects is impossible, that is, these are protected within a single well-defined programming unit, because each of them have design specifications that make them independent of each other.

The main reason why we may want the client object to ignore the way of implementation is that, generally, there can be several alternatives for the same operation. In addition, in the future, we may decide to change from one alternative to another, without the client knowing about it or the provision of the service being affected. object oriented programming javascript

Object abstraction

An essential characteristic of object-oriented programming is that it seeks to attack the problem in parts. In this way, the first thing it does is find the objects, then determine how they should interact and, finally, implement their behavior. Consequently, we have that the objects that we find are the ones that will help us solve the problem.

Abstraction involves two types of knowledge, data or variables, which constitute the mental scheme, and methods, functions or procedures, which relate said scheme to other predetermined schemes. That is, thanks to data abstraction, the domain and structure of the data can be defined, as well as the methods to access them can be established. Finally, the abstraction becomes a new type of data defined by the programmer, made up of attributes and methods that are applied to the former.

Due to the existence of multiple mental schemes for the same problem, each programmer can organize the classes in different ways, according to his personal perception. What he means is that object abstraction is the ability within the program design to create user-defined data.

Type check according to class hierarchy

This is when you choose the language to do type checks. There are languages ​​that decide to do it during compilation, and others during execution. Other languages ​​don’t even compile, which doesn’t give you the opportunity to do checks of any kind, until runtime.

When the check is done at run time, it is called a dynamic check. In contrast, when done at compile time, it is called static checking.

Due to the fact that in the static check the errors arise from the beginning, without reaching the moment of the execution, it is often said that this type of check is more secure. However, dynamic testing allows for partial implementations, without the need to repeatedly rewrite the code.

How does it work?

The first step to solve a problem under this paradigm is to find the objects or entities of the problem domain. Then it is necessary to find the way how these entities interact to solve the problem, establishing the messages that the objects send, in what order and under what conditions they do it. Finally, you have to implement the behavior of the objects, referring to the response they give with respect to the messages.

In summary, when a program is executed under the object-oriented programming paradigm, three things happen: objects are created as needed, messages flow from one object to another parallel to the information processing by the program, and when objects are no longer required, they are deleted to free up memory in the system.

Key concepts

In order to understand a little more about what object-oriented programming is, it is necessary that we mention the following basic concepts:

  • Object: It refers to the entity that can be a recipient of messages, while it can respond to them and send messages to other objects. It is the entity that has behavior.
  • Identity: It is the aspect that distinguishes one object from another.
  • Message: This is the resulting interaction between an entity that requests a service and another that provides it.
  • Client object: It is who sends the message.
  • Receiver object: It is the object that receives the message.
  • Delegation: Referring to the sending of messages from an object to other objects. When an object needs the collaboration of others to be able to respond to messages.
  • Behavior: They are the responses to the messages received by a receiving object.
  • Status: Referred to the current situation of each object.
  • Responsibility: It is the interaction between the state and the behavior of an object.
  • Method: It refers to the implementation of the response given by an object to a received message.
  • Polymorphism: This is the ability of some objects to respond to the same message, but in several different ways.
  • Classes: They are sets of objects that behave in the same way. They can be defined by the programmer. They are mental schemes that allow objects to be abstracted and to determine how to relate to each other.
  • Attribute: It refers to an internal variable of the object created to store part of its state.
  • Contract: Referred to the knowledge of what each component offers and the way to connect with it.

Troubleshooting based on object-oriented programming

Once the problem has been identified and the possible solution is proposed, it is required to transcribe it into a programming language so that it can be executed by a computer, through the use of a program. Under the methodology of object-oriented programming, the following stages are defined:

  • Definition of the program: It deals with the schematic description of the problem, in a clear, understandable and well-defined way. It involves the identification of the origin and the aspect of the data to be processed, as well as the description of the results and the way in which they will be presented.
  • Object-oriented analysis and design: Refers to the identification and description of objects in the problem domain. After which, the attributes, relationships and methods to follow are established, this in order to define the classes that will be implemented in a specific programming language.
  • Programming: Basically, it refers to the transcription of the program, which includes correctly writing the code in a programming language, using a development style capable of guaranteeing the quality of the product, which will cause the proper resolution of the problem. This stage involves the construction of algorithms, the elaboration of flowcharts and the final programming, going through the desktop tests, the coding, compilation and execution of the program.
  • Documentation: It involves the description of the sequence of steps necessary to reach the resolution of a problem. It involves the incorporation of comment lines that clarify or explain the meaning of the code lines that could be confusing, especially those referring to identifiers and declared data structures, control structures and methods and their parameters. This stage is essential for the success of the final product, because if the documentation fails, the programs are difficult to read and debug, and even more so, their modification and maintenance becomes almost impossible.

In another vein, we can say that the functionality of programming languages ​​has increased over the years, mainly due to the appearance of new and varied fields of application. Although it is true that at the beginning these languages ​​were used, basically, to handle large amounts of data and perform certain numerical calculations.

Now programming languages ​​are used in almost any field of society that includes database management, image generation and even artificial intelligence, among many other aspects.

Mainly, the birth of new software engineering technologies has caused the rise of the programming languages ​​that we will see below.

Object-oriented programming languages

They are languages ​​designed to integrate data and applets into classes. These can inherit properties of other transformed codes and give rise to new characteristics, which also lead to a new programming methodology.

Classification

As we will see later, there are multiple programming languages ​​that respond to the object-oriented paradigm. According to their way of implementation, they are classified as:

  • As they implement the behavior: It covers the languages ​​that are based on classes and on prototypes or examples.
  • As they implement object creation: They are based on the execution time in the dynamic memory area or the compilation time of the stack.
  • According to type checking: Refers to compile-time verification or run-time verification.

Among the main object-oriented languages ​​we have:

Smalltalk

It can only be programmed under the paradigm of object-oriented programming. It is a class-based language, which designs objects in the dynamic memory area at run time. It only does type checks at runtime, that is, it is a dynamic checking language.

Java

It is one of the most used languages ​​today, it is completely object-oriented, with syntax similar to C and C ++. It is platform independent.

Like Smalltalk it is a class-based language, which creates the objects in the dynamic memory area at runtime, but does not do type checks at runtime, but rather at compile time, with the difference that it creates a intermediate non-executable code, coming from a precompile. This makes it a static checking language.

Java object-oriented programming runs on a virtual machine specialized in this type of language, which works as if it were a computer and, therefore, allows their execution without the need to modify them. This type of machine is what is called an interpreter.

C ++

It constitutes an increase to the traditional C language, by absorbing the benefits of this language and incorporating supports for objects. Although it encompasses three different programming paradigms, such as: structured programming, generic programming and object-oriented programming, it was he who led the transition from the structured paradigm to the object-oriented paradigm.

It is a versatile language, used very frequently among application programmers, both in Windows and in GNU Linux. Creates objects in dynamic memory at run time. It basically focuses on performance, portability, and abstraction. Its main disadvantage is that when compiling, an executable file is generated whose code is valid only for the platform where the compilation was made. On the other hand, being an executable language, it is not platform independent.

C #

It is a programming language that runs at runtime and is included within the .NET platform, which allows you to share and recognize your libraries. It is totally object-oriented, allows the creation of all kinds of applications.

It constitutes an evolution of the C and C ++ languages, eliminating the complexity of the latter, since it is easier to use and reduces the margin of error during its operation, due to the acceptance of precompilation.

Python

It is a multiplatform language, mainly object-oriented, but encompasses other paradigms such as imperative programming, functional programming, and aspect-oriented programming.

Its clean syntax, very close to natural language, favors the reading of its code. It is highly recommended to start in the world of programming.

It is executed through an intermediate program, that is, through an interpreter. Because it is a semi-interpreted language, it is flexible and portable. It is dynamically typed, which means that the data type is determined at runtime.

Pascal

At present, it is the language used par excellence in the teaching of programming. It has a simple syntax, with a highly structured language, which facilitates the reading and interpretation of the programs. Its compilation can be done on any machine that has a Pascal compiler.

Despite being a structured language, it allows object-oriented programming through its Turbo Pascal version. It has an integrated environment, from which it is possible to write the programs and test them. Ultimately, Pascal is a general-purpose language.

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button