background preloader

Meemoo project by Forrest Oliphant

Meemoo project by Forrest Oliphant
Related:  Programming Paradigms

Structured programming It emerged in the 1960s—particularly from work by Böhm and Jacopini,[1] and a famous letter, Go To Statement Considered Harmful, from Edsger Dijkstra in 1968[2]—and was bolstered theoretically by the structured program theorem, and practically by the emergence of languages such as ALGOL with suitably rich control structures. Low-level structured programming[edit] At a low level, structured programs are often composed of simple, hierarchical program flow structures. Graphical representations of the three basic patterns. Structured programming languages[edit] History[edit] Theoretical foundation[edit] The structured program theorem provides the theoretical basis of structured programming. Debate[edit] P. Us converts waved this interesting bit of news under the noses of the unreconstructed assembly-language programmers who kept trotting forth twisty bits of logic and saying, 'I betcha can't structure this.' Outcome[edit] Common deviations[edit] Early exit[edit] Exception handling[edit]

Procedural programming Procedures and modularity[edit] Scoping is another technique that helps keep procedures strongly modular. It prevents the procedure from accessing the variables of other procedures (and vice-versa), including previous instances of itself, without explicit authorization. Because of the ability to specify a simple interface, to be self-contained, and to be reused, procedures are a convenient vehicle for making pieces of code written by different people or different groups, including through programming libraries. Comparison with imperative programming[edit] Procedural programming languages are also imperative languages, because they make explicit references to the state of the execution environment. Comparison with object-oriented programming[edit] Nomenclature varies between the two, although they have similar semantics: See also: Algorithms + Data Structures = Programs Comparison with functional programming[edit] Procedures correspond to functions. Comparison with logic programming[edit]

Semantic-oriented programming Common features[edit] The way of how these semantic information are represented in the system vary according to the approach chosen (see below), common to these approaches are the following features: Goals[edit] The goals of SOP are: Improving the maintainability of a softwareImproving the transparency of a softwareFlexibility by allowing exchangeability of logic and/or implementationOptimal support for agile development processes (refactoring) SOPlets[edit] Soplets is a method of describing semantic concepts as blocks of code, using existing features of the (Java) language, namely annotations and enumerations. Soplets can be referenced and used from anywhere inside the code. A Soplet may be enhanced by one or more (stateless) functions, which are directly attached to the code block. The structure of a Soplet is formally defined by the stereotype it implements. SymADE[edit] In SymADE a program is edited and stored as a tree of semantic nodes (meanings). See also[edit] External links[edit]

Active object The pattern consists of six elements:[3] See also[edit] References[edit] Jump up ^ Douglas C. Schmidt; Michael Stal; Hans Rohnert; Frank Buschmann (2000). Pattern-Oriented Software Architecture, Volume 2: Patterns for Concurrent and Networked Objects. Object-oriented design Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Overview[edit] What follows is a description of the class-based subset of object-oriented design, which does not include object prototype-based approaches where objects are not typically obtained by instancing classes but by cloning other (prototype) objects. Object-oriented design topics[edit] Input (sources) for object-oriented design[edit] The input for object-oriented design is provided by the output of object-oriented analysis. Some typical input artifacts for object-oriented design are: Object-oriented concepts[edit] The five basic concepts of object-oriented design are the implementation level features that are built into the programming language. Designing concepts[edit] Output (deliverables) of object-oriented design[edit] Some design principles and strategies[edit] See also[edit] References[edit] External links[edit]

Responsibility-driven design Responsibility-driven design is a design technique in object-oriented programming. It was proposed by Rebecca Wirfs-Brock and Brian Wilkerson, who defined it as follows: Responsibility-driven design is inspired by the client/server model. It focuses on the contract by asking:What actions is this object responsible for? Responsibility-driven design is in direct contrast with data-driven design, which promotes defining the behavior of a class along the data that it holds. The client/server model they refer to assumes that a software client and a software server exchange information based on a contract that both parties commit to adhere to. Building blocks[edit] In their book Object Design: Roles, Responsibilities and Collaborations,[1] the authors describe the following building blocks that make up responsibility-driven design. Objects[edit] Objects are described as things that have machinelike behaviors that can be plugged together to work in concert. Roles[edit] Control style[edit] Advantages

Data-driven programming In computer programming, data-driven programming is a programming paradigm in which the program statements describe the data to be matched and the processing required rather than defining a sequence of steps to be taken.[1] Standard examples of data-driven languages are the text-processing languages sed and AWK,[1] where the data is a sequence of lines in an input stream – these are thus also known as line-oriented languages – and pattern matching is primarily done via regular expressions or line numbers. Data-driven programming is similar to event-driven programming, in that both are structured as pattern matching and resulting processing, and are usually implemented by a main loop, though they are typically applied to different domains. Adapting abstract data type design methods to object-oriented programming results in a data-driven design.[2] This type of design is sometimes used in object-oriented programming to define classes during the conception of a piece of software.

