1/13
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
what is a programming paradigm?
a style/approach to computer programming
what is procedural programming?
has a series of instructions which tell the computer what to do with the input in order to solve the problem
structured programming is a type of procedural programming which uses sequence, selection, iteration, modular techniques and recursion
has built in data types and data structures (and programmers can define their own abstract data types)
what is object-oriented programming?
developed to make it possible to abstract implementation details, make code reusable and programs easy to maintain
requires thinking in terms of objects that will carry out required tasks, rather than data structures and algorithms
what is declarative programming?
like SQL, programmer writes statements describing the problem to be solved and describing what should be outputted, and the language decides the best way of solving it
what is functional programming?
statements are written as a series of functions which accept input data as arguments and return an output
what is a class in OOP?
a blueprint that defines what attributes and methods an object of a certain type should have
what are objects in OOP?
data items that are an instance of a class, can represent a real object like a cat or a car, or an abstract object like a data structure
what are attributes in OOP?
the information shared by any object of the same class type (can be manipulated like variables)
what are methods in OOP?
Code/subroutines associated with the class that allows you to access or change the attributes (getting or setting)
The constructor method runs when an object of that class type is instantiated
The constructor method takes the values of the parameters passed into the object and sets the object's attributes to those values
what is an instance in OOP?
when an object is created from a class template and is given its own set of attributes
what is inheritance in OOP?
When a subclass is created, it inherits (reuses) its attributes and methods from the superclass, so when objects are created from the subclass, they can use the same methods as the superclass
The subclass might also have extra methods and attributes on top of the ones inherited from the superclass
what is encapsulation in OOP?
Encapsulation is when attributes are declared to be private so that they cannot be accessed directly; they can only be accessed or changed through the methods provided by the object
Encapsulation hides the values or internal state of an object, preventing direct access by unauthorised parties (so the attributes can’t be accidentally altered)
Attributes are normally set to private and methods are set to public (so the methods can be used to alter the attributes)
what is polymorphism in OOP?
a programming language's ability to process objects (carry out methods) differently depending on their class
Static polymorphism= implementation of multiple methods of the same name, but with different parameters, in the same class
For this to work, the methods must have a different number/order/type of parameters
Dynamic polymorphism= allows a subclass to override a method of its superclass: allows the programmer of the subclass to customise or completely replace the behaviour of that method
Both methods have the same name and parameters, but they have different functionality depending on whether they are implemented by the subclass or the superclass
what are the advantages of OOP?
forces designers to plan more so less weaknesses
encapsulation is good because objects’ code can be written/tested/maintained independently of other objects’ code
other programmers don’t need to know the implementation of the methods to use the object
easy to create new objects
reusable code
good framework for code libraries
easier to maintain due to modular structure