6. Types of Memory Allocation.



Hello folks!
Welcome to this blog series. In the previous blog we have studied classes and its different types. Now in this blog we will see the different types of memory allocation
Types of memory allocation :
Memory is required by any program so as to store the data and process it.
         
          
The memory allocation done by the compiler is of three different types namely –
1.Static memory allocation :
This type of memory allocation is done whenever a variable is declared as static or global. Each static or global variable defines one block of space, of a fixed size. The space is allocated when the program is started and is released only after the program is completely executed.

2.Automatic memory allocation :

This type of memory allocation is done when a local variable or function argument is done. The space for automatic variable is allocated whenever the compounded statement containing the declaration is entered and the space is allocated until the scope of the respective function remains.

3.Dynamic memory allocation :
Dynamic memory allocation is a technique in which programs determine as they are running where to store some information. You need dynamic allocation when the amount of memory you need, or how long you continue to need it, depends on factors that are not known before the program runs. – gnu.org


Why we need Dynamic memory allocation ?
1.    When we do not know the amount of memory that would be required by the program.
2.    When we do want data structures without any upper limit of memory space.
3.    When we have a fixed size of memory available for running which is not enough to execute the program correctly.
4.    When you want you to use the concept of structures and linked
list in programming, dynamic memory allocation is a must, etc.

Space complexity graph

Time complexity graph


From the above graphs it is clearly visible that the memory allocation requirements required by dynamic memory allocation is certainly small compared to static memory allocation. Hence, in our program we have tried to use dynamic memory allocation wherever possible which makes the program more efficient on space complexity rather than time complexity.
Now we have studied the different types of memory allocation, so in the next blog we will see how to use dynamic memory allocation in C++

References:

https://stackoverflow.com/questions/322715/when-to-use-linkedlist-over-arraylist-in-java

By-
Ashutosh Bardapurkar    (k-05)
Hrishikesh Deshpande    (k-16)
Archit Hiwrekar        (k-23)
Chinmay Kapkar    (k-33)






5. Introduction to classes.





Hello folks!

       Welcome to the blog series. In the previous blog we have studied the different types of variables that we are going to use in our object oriented programming (OOP) project.
       Now in this blog we will discuss about Class and different topics related to it. 
       A class in C++ is a user-defined type or data structure declared with keyword class that has data and functions (also called member variables and member functions) as its members whose access is governed by the three access specifiers private, protected or public. By default access to members of a C++ class is private. The private members are not accessible outside the class; they can be accessed only through methods of the class. The public members form an interface to the class and are accessible outside the class. -Wikipedia.
       Instances of a class data type are known as objects and can contain member variables, constants, member functions, and overloaded operators defined by the programmer. -Wikipedia.
Classes are defined using either keyword class or keyword struct, with the following syntax:

class class_name {
  access_specifier_1:
    member1;
  access_specifier_2:
    member2;
  ...
} object_names;

       The syntax for defining a class is similar to that of defining a structure in C.
       Here the class_name is the identifier for the class (basically the name of our class), object_names is the list of names for objects of this class (optional). The body of the declaration can contain members, which can either be data or function declarations, and optionally access specifiers.
       The access specifier can be one of the following three keywords: privatepublic or protected. (As discussed in earlier blog).
       Any member that is declared before any other access specifier or without any access specifier has private access automatically.
Let us see an example of it.


The output of above code is 

       Classes allows both Data and functions as members of the object. Thus using principles of object oriented programming.

More topics related to class are:
1. Abstraction and Encapsulation.
2. Classes defined with structure and union
3. Constructors.
4. Overloading Constructors.
5. Destructors.
6. Const Objects
7. Friend functions.
8. Function overloading.
9. Function overriding.
10.Operator overloading.
       Right now we won’t go in depth of these topics, we will surely explain these concepts if further required. So in this blog we learned how to initialize a class and little bit of its concepts and Object oriented paradigms and in next blog we will see different types of memory allocation

By-
Ashutosh Bardapurkar    (k-05)
Hrishikesh Deshpande    (k-16)
Archit Hiwrekar        (k-23)
Chinmay Kapkar    (k-33)



4. Variables and access specifiers.


Hello folks!
         Welcome to the blog series. In the previous blog we have studied why we have chosen c++ language for object oriented programming (OOP) and our approach to the project. In this blog we are going to look at the variables to be used and types of these variable.
         As our project is building for cafeteria management system. We require certainly  to understand first the table number where one is placing order from. Hence an integer array of the number of table present in the cafeteria. To take the order of available items in the cafeteria such as “Hot Coffee”, “Tea”, “Hot Milk”, “Cold Coffee” we made character array of name and assigned each character pointer to character array of payOption so it will be easier for the waiter who is taking the order to place the order. These items are assigned each int variable of price. To place multiple orders integer quantity variable is used. This quantity variable is multiplied with the price variable. To know the bill of the table integer bill is made which displays bill of the table.

       Classes have the same format as plain data structures, except that they can also include functions and have these new things called access specifiers. An access specifier is one of the following three keywords: private, public or protected. These specifiers modify the access rights for the members that follow them:

       Private members of a class are accessible only from within other members of the same class (or from their "friends").
       Protected members are accessible from other members of the same class (or from their "friends"), but also from members of their derived classes.
       Finally, public members are accessible from anywhere where the object is visible.

       These classes helps us in our project too as price, quantity and the bill is made private so these variables cannot be changed by anyone.
       In next blog of the series we will discuss about classes and different types related to it

By-
Ashutosh Bardapurkar    (k-05)
Hrishikesh Deshpande    (k-16)
Archit Hiwrekar        (k-23)
Chinmay Kapkar    (k-33)

3. Selecting an Object Oriented Programming language.


Hello folks!
         Welcome to the blog series. In the previous blog we have studied the advantages object oriented programming over procedural programming and we concluded on the point that we are going to use object oriented programming (OOP) in our project.


        Now we will be using the basic OOP language which is C++. We have chosen C++ because of the following points.
1)Platform or Machine Independent/ Portable
It means that C++ can run in various environments. For understanding purpose let us say we are writing code in our Linux operating system and after sometime we have to shift our operating system from Linux to say Mac operating system or Windows operating system, still the code written in C++ will be executed in a similar way.

2)Simple and easy to use
The syntax used in C++ is almost similar to that of the C language. If you are familiar with C then you will easily be to code in C++ without and syntax issues (by issues we mean syntax errors). The readability of the code written in C++ is also we good.

3)Popularity 
C++ is one of the oldest and basic programming language. The popularity of C++ is such that almost every programmer or programming geek knows C++. If we get any issue or problem there are many forums and sites which give us solutions to the issue or problem in C++ language. 

4)Compiler Dependent 
Unlike Java and Python that are interpreter-based, C++ is a compiler based language and hence it a relatively much faster than Python and Java.

5)Dynamic memory addressing
As C++ is like C programming language it also supports use of pointer for dynamic memory allocations. In latter part we will discuss more on this but for now let me tell you that here we new[] and delete[] operators.

6)Availability of libraries
As C++ is a very popular language we get access to huge variety of libraries. The function we require for hard task such as taking  system time etc are easily possible by adding relevant header files/libraries (in this case time.h).

7)Speed
As discussed earlier, C++ is compiler-based hence it is much faster than other programming languages like Python and Java that are interpreter-based.  
So now we know that we have to use Object Oriented Programming and C++ programming language to make our system, we will discuss which parameters of the cafeteria to be considered as a variables and access specifiers in next blog 

By-
Ashutosh Bardapurkar    (k-05)
Hrishikesh Deshpande    (k-16)
Archit Hiwrekar        (k-23)
Chinmay Kapkar    (k-33)

2. Advantages of Object Oriented programming



Hello folks!
Welcome to this blog series. While we get started with actual design it is important to start with the basics of OOP.In the previous blog we have studied the different types of programming styles.
Now in this blog we will see the general advantages of object oriented programming (OOP) as well as the how object oriented programming is better then procedural programming

These are some general advantages of object oriented programming (OOP) :

1)  It is easy to model a real system as real objects are represented by programming objects in OOP. The objects are processed by their member data and functions. It is easy to analyze the user requirements.
2)  With the help of inheritance, we can reuse the existing class to derive a new class such that the redundant code is eliminated and the use of existing class is extended. This saves time and cost of program.
3)  In OOP, data can be made private to a class such that only member functions of the class can access the data. This principle of data hiding helps the programmer to build a secure program that can not be invaded by code in other part of the program.
4)  With the help of polymorphism, the same function or same operator can be used for different purposes. This helps to manage software complexity easily.
5)  Large problems can be reduced to smaller and more manageable problems. It is easy to partition the work in a project based on objects.
6)  It is possible to have multiple instances of an object to co-exist without any interference i.e. each object has its own separate member data and function.



Advantages of object-oriented programming over procedural programming are as follows

1)  OOP provides a clear modular structure for programs.

2)  OOP makes it easy to maintain and modify existing code.

3) OOP provides a good framework for code libraries where supplied software components can be easily adapted and modified by the programmer.

4)  Code reusability.

5)  It is suitable for real word problems and real world works.

All these advantages make object-oriented approach more preferable over procedural approach, hence, in our project we are going to use object-oriented programming to make the entire system.
In the next blog we will discuss about the different programming languages

By-
Ashutosh Bardapurkar    (k-05)
Hrishikesh Deshpande    (k-16)
Archit Hiwrekar        (k-23)
Chinmay Kapkar    (k-33)