Ad Code

Responsive Advertisement

Gather basic knowledge before starting of Object Oriented Programming

Q1. What is Object Oriented Programming? 

Object-oriented programming (OOP) is a programming paradigm that represents concepts as "objects" that have data fields and associated procedures known as methods. Objects, which are usually instances of classes, are used to interact with one another to design applications and computer programs. Object-orientation is simply the logical extension of older techniques such as structured programming and abstract data types. An object is an abstract data type with the addition of polymorphism and inheritance.
Object-oriented programming is an approach to designing modular reusable software systems. Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic.
Q2. What is Programming Paradigm?
A programming paradigm is a fundamental style of computer programming, a way of building the structure and elements of computer programs. There are five main paradigms: imperativefunctionalobject-orientedlogic and symbolic programming.
Q3. What are the goal of Object Oriented Programming? 
The goals of object-oriented programming are:
· Increased understanding.
· Ease of maintenance.
· Ease of evolution.
· Easy to reusability. 
· Emphasize ease of writing over readability
Q4. What is Procedural Programming?
A list of instructions telling a computer, step-by-step, what to do, usually having a linear order of execution from the first statement to the second and so forth with occasional loops and branches. Procedural programming languages include C, C++, FORTRAN, Pascal, and Basic.
Structured programming (sometimes known as modular programming) is a subset of procedural programming that enforces a logical structure on the program being written to make it more efficient and easier to understand and modify. Certain languages such as Ada,Pascal, and dBASE are designed with features that encourage or enforce a logical program structure.
Structured programming frequently employs a top-down design model, in which developers map out the overall program structure into separate subsections. A defined function or set of similar functions is coded in a separate module or sub module, which means that code can be loaded into memory more efficiently and that modules can be reused in other programs. After a module has been tested individually, it is then integrated with other modules into the overall program structure.
Program flow follows a simple hierarchical model that employs looping constructs such as "for," "repeat," and "while." Use of the "Go To" statement is discouraged.
Q6. What is Abstract Data Types?
An abstract data type (ADT) is a mathematical model for a certain class of data structures that have similar behavior; or for certain data types of one or more programming languages that have similar semantics. An abstract data type is defined indirectly, only by the operations that may be performed on it and by mathematical constraints on the effects (and possibly cost) of those operations
Here are some examples.
Stack: operations are "push an item onto the stack", "pop an item from the stack", "and ask if the stack is empty"; implementation may be as array or linked list or whatever.
Queue: operations are "add to the end of the queue", "delete from the beginning of the queue", "and ask if the queue is empty"; implementation may be as array or linked list or heap.
Search structure: operations are "insert an item", "ask if an item is in the structure", and "delete an item"; implementation may be as array, linked list, tree, hash table,
Class-based object oriented programming is a style that gains inheritance by processing classes as objects. The most prominent style of OOP is class-based instead of object-based. With the class-based OOP system, objects are units that merge states, identities, and behaviors.
The foundation and behavior of the object will be characterized by the class, which will act as a diagram of all objects which fall under the same type. The object will need to be constructed on the foundation of a class, and because of this, the object is considered to be the instance of the class that it is based on. The object can be likened to a foundation, and it will have access controls and method pointers.

With class-based OOP, encapsulation will stop users from disrupting the invariants within the class, and this is important because it will permit the classes of objects to be implemented. At the same time, it will not have any adverse effects on the user code. Encapsulation is a concept that deals with the collection and protection of information that is related, and the name for this is cohesion. The vast majority of object oriented programming languages don't offer security measures which are formal for the state of an object. The method of access is more closely connected to the design of the interface.

In class-based OOP, inheritance will be performed by collecting objects and placing them into classes. Once the objects have been collected as classes, they will be defined as extensions of classes that already exist. The classes will also be presented as a lattice which will show their common behaviors. Using classes with the method of inheritance is extremely popular. In addition to this, programming which is prototype based is popular as well. There are a number of criticisms that have been made against class-based OOP. One of the common issues that have been cited is the combining of interfaces with implementations. This is one of the foundations of object oriented programming.

For example, a group of classes might be constructed, and they could be extended to create a new class which is named a set class. In the set class, the ability to clone objects can be destroyed. If a function is designed that can take the group of classes, it may think that adding more objects can increase the size of the group, but if an object is placed in a set class, the bag may increase in size, but it may also not increase in size as well. This is a problem that is created because subclassing is connected to subtyping, and this is true in cases where the concept of subtyping is not relevant. Because of this, it is important for programmers to separate subclasses from subtyping.

