Please enable JavaScript.
Coggle requires JavaScript to display documents.
set 5 flash cards - Coggle Diagram
set 5 flash cards
composition
the advantage of composition over the inheritance is that it is easier to test each class using unit testing
favoring composition over inheratence means that using objects composed of others objects rather than a tightly coupled inheritance system. It allows more flexibility if you need to modify your program later
composition and aggregation are similar in a way that they both have a relationships. This means that the class owns the other class
the difference between them if in composition containg (owning) object is destroyed the others will be destroyed. In aggregation this doesn't happen
-
OOP
advantages of oop
classes are highly modular - makes it easy to maintain
promotes code reuse
encapsulation provides high level of protection
drawbacks
can lead to very large and complex systems
objects can take up a relativly large amount of memory which is an issue if there are hardware restrictions
oop principles are
encapsulates what varies
favor composition over inheritance
program to interfaces not implementations
inheratence is needed to create a hierarchy of specialisations for classes e.g. public class Lion : Animals
-
hierarchy chart is needed to represent the structure of the program by showing which subroutine is called from which subroutine
-
access modifier protected means that it can be accessed by any subclasses and from within the class itself. It has a "#" symbol
-
-
subroutines
advantage
allows code re-use
allows to modularisation of the code
it makes easier to identify bugs (glitches in the code)
it makes it easier to test individual tasks
it makes it easier for other programmers to interpret and understand your code
-
encapsulation is a process of combining properties and methods together into an object and being able to restrict access to an object's state/behaviour
encapsulating what varies design principle means that when designing a program in OOP any requirements which are likely to change in the future should be encapsulated in a class so that any changes can be easily made when required
a constant is a data item that once declared retains the same value for the entire duration of the program run
enchances the codes safery by preventing accidental changes to the code to the values that should be changed
makes the code more readable by clearly indicating that this value shouldn't be modified
to find value x in binary search
- Look at the item in the centre of the sorted list
- if it isn't X
if its larger than X ignore all the values above if its smaller than X ignore all the values below
- check middle of halved list and repeat until you find x
-
-
-
subtype polymorphism is when a method in a parent class also exists in a derived class
the method has the same name and parameter list but a different implementation
it allows the objects up and down inheritance hierarchy chain to respond differently to the use of a commnon interface
structured programing approach is when decompostion of a problem occurs by using block structures (subroutines)
structured programing makes a use of control structures like sequence selection and iteration
user defined data types are the data types that are derived from existing built in types in order to create a custom data structure