Four Basic Principles of Object-oriented Programming(OOP), Abstraction, Encapsulation, Polymorphism, Inheritance

I am sorry about next three paragraphs. Because, I wrote too much. If you don’t have time, you can skip them directly 🙂

The four principles of OOP are entry point to build a well designed OOP applications. You definetely need to know whether you are a junior or senior developer to write an effective code. Before telling about them, I just want to tell why you need to know them. Probably, you already use some of them even without knowing principles. But, when you know them, you will have a higher perspective and more confidence related with complex codebase(Projects). Because, writing a class is not difficult at the beginnig but when you have more complex codebase, it will be difficult to maintain development if you don’t apply some patterns and principles. Furthermore, it is a common language between software engineers. So, easy to communicate and easy to design complex applications. They are also not dependent to any programming language like Java, C#, Python etc. If you know and understand what they mean, then you can definetely benefit from them to build an application. By the way, some developers named as different naming convention like basic principles of OOP, main concepts of OOP, basics of OOP, basic concepts of OOP, etc 🙂 But all of them are mentioning about same things Abstraction, Encapsulation, Inheritance and Polymorphism.

Novadays, developers have to be very pragmatist because of the market. They need to learn and use new stuffs very quickly. For example, I read every time about new frameworks. Although I don’t develop any project with new framework, I spend my time to become ready on the software market. So, it is difficult to work and think on some basic concepts due to lock of time. But, I realized that I spend too much effort for every new framework or library to understand. When I anlyze different open-source projects for weeks, I had my way of exploring the projects in a time. This means that I want to follow same way every time unconsciously. It is very very funny 🙂 because I tried to create basic principles and patterns in my way unnecesarily. I every time try to find some key points. But, there is more funny side as well. Developers of open source projects were already applying basic principles. That is why, many developers could work together. In this case, I have learned many principles and patterns unconsciously. Finally, I learned the existence of basic concepts or principles of OOP :))))

Unfortunately I was not only one person who makes same mistakes in the market. Developers who have different experience still don’t know or care for significance of OOP principles. This doesn’t mean that they are not good developers. Many of them were developing complex projects with well known frameworks like Spring Boot, Express Framework, etc. But, they just copy and paste codes from tutorials generally. Big frameworks are making development easer and safer. So, we don’t need to think for low level details for our applications and just need to think about business logic. So, it is decreasing development cost and increasing efficiency for the organizations(companies). But, in this case, developers are becoming lazy in a time and don’t want to spend time to learn or even remember about basic principles of OOP and some common software patterns. Anyway, I decided to write this post for myself. I hope that some developers will benefit in the future as well 🙂

There are four basic principles of OOP as below;

  1. Abstraction
  2. Encapsulation
  3. Polymorphism
  4. Inheritance

I read many different posts about them so I will write different versions of definitions that I took note and you can decide which one is more clear to you 🙂 They are not my sentences. I don’t want to create a new one. I just want to show the way of my thinking.

Continue reading

JavaScript Hoisting

This topic is very very important in javaScript. It is an unknown behavior of javaScript. Shortly, javaScript compiler moves variables and function declarations

Hoisting is JavaScript’s default behavior of moving declarations to the top of the current scope.

Variables and constants declared with let or const are not hoisted!

JavaScript Declarations are Hoisted

In JavaScript, a variable can be declared after it has been used.

In other words, a variable can be used before it has been declared.

Hoisting applies to variable declarations and to function declarations.

function declarations are hoisted before variable declarations.

Continue reading

JavaScript Functions

I sometimes try to remember basis of JavaScript Functions. So, I often exercise about it. I followed this link https://www.w3schools.com/js/js_function_definition.asp. I copied some important descriptions from that link. My aim is to follow this post when I need to remember again 🙂

JavaScript Functions

A JavaScript function is a block of code designed to perform a particular task.

A Function is much the same as a Procedure or a Subroutine, in other programming languages.

Why Functions?

You can reuse code: Define the code once, and use it many times.

You can use the same code many times with different arguments, to produce different results.

JavaScript Function Types

  1. Function Declaration (function statement)
  2. Function Expression
  3. Function Constructor
  4. Self-Invoking Function (Immediately Invokable Function Expression IIFE)
  5. Arrow Function
  6. Object Method Shorthand Definition
  7. Generator Function

JavaScript Function Syntax

Function parameters are listed inside the parentheses () in the function definition.

Function arguments are the values received by the function when it is invoked.

Inside the function, the arguments (the parameters) behave as local variables.

1. Function Declaration (function statement)

When a function declaration is created, a variable named as function name is created as well. This variable is hoisted top of the current scope. In other words, variable is moved to top of current scope. This means that the function can be called before the function declaration

Continue reading

LoopBack 3 – Simple API with Oracle Example

Expose your Oracle Database as a REST service with LoopBack 3 (Node.js Open API Framework)

This post is continuation of previous post https://kenanhancer.com/2019/09/09/loopback-3-simple-api-example/

So if you want to start from beginning, read that one as well.

Follow this link https://kenanhancer.com/2019/09/12/mysql-docker-container-exercise/ to create a Oracle container 🙂

You can find LoopBack 3 project in the following repository. After clonning switch to oracle branch 🙂 or run the following command.

git checkout oracle

https://github.com/kenanhancer/loopback3-simple-api.git