The vast majority of modern programming languages already do this. However, there are some designs which do not separate subclasses from subtyping, and this can cause a number of problems. Another criticism that has been made against class-based OOP is that an object created from a child class is not allowed to become the object of a parent class. The reason for this is because while the child class and parent class can connect to a person class, the vast majority of class-based OOP languages will not permit a change to a specific object class during runtime. They do this so that unified view of the class is maintained.
It is not important for the users to care about any changes that may disrupt the invariants of a class. Another way to make these changes is to delete the object and create a new one to replace it. In addition to this, polymorphism can be utilized to maintain the necessary interfaces whenever a change occurs. The reason for this is because all objects will be seen as being abstractions, and a connection can be made to them through their identities. In most cases, it is the value of the object that may change, and this will cause changes to occur in the code of the client as well. The first programming language to introduce the class-based abstraction is Simula. Some other languages which use this system are Java or C++. It is likely that this system will be used in future programming languages.
Prototype-based programming is a style of object-oriented programming in which behaviour reuse (known as inheritance) is performed via a process of cloning existing objects that serve as prototypes. This model can also be known as prototypal, prototype-oriented, classless, or instance-based programming. Delegation is the language feature that supports prototype-based programming.
A fruit bowl serves as one example. A "fruit" object would represent the properties and functionality of fruit in general. A "banana" object would be cloned from the "fruit" object, and would also be extended to include general properties specific to bananas. Each individual "banana" object would be cloned from the generic "banana" object.
The first prototype-oriented programming language was Self developed by David Ungar
There are a bunch of psychological reasons why I think prototypes work better, but here are some more practical reasons:
The language rules can be simpler. For example, you don't run into any issues like "Is a class an object?" and "If a class is an object, what class is it an instance of?" (In Java, a class is sorta-kinda an object, but not really a very useful one. In Smalltalk, a class is a proper object, but because of that, there's a whole silly complex metaclass system. In Self, the issue just doesn't come up - you get all of Smalltalk's power, without the extra complexity.)
You can give specialized behaviour to individual objects. This has all sorts of uses, but it's particularly useful when debugging. I've got an object on the screen that isn't behaving properly, so I ask to see that object's code, and override a method or two (on just that one particular object) to help me debug it.
A few platypi (like the SingletonPattern) completely disappear. If you want there to be only one of a particular kind of object, then... only make one of them. If you don't want it to be able to be copied, then don't give it a "copy" method.
You start to think of a bunch of new kinds of objects that you couldn't really think of in a class-based language. For example, I'm particularly fond of Self's namespace objects. (Self has a really nice namespace system, without any special namespace-related rules whatsoever in the language - it's all just ordinary objects. Nesting namespaces is done using ordinary inheritance.)
Q9. What is Coupling and Decoupling?
Coupling:
Coupling is the act of joining two things together. In software development, coupling refers to the degree to which software components are dependant upon each other. For instance, in a tightly-coupled architecture, each component and its associated components must be present in order for code to be executed or compiled. In a loosely-coupled architecture, components can remain autonomous and allow middleware software to manage communication between them. In a decoupled architecture, the components can operate completely separately and independently.
Decoupling:
The occurrence of returns on asset classes diverging from their expected or normal pattern of correlation. Decoupling takes place when two different asset classes that typically rise and fall together move in opposing directions, such as one increasing and the other decreasing. For example, stock and corporate bond returns generally move together. If the stock returns were to increase while the returns on bonds decreased, decoupling would have occurred. Another example can be seen with oil and natural gas prices; these typically rise and fall together. Decoupling occurs when oil moves in one direction and natural gas moves in the opposite direction.
Q10. Benefits of Object Oriented Programming?
  1.  Improved software-development productivity: Object-oriented programming is modular, as it provides separation of duties in object-based program development. It is also extensible, as objects can be extended to include new attributes and behaviors. Objects can also be reused within an across applications. Because of these three factors – modularity, extensibility, and reusability – object-oriented programming provides improved software-development productivity over traditional procedure-based programming techniques.
  2. Improved software maintainability: For the reasons mentioned above, object-oriented software is also easier to maintain. Since the design is modular, part of the system can be updated in case of issues without a need to make large-scale changes.
  3. Faster development: Reuse enables faster development. Object-oriented programming languages come with rich libraries of objects, and code developed during projects is also reusable in future projects.
  4. Lower cost of development: The reuse of software also lowers the cost of development. Typically, more effort is put into the object-oriented analysis and design, which lowers the overall cost of development.
  5.  Higher-quality software: Faster development of software and lower cost of development allows more time and resources to be used in the verification of the software. Although quality is dependent upon the experience of the teams, object-oriented programming tends to result in higher-quality software.
