victor-gv / oop-basics

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OOP-Basics-Pill

What is object-oriented programming in general terms?

Objected-oriented programming is a model to organize the code of a software developer aorund data and objects rather than functions and logic. An object is a data field that has unique attributes and behaviour.

What is a class?

A class in objected oriented programming is a canvas to create objects where you define the variables and the methods (functions) that the objects are going to do. A class determine how an object will behave and what the object will contain.

What is an object?

An object, in object-oriented programming (OOP), is an abstract data type created by a developer. It can include multiple properties and methods and may even contain other objects. In OOP, the structure of an object is defined by classes.

What is an instance?

An instance is an object created from a class. To create an object from a class we use the "new" keyword. Class must be created prior to a instantiation.

What is a property?

The variables created in a class are call properties. A property is any data type (string, integer, array, object, etc). Before declaring a variable we should add the visibility keyword (public, private or protected).

What is a method?

Methods are functions inside classes. Their declaration are almost similiar to normal functions, except their special uses inside classes. We declare methods with visibility keywords.

What is the difference between a function and a method?

A method is on an object or is static in class. A function is independent of any object.

What is a constructor?

Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.

The destructor method will be called as soon as there are no other references to a particular object, or in any order during the shutdown sequence.

What is the difference between a class, an object and an instance?

A class is a blueprint which you use to create objects. An object is an instance of a class - it's a concrete 'thing' that you made using a specific class. So, 'object' and 'instance' are the same thing, but the word 'instance' indicates the relationship of an object to its class.

What do we understand about the concept of encapsulation?

In OOP encapsulation refers to a mechanism of restricting acces to some components of an object. For encapsulation we use visibility keywords (public, private and protected), we can use them for methods and variables.

What do we understand about the concept of abstraction?

In OOP, abstraction is a concept in which a class has methods without implementation. The idea is to have a template and let the child class that inherits the parent class implement the method.

What do we understand about the concept of inheritance?

Inheritance is one of the core concepts of object-oriented programming (OOP) languages. It is a mechanism where you can to derive a class from another class for a hierarchy of classes that share a set of attributes and methods.

What do we understand about the concept of polymorphism?

Polymorphism is one of the core concepts of object-oriented programming (OOP) and describes situations in which something occurs in several different forms. In computer science, it describes the concept that you can access objects of different types through the same interface.

What do we understand about the concept of Overload?

Function overloading or method overloading is a feature that allows creating several methods with the same name, which differ from each other in the type of input parameters. It is simply defined as the ability of one function to perform different tasks.

What do we understand about the concept of Override?

Overriding is an object-oriented programming feature that enables a child class to provide different implementation for a method that is already defined and/or implemented in its parent class or one of its parent classes. The overriden method in the child class should have the same name, signature, and parameters as the one in its parent class.

What differences exist between the concept of Overload and Override?

Overriding means, giving a different definition of an existing function with same parameters, and overloading means adding a different definition of an existing function with different parameters.

What is a static class?

A static class is similar to a class that is both abstract and sealed. The difference between a static class and a non-static class is that a static class cannot be instantiated or inherited and that all of the members of the class are static in nature.

Look for 3 advantages over object-oriented programming compared to other programming paradigms

  1. Modularity for easier troubleshooting
  2. Reuse of code through inheritance
  3. Flexibility through polymorphism
  4. Effective problem solving

Look for disadvantages of this paradigm.

  1. Steep learning curve: The thought process involved in OO programming may not be natural for some people, and it will take the time to get used to it.
  2. The complexity of creating programs: it is very complex to create programs based on the interaction of objects. Some of the key programming techniques, such as inheritance and polymorphism, can be a big challenging to comprehend initially.

About


Languages

Language:PHP 100.0%