1 / 12

Paradigms

Paradigms. Imperative Functional Object-Oriented Rule-Based Logic Visual* Scripting* * whether visual and scripting methodologies are paradigms is debatable. Paradigm. General style of thinking that underlies a programming language

cdurr
Download Presentation

Paradigms

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. Paradigms • Imperative • Functional • Object-Oriented • Rule-Based • Logic • Visual* • Scripting* • * whether visual and scripting methodologies are paradigms is debatable. CSE 341 -- S. Tanimoto Paradigms

  2. Paradigm General style of thinking that underlies a programming language Webster’s New World Dictionary: “a pattern, example, or model”. Imperative Rule-based Functional Logic Object-oriented Visual data-flow Scripting CSE 341 -- S. Tanimoto Paradigms

  3. The Imperative Paradigm An imperative program is a sequence of commands Read a value from a file. Evaluate an arithmetic expression. Assign a value to a variable. Test a condition and branch if it is true. Iterate a loop body until a condition is false. Print a value onto the screen. CSE 341 -- S. Tanimoto Paradigms

  4. The Functional Paradigm An functional program is a collection of function definitions and function applications. Define SQR(x): { Apply the * function to x and x} Apply SQR to 7; CSE 341 -- S. Tanimoto Paradigms

  5. The Object-Oriented Paradigm An object-oriented program is a collection of object class definitions, in which both data members and methods are specified. Class Student extends Person { int student_number; int get_student_number() { return student_number; } int set_student_number (int num) { student_number = num; } CSE 341 -- S. Tanimoto Paradigms

  6. The Rule-Based Paradigm A rule-based program is a collection of if-then rules. if name = "" then input name; if name starts with "A" then print "Early in the alphabet"; CSE 341 -- S. Tanimoto Paradigms

  7. The Logic-Programming Paradigm A logic program is a collection of logical propositions and questions. If x is a bird or an airplane, then x has wings. Tweety is a bird. Does Tweety have wings? CSE 341 -- S. Tanimoto Paradigms

  8. The Visual Data-Flow Paradigm A visual data-flow program is a diagram in which boxes represent operations and arrows indicate the flow of data from outputs of operations to inputs of other operations. 3x2 + 5x + 8 3 * * input x + * + 5 8 CSE 341 -- S. Tanimoto Paradigms

  9. The Scripting Paradigm* A script is a relatively small program that serves to direct activities of a system, typically by calling upon system services and programs written in other languages. Fetch input parameters from the environment. Authenticate the user against a username/password database. Issue a database query. Format the results as a web page. Print the web page to the standard output stream. CSE 341 -- S. Tanimoto Paradigms

  10. Comparing Paradigms Imperative : actions can be broken down into sequences of commands. State of the computation may be very important in thinking about the program. Functional: the program can be specified in terms of a collection of input-output relationships. Rule-based: the computation is best described in terms of matching patterns in the data, and then taking appropriate actions for each pattern. Logic: the problem and solution can be described using mathematical logic. CSE 341 -- S. Tanimoto Paradigms

  11. Comparing Paradigms (Cont) Object-oriented: the components of a system can be organized as objects -- really “agents” than encapsulate data and know how to perform methods on that data. Visual data-flow: the computation can be laid out as a network of processing stations with paths that carry data from one to another. Scripting: the problem is to control a collection of higher-level capabilities already written, possibly in other languages. Scripting is like glueing various services together to create new ones or automate a sequence of program invocations that would otherwise be done manually. CSE 341 -- S. Tanimoto Paradigms

  12. Rapid Prototyping vs Product Development Rapid prototyping: full product specifications typically unavailable. Minor bugs may not be a problem. Programmer time is of the essence. Early semantic feedback emphasized above thorough error checking. High-level features (e.g., garbage collection, infinite-precision integers) that remove burdens from the programmer are prominent, even if they slow performance. Product development: product specification is complete or almost complete. Bugs will be highly embarrassing or worse. Compilers with strict type checking and the use of test protocols are prominent. Correct adherence to spec is very important, as is maintainability of code. Code optimization for performance is often an issue. CSE 341 -- S. Tanimoto Paradigms

More Related