Skip to main content

Why Do We Need Object-Oriented Programming?


Object-based programming was developed because of the limitations discovered in the first methods of programming. In order to appreciate the work of OOPs, we need to understand what these limitations are and how they were born out of traditional programming.
Divide into functions



Division into Functions

                                                    As programs get bigger, a list of instructions becomes invalid. Some programmers can understand a program of more than a few hundred statements unless it is broken down into smaller units. For this reason, the program was adopted as a way to make programs more understandable to our human creators. (The term is used in the verbs C ++ and C. In other languages, the same concept can be called subroutine, a subprogram, or a method.) An operational program is divided into functions, and (ideally, at least Each function program has a clearly defined purpose and a clearly defined interface for other tasks. The idea of ​​breaking down a program into functions can be further enhanced by grouping several groups together into one module (which is often a file) in a larger entity, but the principle is the same: a group of components executing instruction lists. Bandi. Separating a program into capacities and modules is an extraordinary piece of organized programming, a to some degree approximately characterized discipline that impacted the programming association for quite a long time before the coming of object-based programming.


Problems with Structured Programming

                                                                                     
                                                                                        As programs get bigger and more complex, even organized programming can show signs of stress. You may have heard or joined the horror stories of the program's development. The plan is more complex, the schedule slips, more programmers are added, the complexity increases, the cost of the skyrocket increases, the schedule slips further, and the disaster spreads. An analysis of the reasons for these failures reveals that in practice the parable itself has its weaknesses. No matter how well-organized programming is implemented, large programs become more complex than necessary. What are the causes of these problems in procedural languages? There are two related issues. First, the functions are limited to global data. Second, the irrelevant functions and data, which are the basis of the metaphor of the method, provide a flawed real-world model. Let's examine these issues in the context of an inventory program. One such program is the collection of items in an important global data item inventory. Various different functions access this data to input a new item, display an item, edit an item, 

Unlimited access 


  In an action program, for example, there are two types of data written in C.. In the inventory program, local data can be used in a display function to remember which item it is displaying. Local data is closely related to its function and is protected from editing other functions. However, when two or more functions have to access the same data - and this is true of the most important data in a program - the data must be globalized. As is our collection of inventory items. Global data can be accessed through any function in the program. (We ignore the issue of grouping functions in modules, which do not affect our argument by the substance.) Arranging local and global variables in the action program.
Local and Global variables

n a big program, there are a lot of functions and a lot of global data items. The problem with the method example is that it involves a large number of possible interactions between functions and data.
Lifetime of Local and Global Variables

                                     These large numbers of contacts cause problems in many ways. First of all, it makes it difficult to imagine the structure of a program. Second, it makes it difficult to edit the program. Changes to a global statistics item will require rewriting all that accesses the item.

When editing data items in a large program, it will not be easy to tell which functions access the data, and even when you detect it, Can do wrong with global data items. Everything is related to everything, so editing is far-fetched anywhere and often has no consequences.                             

Real-world modeling

      Second and more importantly - the practical problem is that its separate data and function management does a poor job of modeling things in the real world. In the physical world, we deal with things like people and cars. Such objects are not as data and they do not like functions. Complex real-world objects have both attributes and behavior. Examples of attributes (sometimes)

Behavior


               Behavior is a stimulus to which the real world responds. If you ask your boss for an increase, she will usually say yes or no. If you apply the brakes to the car, it will usually stop. Saying and pausing is an example of behavior. Treatment is like a function: you ask a task to do something (display inventory, for example) and it performs. So neither data nor functions, themselves, effectively model real-world objects.

         

     Object-oriented approach                                      

         
                                                The basic idea behind object-based languages ​​is to combine both data and the functions that work on that data into one unit. Such a unit is called an object.
The functions of an object, called member functions in C ++, usually provide the only way to access its data. If you want to read a data item in an item, you call a member in question. This will access the data and refund you. You cannot access data directly. The data is hidden, so it is protected from accidental change. It is said that data and its functions are encapsulated in a single act If you want to edit the data in an item, you know exactly what works with it: The object in the object works. No other work can access the data. This program makes it easy to write, debug, and maintain. A-C ++ program usually consists of several objects, which communicate with each other by calling each other's member functions. C ++ program organization

C ++ program organization


We should mention that what are called member functions in C ++ are called procedures in some other object-oriented (OO) languages ​​(such as Smalltalk, one of the first OO languages). Also, data items are sent as attributes or instance variables. Calling an object member function is tantamount to sending a message to the object. These terms are not official C ++ terms, but they are used with increasing frequency, especially in object-based design.



An analogy


                   You want to think about things in a company. Such as sales, accounting, staff, etc. Departments provide an important perspective for corporate organizations. In most companies (except very small ones), people don't work on employee issues one day, get paid the next day, and then go out on the field as sales pop after a week. Each department has its own personnel who have clearly assigned duties., and so on. People in each department control and manage the data of that department. Dividing a company into departments makes it easier to understand and control the company's activities, and helps maintain the integrity of the information used by the company. For example, the accountant department is responsible for payroll statistics. If you're a sales manager, and you need to know the total of all salaries paid in the South in July, you can't just go to the accounting department and start spreading rumors through the file cabinet. You send a memo to the appropriate person in the department, then wait for that person to access the data and send you a reply with the information you need. This ensures accurate access to data and is not compromised by incompetent outsiders. This concept of corporate organization is shown in Figure 1.4. Similarly, programs provide an objective approach to the organization of programs, helping to maintain the integrity of program data.

 OOP: Access to the organization


                                                   Keep in mind that object-oriented programming is not primarily about program details. Instead, it is about the overall organization of the program. Most individual program statements in C ++ are similar to statements in method language, and many are similar to statements in C, in fact, a whole member function in C ++ program is a method function in C It can be very similar to when you see it. The great context that lets you decide if a statement or functional process is part of a C program or an object-based C ++ program.

Comments

Popular posts from this blog

fasmart1.blogspot.com genetic engineering technologies health technologies reproduction technologies war techology information communication technology computer science and robotics 1. Communication Technology 2. Construction Technology 3. Product Technology 4. Medical Technology 5. Architecture Technology 6. Business Technology 7. Educational Technology 8. Information Technology 9. Space Technology 10. Artificial Intelligence 11. Robotics Technology 12. Super intelligence 13. Agriculture Technology 14. Assistive Technology 15. Operation Technology 16. Entertainment Technology

Assistive Technology Tools & Resources For College Students With Disabilities

                                                                   Assistive innovation devices are among the least 'celebrated' however most pivotal apparatuses in K-12 instruction today.  As indicated by the National Education Association (NEA), the quantity of U.S. understudies took a crack at a custom curriculum program has risen 30 percent in the course of the last 10 years. Additionally, the NEA reports that almost every broad training homeroom in the nation incorporates understudies with handicaps, as three out of each four understudies with incapacities spend part or the entirety of their school day in overall instruction study hall.  One apparatus to assist understudies with handicaps even notwithstanding a specialized curriculum instructor deficiency is assistive innovation. Today, assistive innovati...