Title: Paradigms of programming
1Paradigms of programming
2The program a code data
- Code - algorithm of processing (action, process,
procedure, function) - Data - processable given by the algorithm, set in
the form of the certain structures of data - Programs algorithms structures of data
-
(N. Virt) -
-
3Paradigm
- - This rule of development of scientific
- knowledge
- - A way of thinking in programming
- - The basic approach, managements of
- designing of programs
- - The internal organization of the text of
- the program
4The basic paradigms
- The Procedure-oriented programming (at which the
program is considered the approach the model
focused on process (process-oriented model)) - Object-oriented programming (the approach at
which is done access operated by data to a code
(data controlling access to code))
5Rules of structural programming - rules of
registration of the text of the program
- 1. Use of base structures of algorithm
- Unconditional action (function)
- Branching
- Recurrence
- 2. Ways of a combination of base structures
- Consecutive connection
- Investment of one structure inside of another
- 3. The structured coding
6Procedure-oriented programming
- Idea the Problem gt subtasks
- Idea Programm gt Subroutines
result
data
Algoritm (task, programm)
data
result
subroutine1
subroutine2
subroutine3
7Task R a b. Example_0 Programm without
user Subroutines (Delphi)
- program Lab1a
- APPTYPE CONSOLE
- uses
- SysUtils
- VAR a, b, r Integer
- begin
- Write('Vvedite a ') Readln(a)
- Write('Vvedite b ') Readln(b)
- r a b
- WRITELN('summa', r) // WRITELN('summa',
a b) - READLN
- end.
-
8Subroutines (Delphi)
9Function
- Function summa (a,bInteger)Integer
- Begin
- Resultab
- End
10Procedure
- Procedure summa (a,bInteger var R)
- Begin
- Rab
- End
11Task R a b. Example_1
Procedure-oriented programming (Delphi)
- program Lab1b
- APPTYPE CONSOLE
- uses
- SysUtils
- Function summa (a,bInteger)Integer
- Begin
- Resultab
- End
- VAR x,yInteger
- begin
- Write('Vvedite x ') Readln(x)
- Write('Vvedite y ') Readln(y)
- WRITELN('summa', summa(x,y))
- READLN
- end.
12Module Programming
- Concept of the module
- The module is a subroutine, but issued according
to special rules. - The module should have one input and one output
and carry out strictly unequivocal function which
is described by a simple sentence. - The module should provide the compilation
independent of other modules, with to forget
all internal designations of modules. - The module can cause other modules on their
names. - Module Programming
- Modularity of programs
- Structural coding of modules of programs
- Descending designing of rational hierarchy of
modules of programs - Descending realization of the program with use
???????? - Realization of planning at all stages of the
project - The through structural control of program
complexes over the whole and modules making them.
13Task R a b. Example_2 Module
Programming (Delphi)
- The program using the subroutine-module
- program Lab1c
- APPTYPE CONSOLE
- uses
- SysUtils,
- Unit1c in 'Unit1c.pas' // The connected
module - VAR x,yInteger
- begin
- Write('Vvedite x ') Readln(x)
- Write('Vvedite y ') Readln(y)
- WRITELN('summa', summa(x,y))
- READLN
- end.
-
14Task R a b. Example_2 Module
Programming (Delphi)
- The used subroutine-module
- unit Unit1c
- interface
- Function summa
- (a,bInteger)Integer
-
- implementation
- Function summa (a,bInteger)Integer
- Begin
- Resultab
- End
- end.
15Object-oriented programming
- Statement of a problem in the form of set of
operating objects (??? - object-oriented-analysis)
- Designing of complex program systems in the form
of objects (OOD - object-oriented-design)
16Object-oriented-analysis
- Creation of models of reality of a problem on the
basis of object-oriented thinks, the description
of a problem in its expressions. - It is methodology at which requirements to
program system are perceived from the point of
view of classes and the objects pragmatically
revealed in a subject domain of a problem - Objects correspond concrete ????????? problems,
and classes are their abstraction acting in a
role of concepts. - The class is the description of how its
representative-object will look and behave. A
class - logic, object - the physical design
existing in memory. - Any component of a problem can be considered as
object with characteristics (data) and behaviour
(action). Their object incapsulation. - Each object in the text of the program is
considered a copy of a class (type) or it is the
structured variable of type a class. A class -
abstract type of data - The object (objective variable) stores data, but
you can do inquiries to object, asking to
make actions above yourselves
17Object-oriented-design
- Designing of program system on the basis of model
OOA - Programming in terms of a problem, the decision
of a problem in its space, instead of in terms of
a computer. - Process of realization of the programs, based on
representation of the program in the form of set
of objects - copies of classes. - Each class should make the separate program
module (modularity). - Programming from a class to a class . Classes
are formed in the program as required
descriptions new physical objects problems or
their abstract concepts (abstraction) - Can create new object (class) by means of laying
in it already existing classes-objects
(inheritance) - Definition of various forms of realization of the
same action. All objects of the certain type
(class) can receive identical messages
(polymorphism).
18Task R a b. Example_3 Object-oriented
programming (Delphi)
- The basic program using the module-class
- program Lab1d
- APPTYPE CONSOLE
- uses
- SysUtils,
- Unit1d in 'Unit1d.pas' // module-class
- Var arifmOperacia TarifmOperacia
- BEGIN
- arifmOperacia TarifmOperacia.Create
- arifmOperacia.dane
- writeln('summa ', arifmOperacia.summa)
- READLN
- END.
19Task R a b. Example_3
Object-oriented programming (Delphi)
- The connected module - class
- unit Unit1d
- interface
-
- Type TarifmOperacia class
- private
- a, b Integer
- public
- Procedure dane
- Function summa Integer
- end
- implementation
- Procedure TarifmOperacia.dane
- begin
- write('a ') readln(a)
- write('b ') readln(b)
- end
- Function TarifmOperacia.summa Integer
- Begin
- Resultab
- End
- end.
20The events and visual programming
- The events -visual programming in many respects
automates work of the programmer on a writing of
programs. - The events -visual programming - one of the most
popular paradigms of programming at present. It
is based on technology ???. - The environment of visual programming supports
work of browsers by means of which it is possible
to receive automatically the documentation on
structure of the program. - Basic element in environments of visual
programming is the component. Components happen
visual and not visual. - The technology of The events -visual programming
consists in the following - Creation of screen forms
- Drawing visual and not visual a component
- Programming of events and methods of window forms
21The events -visual programming (Delphi). Task R
a b. 1. Creation of screen forms2.
Drawing visual and not visual a component
22Task R a b. Example_4 The
events -visual programming (Delphi). 3.
Programming of events and methods of window forms
- program Lab1e
- uses
- Forms,
- Unit1e in 'Unit1e.pas' Form1
- R .res
- begin
- Application.Initialize
- Application.CreateForm(TForm1, Form1)
- Application.Run
- end.
- unit Unit1e
- interface
- uses
- Edit2 TEdit
- Label1 TLabel
- Label2 Tlabel
- Label3 Tlabel
- procedure Button1Click(Sender TObject)
- private
- Private declarations
- public
- Public declarations
- end
- var
- Form1 TForm1
- implementation
- R .dfm
23Resume
- On an example of Delphi-programs, decisions of
the same problems, it has been shown distinctions
of the internal organization of the text of
programs at use of various paradigms of
programming.