Q11. Limitations of Object Oriented Programming?
  1. Steep learning curve: The thought process involved in object-oriented programming may not be natural for some people, and it can take time to get used to it. It is complex to create programs based on interaction of objects. Some of the key programming techniques, such as inheritance and polymorphism, can be challenging to comprehend initially.
  2. Larger program size: Object-oriented programs typically involve more lines of code than procedural programs.
  3. Slower programs: Object-oriented programs are typically slower than procedure based programs, as they typically require more instructions to be executed.
  4. Not suitable for all types of problems: There are problems that lend themselves well to functional-programming style, logic-programming style, or procedure-based programming style, and applying object-oriented programming in those situations will not result in efficient programs.
Q12. Compare Between Procedural Programming and Object Oriented Programming?
The focus of procedural programming is to break down a programming task into a collection of variablesdata structures, and subroutines, whereas inobject-oriented programming it is to break down a programming task into objects that expose behavior (methods) and data (members or attributes) using interfaces. The most important distinction is that while procedural programming uses procedures to operate on data structures, object-oriented programming bundles the two together, so an "object", which is an instance of a class, operates on its "own" data structure.
Nomenclature varies between the two, although they have similar semantics:
Procedural
Object-oriented
procedure
method
object
module
class
procedure call
message
See also here
Q13. Compare Between Structured Programming and Object Oriented Programming?
Structured programming is task-centric, object oriented programming is data-centric.
Task-centric vs. Data-centric
Structured programming is based around data structures and subroutines. The subroutines are where stuff actually "happens", and the data structures are simply containers for the information needed by those subroutines.

Object oriented programming, on the other hand, shifts your primary focus to the data itself. Instead of asking "what do I want to do and what will I need to know to do it", you ask "what kind of things do I want to have and what can those things do for me". Instead of designing your functions first and then coming up with data structures to support them, you design types first and then come up with the operations needed to work with them.
Q14. Why do we need Object Oriented Programming?
Most developers have been doing some form of Object Oriented Programming (OOP) for quite a while now. Sometimes you might not even realize it. If you have been using VB 6 for example, then every control is a class, and you interact with it as an object by setting properties and calling methods on those objects. All you need to do now is to start creating your own classes, properties and methods.
An easy way to start, is take just a few of your global functions and the properties those functions use and put them into a class. This is a good first start to creating your own classes. As you learn this, you will then start to see other ways to encapsulate your data and functions together.
What Does OOP Give Me?
OOP provides many benefits over not using any OOP techniques. You will see the following benefits:
  • Eliminate Global Variables
  • Modularity: Related data and methods together in one place
  • Allows for better unit testing
  • Allows you to focus on a smaller set of data & functionality
  • Better reusability
  • Easier to extend functionality
  • Hide Complexity
As you can see, these are huge benefits! We all understand that global variables kill our productivity and make tracking down bugs very difficult. The ability to move data and the functions that operate upon that data into one place make reading code easier, and also contributes to better testing. You are better able to reuse code that is in classes.
If You Don't Use OOP...
Every new technology that comes out uses OOP techniques. If you don't start using these techniques, you could become a dinosaur and be faced with finding a new career. Ok, this is a little harsh, but it is true. If you want to take advantage of WPF, WCF, SilverLight and other technologies, you will need to understand OOP. I hope you will take sometime to really understand this all-important underlying technology on which everything you do these days is based.
Q15. History of Object Oriented Programming? 
SIMULA was the first object language. As its name suggests it was used to create simulations. Alan Kay, who was at the University of Utah at the time, liked what he saw in the SIMULA language. He had a vision of a personal computer that would provide graphics-oriented applications and he felt that a language like SIMULA would provide a good way for non-specialists to create these applications. He sold his vision to Xerox Parc and in the early 1970s, a team headed by Alan Kay at Xerox Parc created the first personal computer called the Dynabook. Smalltalk was the object-oriented language developed for programming the Dynabook. It was a simulation and graphics-oriented programming language. Smalltalk exists to this day although it is not widely used commercially.
The idea of object-oriented programming gained momentum in the 1970s and in the early 1980s Bjorn Stroustrup integrated object-oriented programming into the C language. The resulting language was called C++ and it became the first object-oriented language to be widely used commercially.
In the early 1990s a group at Sun led by James Gosling developed a simpler version of C++ called Java that was meant to be a programming language for video-on-demand applications. This project was going nowhere until the group re-oriented its focus and marketed Java as a language for programming Internet applications. The language has gained widespread popularity as the Internet has boomed, although its market penetration has been limited by its inefficiency.
Q16. Object Oriented Programming Issues
There are a number of errors that programmers can make when they are using an object oriented programming languages. One example of this is looking at the type of object instead of the membership it is associated with. When this happens, the advantages of polymorphism and inheritance are weakened.
This is just one of the many issues a programmer may face when trying to create an application with an object oriented programming approach. One characteristic of OOP is that it supports what is called code centrality. Code centrality is connected to inheritance. Many critics point out that code centrality makes the code more expensive to maintain.

