7 Programming Concepts Everyone should Know
In this post, we will discuss about :
- Classes and Objects
- Static Methods
- Libraries/Modules/Packages (All mean the same thing)
Classes and Object:
A class is a blueprint for creating objects . It has member functions and member variables . and an object is an instance of class . One can access class member functions and variables with the help of object .
It is a special method that is used to initialize the newly created object and is called just after the memory is allocated by the object.
source : https://gist.github.com/karanjagota/3fbbb2e8fdc28d5231d9fd3194fa7ac1
Static Methods / Static Functions
They are indeed one of the most important methods that i use . They belong to the class itself. They can be used without the instance (object) of a class. They don?t modify the behaviour of our class but is very powerful when want to view certain data etc Just add static in-front of a function .
Recursion is a technique where a function calls itself . Their is a termination condition called the base condition which stops the recursive action .
source : https://gist.github.com/karanjagota/96efdd7351812fd568cd219951f2d0c8
Loops in programming languages is a feature which facilitates the execution of a set of instructions repeatedly while some condition evaluates to true.
OOPS (Object Oriented Design)
It is a methodology or paradigm to design a program using classes and objects. Main Components of OOPS are Encapsulation , Abstraction , Inheritance and Polymorphism . Lets look at them closely ?
Encapsulation: Encapsulating every thing about an entity inside a class. ie. Putting functions and data members inside a class.
Abstraction: Abstraction is a very important concept in oops . It simply means that you are hiding the important things inside the class and provides only the necessary or relevant information that you want to show through a object . (It hides the details of implementation)
Inheritance : It is a concept where a class acquire properties of a child class . We can extend this child class and use already defined methods that are in the base class / Parent class . The main purpose of inheritance is to provide reusable code and help you achieve DRY
source : https://gist.github.com/karanjagota/1811a5e29eea42cb0d8af38db1996634
Polymorphism: It generally means ability to take many forms . There are generally 2 types of Polymorphism ? compile time and run time .
- Compile time : Function Overloading is an example of compile time polymorphism. Same function name different parameter data types .
- Run time : Function Overriding is an example of run time polymorphism . Let?s look at an example.
source : https://gist.github.com/karanjagota/9f780c9deed338ae1f8504577f895cc8
Library / Package / Module (All mean the same thing ):
It is just a function or list of functions that are wrapped around or are written for repetitive work . Generally, SDE either worked with libraries or they create their own . Automating the boiler plated code .[ Most Important ]. Every programmer should know how to create a library else he would spent a lot of time in writing same code again and again and again and again ?.
That?s it for this post. I hope you liked it . Once again, thank you for taking your time and reading this post. Good bye | Take Care | and keep coding ..
and Don?t forget to Clap Share and Follow .