Challenge: Learn Object Oriented Programming in Practice
The main objective is to put into practice one of the main tools of OO: ABSTRACTION, ENCAPSULATION, INHERITANCE AND POLYMORPHISM, through a Java project.
- Let's ABSTRACT the Bootcamp DOMAIN and MODEL its ATTRIBUTES AND METHODS
- We will create the CLASSES: Bootcamp, Courses, Mentorships and Devs and we will list them
- The Course, Mentorship and Devs CLASSES will also be MODELED, that is, we will create their ATTRIBUTES AND METHODS
- To make the code more readable and easier to maintain, we will use some of the tools that the OBJECT ORIENTATION PARADIGM (OOP) offers us: ABSTRACTION, ENCAPSULATION, INHERITANCE AND POLYMORPHISM
- And to represent CLASSES that were created and related, we will transform them into OBJECTS
Object Oriented Programming Paradigm (OOP)
The Object Oriented (OO) view is that of a world of interacting objects. This paradigm is an analysis, design and programming model based on the approximation between the real world and the virtual world, through the creation and interaction between classes, attributes, methods, objects, among others.
There are 4 main pillars of OOP: ABSTRACTION, ENCAPSULATION, INHERITANCE AND POLYMORPHISM.
ABSTRACTION:
Ability to focus on essential aspects of a domain, ignoring less important or accidental features. In this context, objects are abstractions of existing entities in the domain in question.
ENCAPSULATION:
Encapsulating means hiding the implementation of objects. Encapsulation mainly favors two aspects of a system: maintenance and evolution.
HERITAGE
Allows you to define a child class that reuses (inherits), extends, or modifies the behavior of a parent class. The class whose members are inherited is called the base class. The class that inherits the members of the base class is called a derived class.
POLYMORPHISM:
Ability of an object to be referenced in various ways. Be careful, polymorphism does not mean that the object keeps changing, on the contrary, an object is born of a type and dies of that type, what can change is the way we refer to it. The ability to treat objects created from specific classes as objects of a generic class is called polymorphism.
FUNDAMENTAL CONCEPTS POO
DOMAIN:
Application domain, also known as business or business objects layer, is where the classes that are part of the problem domain are located, that is, classes corresponding to objects that are part of the problem description.
CLASS:
An element of code that has the function of representing objects in the real world. Within it, it is common to declare attributes and methods, which represent, respectively, the characteristics and behaviors of this object.
ATTRIBUTE:
Attributes are basically the data structure that will represent the class. Attributes are also known as CLASS VARIABLE, and can be divided into two basic types: instance and class attributes.
VARIABLE:
A “previously identified memory region (of the computer) whose purpose is to store the data or information of a program for a certain period of time”.
METHOD:
Methods represent the states and actions of objects and classes.
OBJECT:
In OOP, an object is a "mold" of a particular class, which comes into existence from an instance of the class. The class defines the behavior of the object, using attributes (properties) and methods (actions). Object in computer science, is a reference to a memory location that has a value. An object can be a variable, function, or data structure.
INSTANCE:
An instance of a class is a new object created from that class, with the new operator. To instantiate a class is to create a new object of the same type as that class. A class can only be used after being instantiated.
Programming Language vs Programming Language Paradigm
PROGRAMMING LANGUAGE:
It is a formal language that, through a series of instructions, allows a programmer to write a set of orders, consecutive actions, data and algorithms to create programs that control the physical and logical behavior of a machine. Here are some examples of how programming languages can be classified:
Abstraction level:
Low Level: Assembly Medium Level: C, C++, D, Objective C, etc. High Level: Java, C#, PHP, Javascript, etc. Highest Level: Python, Ruby, Elixir, etc.
Programming paradigm:
Structured Programming: C, Pascal, Ada, etc. Object Oriented Programming: Java, C#, C++, Objective C, D, etc. Functional Programming: Lisp, Scheme, Erlang, Elixir, etc.
Languages classified by application architecture:
Desktop: C, C++, Object Pascal, Java, etc. Web: PHP, Ruby, Javascript, Java, etc.
Type of execution:
Compiled languages: C, C++, Pascal, D, GO, etc. Interpreted Languages: Python, Ruby, PHP, Javascript, etc. Hybrid Languages: Java, Erlang, Elixir, etc.
PROGRAMMING LANGUAGE PARADIGM
It is a set of characteristics that can be used to categorize a given group of languages. A paradigm may offer appropriate techniques for a specific application.
MAIN PARADIGMS and THEIR SUBPARADIGMS
Imperative Paradigm
In this paradigm, the program describes the processing required to solve the problem. Thus, the imperative paradigm is characterized by sequential execution of instructions, by the use of variables that represent memory locations and by the use of assignment instructions that change the values of these variables. Let's look at some Imperative Paradigm Subparadigms and examples of programming languages that adopt these subparadigms.
1.1 Structured Paradigm: ALGOL 58 and ALGOL 60
1.2 Concurrent Paradigm: Java and Ada
1.3 Object Oriented Paradigm: Smalltalk and Java
2. Declarative Paradigm
This paradigm is the model in which the results are described, but the steps to arrive at the results are not established. Let's look at some Declarative Paradigm Subparadigms and examples of programming languages that adopt these subparadigms: