155x Filetype PDF File size 0.02 MB Source: personalpages.bradley.edu
Problem Solving via Programs A computer is a tool that solves problems by means of programs written in PLs. Programming Paradigms (Styles) A typical program development process: – Requirement analysis (specification) – Design a solution – Implement as programs in a PL – Verification/validation CS216 1 CS216 2 Paradigms and Programs What Is a Programming Paradigm? A collection of conceptual patterns that Problems together mold the program design process and Paradigms Design a solution ultimately determine a program’s structure. Solutions – How we think about and formulate solutions PLs Implement as programs – The form of programs Programs in a PL Computer CS216 3 CS216 4 Programming Paradigms and PLs Programming Paradigms Relationship between PPs and PLs: Operational Approach – Once we visualize a solution via a paradigm’s – Describes step-by-step how to construct a solution. conceptual pattern, we express it in a PL Definitional (Declarative) Approach – A PL that reflects a particular paradigm well, this – States properties about the solution. PL is said to support that paradigm Demonstrational Approach Does a PL support only one paradigm ? – Demonstrates solutions (examples) to specific – No, typically it supports one paradigm very well. instances of simple problems. CS216 5 CS216 6 1 Programming Paradigms Imperative Programming Paradigms Operational Approach Characterized by an abstract model of a – Imperative (Procedural) Programming computer that consists of a single large global – Object-Oriented Programming store. Definitional (Declarative) Approach (Paradigms) The computer stores an encoded representation – Functional Programming of a computation and executes a sequence of – Logic Programming command or expressions that modifies the Demonstrational Approach (Paradigms) store. – Program by example Best represented by Von-Neumann style – Visual Programming computer. CS216 7 CS216 8 Imperative (Procedure-Oriented) Object-Oriented Programming Thinking Paradigms How to do IP? In IP, each procedure/function deals with the – Determine what data values will be required. concrete representation of data values in a – Represent these data values by associating them single global store. with storage locations. In OOP, each procedure/function operates on – Derive a step-by-step sequence of transformation to abstract values, rather than on stored the store. representation. – The final state represents the result values – Objects (solution). CS216 9 CS216 10 Imperative vs. Object-Oriented Object-Oriented Thinking Programming P/F How to do OOP ? – Define suitable objects for the problem. – Use these objects to describe step-by-step sequence Grouping of operations. Global store IP OOP CS216 11 CS216 12 2 Functional Programming Function-Oriented Thinking Paradigms Based on the mathematical model of functions How to do FP ? and function composition. – Define functions (using function composition) – No concepts of a storage location that can be – Use a function application assigned or modified. (no variables, no commands) Referentially transparent – Easier to understand program Functions treated as first class values – No restriction of use CS216 13 CS216 14 Logic Programming Paradigms Logic-Oriented Thinking Based on the mathematical model of facts and How to do LP ? rules that allow deduction of other facts. – Define facts – A logic program = facts + rules – Define rules – Use a query CS216 15 CS216 16 Parallel/Concurrent Programming Parallel/Concurrent Programming Paradigms Cooperating parallel process How to use P/C P? – asynchronous – Automatically detect parallelism in a sequential Single process applied to many data pgm. – synchronous – Add mechanisms that describe parallelism.. CS216 17 CS216 18 3 Programming Paradigms Programming Paradigm Operational Definitional Demonstrational IP OOP FP LP EP Parallel/Concurrent Paradigm CS216 19 4
no reviews yet
Please Login to review.