Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

CS304 - Object Oriented Programming Lecture No. 01 Problems Discussions and Solutions Spring 2013

Post your problems and questions about lecture no. 01 in reply of this discussion so we can give you answers and solve problems.Also share important points of Lecture number so others students can also get help. Discussions provide best solution.

Views: 535

Replies to This Discussion

What is Object-oriented programming (OOP)?
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Whereas C++ is a partial implementation of OOP paradigm where you can include features such as data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance.

what are the applications of oop in our professional life?
OOP is the basic programming language which is widely used in many other languages. Or we can say that is it the base of many other concepts and emerging technologies. Many modern programming languages extensively used and support OOP. Some of the applications of OOP are:

Dynamic programming languages
Design patterns
Wed application development

What is difference between Encapsulation and Abstraction ?

In encapsulation all the characteristics of an object is present in the object itself while in abstraction we capture only those details which are relevant to object current prospective. Read handout as their difference is given in handout with enough details.
How can differentiate b/w OOP and OO Model?

We make Object Oriented models showing several interacting objects to understand a system given to us for implementation.

During coding in object oriented programming approach we have objects with their attributes and behaviors that are hidden from other classes, so we can say that object oriented programming follows the principle of information hiding.

What is difference between Tangible and Intangible ?
Tangible: Something that can be physically touched or felt. For example something real and substantial.

Intangible: Something that cannot be touched. If something is intangible it does not mean it's not real. It just means it has no physical existence like emotions

What is procedural programming ?

Procedural programming focuses on processes (processes are implemented in OOP as functions), while OOP focuses on objects of user defined data types (classes). In procedural programming data and functions are stored in separate memory location, while in OOP data and functions are stored in same memory location.

what is control bus?
Control bus is the physical connections between the CPU and other devices of the computer, which carry control information. The control bus consists of control signals that report the status of various devices. OR
Control bus is a control path that carries different commands from the instruction decoder to various functional units like ALU, memory address register, memory data register etc.

For example, a line of bus is used to indicate whether the CPU is currently reading from or writing to main memory. Similarly in the processor the one bus line is used to select an appropriate register.

What are the concept of object oriented programing, object and model?

Object oriented programming: Object oriented programming focuses on “objects” rather than “actions”. The procedural programming only focuses on processes performed by the system, while object oriented programming focuses on data and processes that are performed by the system. All the data manipulation operations are done through objects. OOP consists of some basic features like classes, objects, inheritance, polymorphism etc.

Objects: object is tangible or intangible things that have basic three properties. These properties are “State”, “well defined behaviour” and “unique identity”.

Model: model is an abstraction of something real or conceptual. Model is used to understand an aspect of reality

Procedural vs Object Oriented Programming

ColdFusion started its life as a procedural language and only in more recent times gained object oriented features. As a result of this history there is a substantial number of procedural ColdFusion systems in existence today. Considering this, it's worth taking a brief look at what it means to write procedural code and then see how this differs from an object oriented approach.

To make this comparison we need to first consider the problem that both approaches help us to solve. When programming any system you are essentially dealing with data and the code that changes that data. These two fundamental aspects of programming are handled quite differently in procedural systems compared with object oriented systems, and these differences require different strategies in how we think about writing code.

Procedural programming

In procedural programing our code is organised into small "procedures" that use and change our data. In ColdFusion, we write our procedures as either custom tags or functions. These functions typically take some input, do something, then produce some output. Ideally your functions would behave as "black boxes" where input data goes in and output data comes out.

The key idea here is that our functions have no intrinsic relationship with the data they operate on. As long as you provide the correct number and type of arguments, the function will do its work and faithfully return its output.

Sometimes our functions need to access data that is not provided as a parameter, i.e., we need access data that is outside the function. Data accessed in this way is considered "global" or "shared" data.

So in a procedural system our functions use data they are "given" (as parameters) but also directly access any shared data they need.

Object oriented programming

In object oriented programming, the data and related functions are bundled together into an "object". Ideally, the data inside an object can only be manipulated by calling the object's functions. This means that your data is locked away inside your objects and your functions provide the only means of doing something with that data. In a well designed object oriented system objects never access shared or global data, they are only permitted to use the data they have, or data they are given.

Global and shared data

We can see that one of the principle differences is that procedural systems make use of shared and global data, while object oriented systems lock their data privately away in objects.

Let's consider a scenario where you need to change a shared variable in a procedural system. Perhaps you need to rename it, change it from a string to a numeric, change it from a struct to an array, or even remove it completely.

In a procedural application you would need to find and change each place in the code where that variable is referenced. In a large system this can be a widespread and difficult change to make.

In an object oriented system we know that all variables are inside objects and that only functions within those objects can access or change those variables. When a variable needs to be changed then we only need to change the functions that access those variables. As long as we take care that the functions' input arguments and output types are not changed, then we don't need to change any other part of the system.

The cost of OO

Object oriented design is complicated to do well, and a substantial amount of time is likely to be required to learn it in depth. If you have been developing procedural systems for some time then object oriented concepts will require learning a different way of thinking which is always challenging and requires effort.

However the time to learn is not the only cost. Once you start learning, you may start to question yourself time and time again if you are writing code "correctly". Your productivity may be affected as you try different ideas, aiming for a good object oriented solution.

A further cost to consider is not specific to OO, but is specific to OO within ColdFusion. You may read many object oriented articles and books but you cannot apply their teachings blindly in your ColdFusion applications. There is a performance factor associated with creating objects in ColdFusion so applying many of the pure object oriented ideas can adversely affect your application. This then adds an additional challenge in knowing when not to apply some object oriented ideas.

What is an Object?

In object oriented programming, an object represents a bundling of data and functions that use the data.

This is simply a description of the structure of an object, but we need to think about objects as much more than this simple bundling. We can think of objects as though they were very little living entities; they have a lifespan, they can do things, and they can communicate with each other.

Objects have a lifetime

Some objects may have a very short lifespan and perhaps only exist for the duration of a single page request. Other objects may live much longer and may exist throughout the lifetime of your application.

Objects that have a short lifespan are those that you create on the fly during a page request. You might use it a few times during that page request but it is discarded when the page request finishes. Objects that have a longer lifespan are those you create and store in the session or application scope. These survive for as long as session or as long as the application is running.

Objects are your own personal little workers

Once you have brought an object to life you need to tell it to do things for you. Objects don't get tired or bored and are there make you happy so they will stick around as long as you need them so you can keep on asking them to do things for you.

This is a fundamental idea to get; objects are there to do work for you. You need to think of them as little workers who only know how to perform very specific tasks and you can ask them to do your bidding. They are much more than a simple bundle of data or a wrapper for some functions.

Objects can communicate with each other

This simply means that one object call another object's functions. When one object calls another object's function it might be to ask the object to do something, or to ask the object for some information.

However, objects can't just communicate with any object anywhere in the system. Objects can only communicate with other objects that it has been "introduced to". This simply means that an object can only communicate with other objects that have been passed via a function call.

What is object orientation?

It is a technique in which we visualize our programming problems in the form of objects and their interactions as happens in real life.

What is a model?

A model is an abstraction of something real or conceptual.

We need models to understand an aspect of reality.

Advantages of Object-Orientation

We can easily develop an object oriented model for a problem.

Everyone can easily understand an object oriented model.

We can easily implement an object oriented model for a problem using any object oriented language like c++ using its features like classes, inheritance, virtual functions and so on.

What is an object?

An object is,

  1. 1.     Something tangible (Ali, School, House, Car).
  2. 2.     Something conceptual (that can be apprehended intellectually for example time, date and so on.).

An object has,

  1. 1.     State (attributes)
  2. 2.     Well-defined behavior (operations)
  3. 3.     Unique identity

What is encapsolation ?

Encapsulation means to protect sensitive information in an object by making members protected or private in a class. The user then has to use functions to change the state of the object, rather than modifying the object directly. This helps assure than an object is always "stable" and can't be corrupted. It also makes classes much harder to misuse and less likely to cause serious problems in a program.

class MyClass
// members functions (to access the object data)
int foo; // sensitive members that we want to hide from the outer objects (encapsulated)
int bar; // usually private and in some cases protected

What is Polymorphism?

it can be described as existence of one entity in more than one form its simplest example is function overloading in c++, where a function can work for more than one data type according to nature of parameters passed to the function.

High Level Language is the language in which we can write code without taking care of architecture of system mean we don’t have to understand the no. of registers in the processor amount of available memory in stack and so on… Compiler takes care of these things and converts our code to machine code of the system that can execute directly on the system whereas,
Object Oriented Language is such a language in which we can write code in terms of objects this is a modern concept and we can say that all modern languages have implemented this concept.

But note that these two terms are entirely different it is not necessary that all high level languages support object oriented programming there may be some high level languages that don’t support object oriented programming concepts.
For example Java, c, c++, python, c#, VB.Net, VB all can be said high level languages (c and c++ are mixture these can be said high level languages but they also support assembly language code to be embedded in them)
Some of these languages are not object oriented like c.

How can differentiate b/w OOP and OO Model?

We make Object Oriented models showing several interacting objects to understand a system given to us for implementation.

During coding in object oriented programming approach we have objects with their attributes and behaviors that are hidden from other classes, so we can say that object oriented programming follows the principle of information hiding.

Tariq bhai plz explain some of previous concepts which will be use in this course like function overloading, encapsulation hiding etc

also explain shortly some useful functions and commands of c++

plz help me this Question

Write a class named as memory which has public and private data embers/functions to implement simple program of dynamic memory allocation.


© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service