Object-oriented programming has four basic concepts: encapsulation, abstraction, inheritance and polymorphism. Even if these concepts seem incredibly complex, understanding the general framework of how they work will help you understand the basics of a computer program.
Polymorphism means "many forms", and it occurs when we have many classes that are related to each other by inheritance. Like we specified in the previous chapter; Inheritance lets us inherit attributes and methods from another class. Polymorphism uses those methods to perform different tasks.
4 Advantages of Object-Oriented Programming
- Modularity for easier troubleshooting. Something has gone wrong, and you have no idea where to look.
- Reuse of code through inheritance.
- Flexibility through polymorphism.
- Effective problem solving.
Other OOP disadvantages are: 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.
Object Oriented Development (OOD) has been touted as the next great advance in software engineering. It promises to reduce development time, reduce the time and resources required to maintain existing applications, increase code reuse, and provide a competitive advantage to organizations that use it.
A major disadvantage of using Procedural Programming as a method of programming is the inability to reuse code throughout the program. Having to rewrite the same type of code many times throughout a program can add to the development cost and time of a project. Another disadvantage is the difficulty in error checking.
Encapsulation in Java is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit. Declare the variables of a class as private. Provide public setter and getter methods to modify and view the variables values.
Let's see what are the advantages of OOP offers to its users.
- Re-usability. It means reusing some facilities rather than building it again and again.
- Data Redundancy.
- Code Maintenance.
- Security.
- Design Benefits.
- Better productivity.
- Easy troubleshooting.
- Polymorphism Flexibility.
Main application areas of OOP are:
- User interface design such as windows, menu.
- Real Time Systems.
- Simulation and Modeling.
- Object oriented databases.
- AI and Expert System.
- Neural Networks and parallel programming.
- Decision support and office automation systems etc.
Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object. Any Java object that can pass more than one IS-A test is considered to be polymorphic.
Advantages
- Procedural Programming is excellent for general-purpose programming.
- The coded simplicity along with ease of implementation of compilers and interpreters.
- A large variety of books and online course material available on tested algorithms, making it easier to learn along the way.
Structured Approach Vs. Object-Oriented Approach
| Structured Approach | Object Oriented Approach |
|---|
| DFD & E-R diagram model the data. | Class diagram, sequence diagram, state chart diagram, and use cases all contribute. |
Which things are dynamic parts of UML models?
- Structural Things. Structural things define the static part of the model.
- Behavioral Things. A behavioral thing consists of the dynamic parts of UML models.
- Grouping Things.
- Annotational Things.
- Dependency.
- Generalization.
- Realization.
Explanation: Object oriented programming follows a conceptual framework called object model and is implemented by writing classes and objects to make its style clear unlike procedure- oriented language.
Explanation: The nine UML diagrams include use-case, sequence, collaboration, activity, state-chart, deployment, class, object and component.
A timing diagram in the Unified Modeling Language 2.0 is a specific type of interaction diagram, where the focus is on timing constraints. Timing diagrams are used to explore the behaviors of objects throughout a given period of time. A timing diagram is a special form of a sequence diagram.
Sequence diagrams are a popular dynamic modeling solution in UML because they specifically focus on lifelines, or the processes and objects that live simultaneously, and the messages exchanged between them to perform a function before the lifeline ends.
Explanation: An operation is the implementation of a service that can be requested from any object of the class to affect behavior. Object diagram captures the behavior of a single use case. Explanation: Sequence Diagram is responsible for this.
Object-oriented programming (OOP) is a programming paradigm based upon objects (having both data and methods) that aims to incorporate the advantages of modularity and reusability. Objects, which are usually instances of classes, are used to interact with one another to design applications and computer programs.
The UML began as an attempt by some of the major thought leaders in the community to define a standard language at the OOPSLA '95 Conference. Originally, Grady Booch and James Rumbaugh merged their models into a unified model.
Following are the five concepts that make up SOLID principles: Single Responsibility principle. Open/Closed principle. Liskov Substitution principle.
OOA
| Acronym | Definition |
|---|
| OOA | On Or About |
| OOA | Order of Appearance |
| OOA | Out of Ammo |
| OOA | Office of Agriculture (various organizations) |
What are the 5 key activities in an object-oriented design
- Design the system architecture.
- Identify the principal objects in the system.
- Develop design models.
- Specify interfaces. TIGER PRODUCTIONS at 12:03 AM. Share.
The term programming paradigm refers to a style of programming. It does not refer to a specific language, but rather it refers to the way you program. There are lots of programming languages that are well-known but all of them need to follow some strategy when they are implemented. And that strategy is a paradigm.
Common models used in OOA are use cases and object models. Use cases describe scenarios for standard domain functions that the system must accomplish. During object-oriented design (OOD), a developer applies implementation constraints to the conceptual model produced in object-oriented analysis.
What are the three ways and perspectives to Apply UML? Ways - UML as sketch, UML as blueprint, UML as programming language Perspectives-Conceptual perspective, Specification (software) perspective, Implementation (Software) perspective.
Java Classes/ObjectsJava is an object-oriented programming language. Everything in Java is associated with classes and objects, along with its attributes and methods. For example: in real life, a car is an object. A Class is like an object constructor, or a "blueprint" for creating objects.
Constructors are special class functions which performs initialization of every object. The Compiler calls the Constructor whenever an object is created. Constructors initialize values to object members after storage is allocated to the object. Whereas, Destructor on the other hand is used to destroy the class object.
Procedural programming is about writing procedures or methods that perform operations on the data, while object-oriented programming is about creating objects that contain both data and methods. OOP helps to keep the Java code DRY "Don't Repeat Yourself", and makes the code easier to maintain, modify and debug.