The costs involved with maintaining code can become high with large applications are involved. If there is a problem at higher levels of the system, this could lead to serious problems. The information technology industry is one that has high turnovers, and new employees will not be as familiar with the code. Some developers who are maintaining lower level classes have been known to avoid make changes in the code in order to correct a bug. These developers may ask someone else to fix the issue. However, code centrality can be obtained with techniques which are secure. Another thing that many critics point out about OOP is that lists of exclusive options may not match changes that occur within the real world.
Q17. Key Difference among Procedural, Structured and Object Oriented Programming
Key Difference: A procedural programming language consists of a set of procedure calls and a set of code for each procedure. A structural programming language emphasizes on separating a program’s data from its functionality. On the other hand, object oriented languages are based on entities known as objects.
Q18. Compare among Procedural, Structured and Object Oriented Programming
Procedural
Structural
Object Oriented
1.Simple, easy implementation of compilers and interpreters
2. The ability to re-use the same code at different places in the program without copying it.
3. An easier way to keep track of program flow.
4. The ability to be strongly modular or structured.
5. Needs only less memory.
1. Programs are more easily and more quickly written
2. Programs are reliable as fewer organizational and logical errors occur during the initial stages of program development.
1. Improved software development productivity due to modularity, extensibility and reusability.
2. Software Maintenance is improved
3. Reusability helps in faster development of programs, as the language comes worth rich library of objects
4. Lower cost of Development
5. Higher quality of software can be ensured
Q19. Difference among Procedural, Structured and Object Oriented Programming
Until recently, programs were thought of as a series of procedures that acted upon data. A procedure, or function, is a set of specific instructions executed one after the other. The data was quite separate from the procedures, and the trick in programming was to keep track of which functions called which other functions, and what data was changed. To make sense of this potentially confusing situation, structured programming was created.
The principle idea behind structured programming is as simple as the idea of divide and conquer. A computer program can be thought of as consisting of a set of tasks. Any task that is too complex to be described simply would be broken down into a set of smaller component tasks, until the tasks were sufficiently small and self-contained enough that they were easily understood.
As an example, computing the average salary of every employee of a company is a rather complex task. You can, however, break it down into these subtasks:
  1. Find out what each person earns.
  2. Count how many people you have.
  3. Total all the salaries.
  4. Divide the total by the number of people you have.
Totaling the salaries can be broken down into
  1. Get each employee's record.
  2. Access the salary.
  3. Add the salary to the running total.
  4. Get the next employee's record.
In turn, obtaining each employee's record can be broken down into
  1. Open the file of employees.
  2. Go to the correct record.
  3. Read the data from disk.
Structured programming remains an enormously successful approach for dealing with complex problems. By the late 1980s, however, some of the deficiencies of structured programing had become all too clear.
First, it is natural to think of your data (employee records, for example) and what you can do with your data (sort, edit, and so on) as related ideas.
Second, programmers found themselves constantly reinventing new solutions to old problems. This is often called "reinventing the wheel," and is the opposite of reusability. The idea behind reusability is to build components that have known properties, and then to be able to plug them into your program as you need them. This is modeled after the hardware world--when an engineer needs a new transistor, she doesn't usually invent one, she goes to the big bin of transistors and finds one that works the way she needs it to, or perhaps modifies it. There was no similar option for a software engineer.
Old-fashioned programs forced the user to proceed step-by-step through a series of screens. Modern event-driven programs present all the choices at once and respond to the user's actions.
Object-oriented programming attempts to respond to these needs, providing techniques for managing enormous complexity, achieving reuse of software components, and coupling data with the tasks that manipulate that data.
The essence of object-oriented programming is to treat data and the procedures that act upon the data as a single "object"--a self-contained entity with an identity and certain characteristics of its own.
Q20. Why c# is called Objet Oriented Programming?
C# is called an Object Oriented Programming Language because many of the object oriented programming concepts are implemented in C#. Some concepts are:
  1. Class
  2. Object
  3. Inheritance
  4. Encapsulation
  5. Polymorphism
  6. Abstraction etc. 

 Reference 

  • http://en.wikipedia.org/wiki/Object-oriented_programming
  • http://searchcio-midmarket.techtarget.com/definition/structured-programming
  • http://en.wikipedia.org/wiki/Structured_programming
  • http://inst.eecs.berkeley.edu/~selfpace/studyguide/9C.sg/Output/ADTs.in.C.html 
  • http://www.exforsys.com/tutorials/oops/class-based-object-oriented-programming.html
  • http://c2.com/cgi/wiki?PrototypeBasedProgramming  

Post a Comment

0 Comments

Close Menu