32 terms

IB Comp Sci Paper 2 Option D: Object Oriented Programming


Terms in this set (...)

D.1.1 Outline the general nature of an object
An object is an abstract entity in computer science. It represents an abstraction of a complex concept and thus allows programmers to deal with a large amount of interlinked data without having to deal with all of its detail at once. A real life example is a car engine. You don't need to be able to know exactly how an engine works to be able to operate it, you only need to know how its abstraction - the control elements in the cockpit - works. This also allows you to deal with many different types of engines because although they work differently but their abstractions are largely similar.
D.1.2 Distinguish between an object (definition, template or class) and instatiation
An class is the coded description of an object. It provides methods for the object to allow it to carry out actions, and describes its properties.
An instantiation of an object is the physical storage space reserved for an object where its properties and current state can be stored. There can be only one class describing an object, but many instantiations of an object can exist within a program.
D.1.3 Construct unified modelling language diagrams to represent object designs
D.1.4 Interpret UML diagrams
D.1.5 Describe the process of decomposition into several related objects
Decomposition in computer science, also known as factoring, refers to the process by which a complex problem or system is broken down into parts that are easier to conceive, understand, program, and maintain. Object-oriented decomposition breaks a large system down into progressively smaller classes or objects that are responsible for some part of the problem domain.
D.1.6 Describe the relationships between objects for a given problem
Objects can have three kinds of relationships:
-the has-a relationship
-the is-a relationship
-the uses-a relationship
The has-a relationship means that one type of object contains another or is composed of another. Some examples are: a car has-an engine, a bicycle has-a wheel, and a coffee cup has coffee. The has-a relationship is modeled with composition, which is discussed in Chapter 6.
The is-a relationship means that one type of object is a more specific version of a general type. Some examples are: a car is-a vehicle, a bicycle is-a vehicle, and a coffee cup is-a cup. The is-a relationship is modeled with inheritance, which is also discussed in Chapter 6.
The uses-a relationship means that during some activity, one type of object uses another type of object. Some examples are: a car uses-a squeegee (during a window-washing activity), a bicycle uses-a pump (during a tire-pumping activity), and a coffee cup uses-a stirrer (during a stirring activity).
D.1.7 Outline the need to reduce dependencies between objects in a given problem
If many things are interdependent in a program, changing one part can be very difficult as all dependencies must be taken into account when making changes. This increases difficulty of maintenance. Therefore, dependencies should be kept to a minimum or standard calling procedures should be implemented.
D.1.8 Construct related objects for a given problem
Scenario: a school students&staff database has to be developed with personal details of every people in the school.
Because students and teachers both have common properties, a master class is useful from which both groups will inherit some of their properties.
Object people: This object stores the general details of the people in the school, like gender, age, phone number and home address.
Object students: This objects inherits all the properties of the people class and adds some more properties specific to students, like grade, marks for subjects and days missed.
Object teachers: This object inherits all the properties of the people class and addso some more properties specific to teachers, like homeroom, days sick, salary and subjects teached.
In this scenario, only objects of teachers and students would be instantiated, but because they inherit from the people class, they will possess properties of this class. people is now a superclass while teachers and students are a subclass.
D.1.9 Explain the need for different data types to represent data items
Data is stored as a combination of binary values in the computer. Data types are used to store different kinds of data, like text, numbers, floats or other values. They are needed because they specify to the computer how to interpret the binary values in the storage.
D.1.10 Describe how data items can be passed to and from actions as parameters
In many programming languages, data can be passed to methods to calculate with. This is done by giving them to the method while calling it as parameters. In Java and C# parameters are given in brackets after the calling name of a method:
int s = addInt(3,2);
public int addInt(int Parameter1, int Parameter2){
int result = Parameter1 + Parameter2;
return result;
D.2.1 Define the term encapsulation
Encapsulation is enclosing the properties and methods of an object so that they can easily be dealt with and are secured against invalid changes. This usually means making their object variables inaccessible from outside their class and using methods with security check mechanisms to change those variables.
D.2.2 Define the term inheritance
inheritance is when an object inherits or adapts the properties and methods of an other object and uses them as if they were its own. An object of the other class does not need to be instantiated for this.
D.2.3 Define the term polymorphism
Polymorphism is the method of defining multiple methods with same names but with different parameters in order to deal with different parameter configurations. When such a method is called the program automatically selects the method whose parameter configuration matches the parameters given by the calling method.
D.2.4 Explain the advantages of encapsulation
-Direct access to the variables of an object can be restricted. This reduces the risk of accidentally setting invalid values as properties.
-Security checks can be implemented to avoid setting invalid values as properties.
-If methods are set to access properties, objects inheriting properties can also use them → less complexity in the program
private int age;
D.2.5 Define the advantages of inheritance
It is possible that many objects share a set of common properties and functions that they have inherited from a common object. The advantage is that it is easy to add functionality to the objects. If for example, in the school database both the teachers and students would need a property for storing an email address, this could be implemented in the people class. This way, the properties and methods would have to be implemented only once, which would make development easier and less prone to errors.
D.2.6 Define the advantages of polymorphism
A method can accept various sets of parameters. For example, the method in the people class that is used to set a phone number could be implemented in a way to accept a string as a phone number and in a way to accept an integer as phone number. This way, phone numbers could be entered using both ways.
D.2.7 Desribe the advantages of libraries of objects
Sorting and other complex algorithms and processes do not have to be re-invented.
D.2.8 Describe the disadvantages of OOP
-Increased complexity for small problems
-Unsuited for some kinds of problems
D.2.9 Discuss the use of programming teams
Compared to working alone, programming teams can have many advantages:
-People can work on many parts of a program at the same time, reducing time needed
-Code can be cross-checked to avoid mistakes
-Because people don't see other's information, module dependencies are reduced due to information hiding
-Expertise can be concentrated in a narrow field
D.2.10 Explain the advantages of modularity in program development
-Modules can be tested and debugged separately
-Time reduced as work can be done on many modules simultaneously
-Modules can be easily changed, so easier maintenance
-Internal structure of moduls can be changed without having to worry about the other modules → easier code optimisation
An abstract model for objects. It defines the properties and methods of an object. It is like a data type for an object. For example, in Java strings are not fundamental variables like integers but objects
A pointer that explicitly identifies an object. Generally, it is the variable name
primitive data types are the ones involving the most basic entities in informatics: numbers. Other data types like arrays are abstract because they combine many primitive data types.
Instance Variable
A variable in a class from which every instantiated object gets its own copy. If a class called people would have an instance variable called age, every object of this class would have its own variable called age.
Parameter Variable
A variable that is passed along to a function that is called to perform operations with. In Java it is the argument passed in the brackets with the function caller.
Local Variable
A variable declared inside a function. This variable is only known and accessible by the function it is declared inside.
A method is a set of rules defining operations that are executed.
A method used to return values of a private variable of an object.
A mutator is a method used to control changes to the private variables of an object. Setter and accessor methods are mutator methods.
The method called when an object is instantiated.
Defines the inputs and outputs of a method. In some programming languages it even defines the errors thrown by the function.
Return Value
Specifies the data type that a function returns to its caller.