1 / 21

Procedural Programming

Procedural Programming. Before Object Oriented Programming (OOP) was popular, computer software was written in a Procedural style. This meant that the application/program was divided into a large number of procedures. C is largely procedural, and to a certain degree C++ and C# are as well.

belles
Download Presentation

Procedural Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Procedural Programming Before Object Oriented Programming (OOP) was popular, computer software was written in a Procedural style. This meant that the application/program was divided into a large number of procedures. C is largely procedural, and to a certain degree C++ and C# are as well.

  2. Structured Programming A popular design methodology was "Structured Programming" but that has been rendered obsolete by OOP. 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.

  3. 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.

  4. 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. Structured programming was first suggested by Corrado Bohm and Guiseppe Jacopini. The two mathematicians demonstrated that any computer program can be written with just three structures: decisions, sequences, and loops.

  5. Edsger Dijkstra's subsequent article, Go To Statement Considered Harmful was instrumental in the trend towards structured programming. The most common methodology employed was developed by Dijkstra. In this model (which is often considered to be synonymous with structured programming, although other models exist) the developer separates programs into subsections that each have only one point of access and one point of exit.

  6. Almost any language can use structured programming techniques to avoid common pitfalls of unstructured languages. Unstructured programming must rely upon the discipline of the developer to avoid structural problems, and as a consequence may result in poorly organized programs. Most modern procedural languages include features that encourage structured programming. Object-oriented programming (OOP) can be thought of as a type of structured programming, uses structured programming techniques for program flow, and adds more structure for data to the model.

  7. Object-oriented programming Object-oriented programming is an approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions that can be used as templates for creating copies of such modules on demand. This means that an object is considered to be a partitioned area of computer memory that stores data and set of operations that can access the data. Since the memory partitions are independent, the objects can be used in a variety of different programs without modifications Object = Data + Methods (Functions)

  8. Person = Object Name,Basicpay = Data Salary(),Tax() = Methods OOP Basic Concepts Encapsulation: Wrapping up data methods in to a single unit (class) is encapsulation. Data is accessible only through its methods. (Protection)) Data Abstraction: Refers to the act of representing essential features without including the background details or explanations. (Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, weight and cost, and methods operate on these attribute) Inheritance: The process by which object of one class acquire the properties of objects another class. Polymorphism: Ability to take more than one form. For ex. An operation may exhibit different behavior in different instances. The behavior depends upon the type of data used in the operation. For ex. The operation of addition. For numbers, the operation will generate a sum and if the operands are strings then the operation would produce a third string by concatenation. A single function name can be used to handle different no and different arguments

  9. Object-oriented programming One of the most important concepts of OOP (Object Oriented Programming) is the data encapsulation concept, which means that there is a very close attachment between data items and procedures. The procedures (methods) are responsible for manipulating the data in order to reflect its behaviour. The public interface, formed by the collections of messages understood by an object, completely defines how to use this object. Programs that want to manipulate an object, only have to be concerned about which messages this object understands, and do not have to worry about how these tasks are achieved nor the internal structure of the object. The hiding of internal details makes an object abstract, and the technique is normally known as data abstraction.

  10. Normally, objects of a given type are instances of a class, whose definition specifies the private (internal) working of these objects as well as their public interface. Basically the creation of an object is referred to as instantiation, and it consists of a class definition with appropriate initial values. Another powerful feature of OOP, is the concept of inheritance (derived classes in C++), meaning the derivation of a similar or related object (the derived object) from a more general based object. The derived class can inherit the properties of its base class and also adds its own data and routines. The concept above is known as single inheritance, but it is also possible to derive a class from several base classes, which is known as multiple inheritance.

  11. Overloading, in OOP, means the ability to assign multiple meanings to the names of operators and functions. For example, the operator +, normally associated with arithmetic addition can be overloaded to add one list to another in a certain context. Polymorphism means the sending of a message to an object without concern about how the software is going to accomplish the task, and furthermore it means that the task can be executed in completely different ways depending on the object that receives the message (in C++, polymorphism is implemented through the use of virtual functions). When the decision as to which actions are going to be executed is made at run-time, the polymorphism is referred to as late binding (as in the case of virtual functions). If they are made at compile time then it is known as early binding.

  12. Drawbacks Much of it is a philosophy. But, the OOP philosophy is not always the best philosophy for many types of applications. Also a language philosophy dictates the built-in functions and operations provided. If neither the syntax nor the built-in functions are optimized for what you are working on, then you are wasting a lot of time. There are some studies that show that OOP only pays off if a programming project is "well-managed". There are also a few studies that show that even non-OOP COBOL projects can achieve the same famous "code reuse" and "flexibility" goals that OOP lays claim to if managed properly. Thus, OOP's goals may be achievable simply through commitment to certain goals, and OO languages are not a prerequisite.

  13. Studies show that most OOP projects do not really achieve the goals (improvements) of the OOP promise because all parties have to buy into the proper methodologies. These parties include programmers, project managers, and top level managers. Since code reuse and added flexibility often come only after a few years, many are unwilling to follow the process correctly. Using OOP and OOD (Object Oriented Design) often slows down progress in the first few years. If done right, OOP works as a long-term investment; it isnot an instant results tool even according to OOP experts and proponents. Instance (or shared class) variables of an object can be accessed by class-specialized functions, and called the same way as any other function.

  14. Look through the graph below. For simple or easy (even for semi hard) programs, procedural approach can be a good solution. But for the hard ones it is not. On the other hand for simple problems, approaching OOP concept is rather lengthy, time consuming and not useful. It is however, useful for tough problems. 

  15. Object-oriented programming Object-oriented programming (OOP) is a programming language model organized around "objects" rather than "actions" and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data. The programming challenge was seen as how to write the logic, not how to define the data. Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them.

  16. Examples of objects range from human beings (described by name, address, and so forth) to buildings and lands (whose properties can be described and managed) down to buttons and scroll barson computer desktop. The first step in OOP is to identify all the objects you want to manipulate and how they relate to each other, an exercise often known as data modeling. Once you've identified an object, you generalize it as a class of objects and define the kind of data it contains and any logic sequences that can manipulate it.

  17. Each distinct logic sequence is known as a method. A real instance of a class is called an "object" or, in some environments, an "instance of a class." The object or class instance is what you run in the computer. Its methods provide computer instructions and the class object characteristics provide relevant data. You communicate with objects - and they communicate with each other - with well-defined interfaces called messages.

  18. The concepts and rules used in object-oriented programming provide these important benefits: The concept of a data class makes it possible to define subclasses of data objects that share some or all of the main class characteristics. Called inheritance, this property of OOP forces a more thorough data analysis, reduces development time, and ensures more accurate coding. Since a class defines only the data it needs to be concerned with, when an instance of that class (an object) is run, the code will not be able to accidentally access other program data. This characteristic of data hiding provides greater system security and avoids unintended data corruption. The definition of a class is reusable not only by the program for which it is initially created but also by other object-oriented programs (and, for this reason, can be more easily distributed for use in networks). The concept of data classes allows a programmer to create any new data type that is not already defined in the language itself.

  19. Some argue that OOP is still important even if not dealing directly with GUI's. In my opinion, much of the hype about OOP is faddish OOP in itself does NOT allow programs to do things that they could not do before. OOP is more of a program organizational philosophy rather than a set of new external solutions or operations. However, there is a slight cost in terms of efficiency. As objects are normally referenced by pointers, with memory allocated dynamically, there is a small space overhead to store the pointers, and a small speed overhead to find space on the heap (at run-time) to store the objects. For dynamic methods there is an additional small time penalty, as the method to choose is found at run time, by searching through the object hierarchy (using the class precedence list for the object). OOP is not a new solution for unsolved problems, but only a theory (active theory of course) acting to have better solution for tough programs.

  20. Advantages of OOP simplicity: software objects model real world objects, so the complexity is reduced and the program structure is very clear; modularity: each object forms a separate entity whose internal workings are decoupled from other parts of the system; modifiability: it is easy to make minor changes in the data representation or the procedures in an OO program. Changes inside a class do not affect any other part of a program, since the only public interface that the external world has to a class is through the use of methods; extensibility: adding new features or responding to changing operating environments can be solved by introducing a few new objects and modifying some existing ones; maintainability: objects can be maintained separately, making locating and fixing problems easier; re-usability: objects can be reused in different programs. Provides a clear modular structure for programs. This makes it good for defining abstract datatypes, where implementation details are hidden and the unit has a clearly defined interface. Provides a good framework for code libraries, where supplied software components can be easily adapted and modified by the programmer. This is particularly useful for developing graphical user interfaces. Makes it easy to maintain and modify existing code, as new objects can be created with small differences to existing ones.

  21. Overall popularity of using OOP

More Related