Imperative programming The term is used in opposition to declarative programming, which expresses what the program should accomplish without prescribing how to do it in terms of sequences of actions to be taken. Functional and logic programming are examples of a more declarative approach. Imperative, procedural, and declarative programming[edit] Procedural programming could be considered a step towards declarative programming. A programmer can often tell, simply by looking at the names, arguments and return types of procedures (and related comments), what a particular procedure is supposed to do, without necessarily looking at the details of how it achieves its result. At the same time, a complete program is still imperative since it 'fixes' the statements to be executed and their order of execution to a large extent. Declarative programming is a non-imperative style of programming in which programs describe their desired results without explicitly listing commands or steps that must be performed. History[edit]

Object-oriented programming Overview[edit] Rather than structure programs as code and data, an object-oriented system integrates the two using the concept of an "object". An object has state (data) and behavior (code). Objects correspond to things found in the real world. So for example, a graphics program will have objects such as circle, square, menu. The goals of object-oriented programming are: Increased understanding.Ease of maintenance.Ease of evolution. The overall understanding of the system is increased because the semantic gap—the distance between the language spoken by developers and that spoken by users—is lessened. Object-orientation takes this to the next step. In addition to providing ease of maintenance, encapsulation and information hiding provide ease of evolution as well. An object-oriented program usually contains different types of objects, each corresponding to a real-world object or concept such as a bank account, a hockey player, or a bulldozer. History[edit] A survey by Deborah J.

Logic programming Logic programming is a programming paradigm based on formal logic. Programs written in a logical programming language are sets of logical sentences, expressing facts and rules about some problem domain. Together with an inference algorithm, they form a program. Major logic programming languages include Prolog and Datalog. A form of logical sentences commonly found in logic programming, but not exclusively, is the Horn clause. p(X, Y) if q(X) and r(Y) Logical sentences can be understood purely declaratively. The programmer can use the declarative reading of logic programs to verify their correctness. History[edit] The use of mathematical logic to represent and execute computer programs is also a feature of the lambda calculus, developed by Alonzo Church in the 1930s. In 1997, the Association of Logic Programming bestowed to fifteen recognized researchers in logic programming the title Founders of Logic Programming to recognize them as pioneers in the field:[1] Prolog[edit] H :- B1, …, Bn.

Programming paradigm A programming paradigm is a fundamental style of computer programming, a way of building the structure and elements of computer programs. Capablities and styles of various programming languages are defined by their supported programming paradigms; some programming languages are designed to follow only one paradigm, while others support multiple paradigms. There are six main programming paradigms: imperative, declarative, functional, object-oriented, logic and symbolic programming.[1][2][3] Overview[edit] Overview of the various programming paradigms[4]:5 In object-oriented programming, programmers can think of a program as a collection of interacting objects, while in functional programming a program can be thought of as a sequence of stateless function evaluations. Programming paradigms can also be compared with programming models which are abstractions of computer systems. History[edit] Machine code[edit] Procedural languages[edit] All these languages follow the procedural paradigm.

Event-driven programming Event handlers[edit] A trivial event handler[edit] Because the code for checking for events and the main loop do not depend on the application, many programming frameworks take care of their implementation and expect the user to provide only the code for the event handlers. In this simple example there may be a call to an event handler called OnKeyEnter() that includes an argument with a string of characters, corresponding to what the user typed before hitting the ENTER key. globally declare the counter K and the integer T. While keeping track of history is straightforward in a batch program, it requires special attention and planning in an event-driven program. Exception handlers[edit] Creating event handlers[edit] The second step is to bind event handlers to events so that the correct function is called when the event takes place. Criticism and best practice[edit] and advocates the use of state machines as a viable alternative.[2][clarification needed] Stackless threading[edit]

Event loop When the event loop forms the central control flow construct of a program, as it often does, it may be termed the main loop or main event loop. This title is appropriate because such an event loop is at the highest level of control within the program. Message passing[edit] Alternative designs[edit] This approach is in contrast to a number of other alternatives: Traditionally, a program simply ran once then terminated. Usage[edit] function main initialize() while message ! File interface[edit] For example, consider a program that reads from a continuously updated file and displays its contents in the X Window System, which communicates with clients over a socket (either Unix domain or Berkeley): main(): file_fd = open ("logfile") x_fd = open_display () construct_interface () while changed_fds = select ({file_fd, x_fd}): if file_fd in changed_fds: data = read_from (file_fd) append_to_display (data) send_repaint_message () if x_fd in changed_fds: process_x_messages () Handling signals[edit]

Related: