1.2 programming paradigms

0.0(0)
studied byStudied by 10 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/31

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

32 Terms

1
New cards
procedural programming
programming paradigm where programs are formed from sequences of instructions and broken down modularly into routines and subroutines
2
New cards

characteristics of procedural programs

-instructions are executed in the order in which they appear

-subroutines can be called from anywhere in the program

-data is stored as variables and constants

-data structures can have a local or global scope

3
New cards
structured approach to program design and construction
uses assignment, sequence, selection and iteration
4
New cards

characteristics of the structured approach

-designed from the top down(elements are broken down into smaller tasks)

-keeps programs easy to understand and maintain as they are easier to navigate

-testing can be carried out on individual modules

-easier to develop collaboratively as each module can be assigned separately

5
New cards
hierarchy charts

charts representing the structure of a structured program

each procedure is diaplayed as a rectangle and connected to parent or child procedures with a line, with parent procedures above their children

6
New cards

object-oriented programming

programming paradigm where programs are formed from, and designed around, objects which contain their own properties and methods

7
New cards

OOP main principles

inheritance, encapsulation, abstraction and polymorphism

8
New cards
why OOP is used

-programs have a clear structure which makes developing and testing easier, as well as splitting projects among teams

-the use of classes allows code to be reused throughout the program(and sometimes in other programs) improving readability and data efficiency

9
New cards

class

a blueprint for objects specifying their properties and methods

(a “type of thing”)

10
New cards
properties and methods

data and instructions in a class, respectively

can be public or private(accessible from anywhere in the program, or only from within the object and its inheritors)

11
New cards
class definitions
lists of a class's name, properties and methods in text form
12
New cards
object
containers of data and instructions created from a class
13
New cards

instantiation

the creation of an instance of an object from a class using a constructor

14
New cards
constructor

a method in a class called to create and initialise an object from it, assigning a reference to a variable of the class type

constructors can be implicit(automatic, with default parameters) or explicit(eith user-defined parameters)

15
New cards
encapsulation
the process of combining properties and methods to form a class
16
New cards
inheritance
the process by which a class is given the properties and methods of another class in addition to its own, in an is-a relationship
17
New cards
overriding
when a class inherits another it can override its methods, changing the implementation but keeping the name(for itself, not the inherited class)
18
New cards

association

associated objects form part of their container object as a property, in a has-a relationship

19
New cards
aggregation
association where an object will continue to exist if its container object is destroyed
20
New cards
composition
association where an object will cease to exist if its container object is destroyed
21
New cards
polymorphism
where objects are processed differently depending on their class
22
New cards

OOP design principles

-encapsulate what varies

-favour composition over inheritance

-program to interfaces, not implementation

23
New cards
encapsulate what varies
components of a program which are likely to change should be encapsulated as it better protects against said changes unwantedly affecting other parts of the program
24
New cards
favour composition over inheritance
composition should be used over inheritance wherever possible as it is seen as more flexible
25
New cards

program to interfaces, not implementation

programming to depend on interfaces rather than implementations improves code flexibility, and allows unrelated classes to easily make use of similar methods

26
New cards

interface

a set of abstract procedures determining what methods an object should have, without providing the code for them

27
New cards

implementations

classes that fulfil the rules determined by interfaces and provide the code

28
New cards

class diagrams

used to visually represent the relationships that exist between classes

classes are represented by boxes with different connectors representing different kinds of relationship, can exhibit various levels of detail

<p>used to visually represent the relationships that exist between classes</p><p>classes are represented by boxes with different connectors representing different kinds of relationship, can exhibit various levels of detail</p>
29
New cards

inheritance diagrams

sshow inheritance relationships that exist between classes- unfilled arrows point from classes to their inheritees and always point upwards

<p>sshow inheritance relationships that exist between classes- unfilled arrows point from classes to their inheritees and always point upwards</p>
30
New cards

association in class diagrams

association is shown in class diagrams using diamond headed arrows, unfilled and filled diamonds correspond to aggregation and composition respectively

<p>association is shown in class diagrams using diamond headed arrows, unfilled and filled diamonds correspond to aggregation and composition respectively</p>
31
New cards

association in UML

in unified modelling language, association between two classes is modelled using lines

a normal line represents bidirectional association while a line with an arrow represents one-way association where a class can call the one the arrow is pointing to but not vice versa

32
New cards

class diagrams with properties and methods

class boxes are split into three, containing the class's name, properties and methods from top to bottom respectively

plus and minus signs in front of properties and methods denote they are public and private respectively

hashtags indicate protected properties or methods

<p>class boxes are split into three, containing the class's name, properties and methods from top to bottom respectively</p><p>plus and minus signs in front of properties and methods denote they are public and private respectively</p><p>hashtags indicate protected properties or methods</p>