SDD half-yearly Flashcards

1
Q

Main OOP concepts:

A

Inheritance
Polymorphism
Encapsulation
Superclass and Subclass

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is instantiation?

A

The process of creating an object from a class is called instantiation. Attributes get allocated for that class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is generalisation

A

Extracting the essential characteristics from 2 or more subclasses and combining them under one base class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Explain why using the OOP paradigm is appropriate for developing this
software. In your response, refer to relevant OOP concepts.

A
  • Inheritance: There is a superclass called __ with subclasses for each __. Many attributes and methods common to each subclass are inherited from the superclass. Polymorphism: Each instance of a subclass behaves slightly differently to the same input. For example, a dog will react differently to a command given by its owner and by a stranger.
    These concepts make OOP appropriate as there will not be a need to write code defining the attributes and methods of each subclass.
    In addition, it gives the programmer the scope to have similar methods react differently to the same input.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe abstraction in the context of object-oriented programming

A

Hides the complexity and finer details of a class/object, to allow for convenient usage and maintenance. E.g. class signature - print() function in python allows you to use function without needing to know the inner details of the function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

With reference to the fragment of code above, explain the importance of
inheritance in the OOP paradigm. (3)

A

My answer (3 points for 3 marks):
Inheritance enables attributes of a superclass to be automatically assumed by its subclasses, thus saving the programmer from having to redefine them.
1. We do not need to re-write the common attributes and methods while modelling a WATERBIRD since it inherits from the BIRD class
2. Evolution of the program can be done easily, say by adding a new subclass for NON_FLYING_BIRD
3. We could use method overriding (a type of polymorphism) to change the behaviour of a subclass

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Explain the relevance of OOP in developing the computer game

A

Since the computer game consists of various characters, these characters can be defined as objects. These characters or objects can be given common characteristics, and they may inherit their attributes from a parent class. These characters or objects can also interact with each other in specified ways through defined methods.
Polymorphism, specifically method overriding, can be used to dynamically change the behavior of objects based on different inputs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is Encapsulation

A

Bundling of attributes and methods into a single object with the use of a class. This means data inside an object is not modified unexpectedly by external code in a completely different part of the program, written by a different programmer.used to hide components or values of an object within a class from other objects, which helps to restrict access to the object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is polymorphism

A

Polymorphism can either mean overloading or overriding depending on the scenario:
With respect to overloading, polymorphism means that the same class can have 2 different methods of the same name based on the data type parsed into the class through the parameters e.g. the + operator adds 2 ints normally, but combines them when they are 2 strings

With respect to inheritance, polymorphism is called overriding which is the changing of the behaviour of an inherited method from the parent class. i.e. a method with the same name (function signature) and same parameters acts differently when it skips the superclass method and instead goes straight to the subclass method of the same name (overriden) e.g.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Describe how polymorphism is used in the code provided. Refer to line numbers in your response. (3)

A

The methods on lines 3 and 8 have the same name, operator, but act differently when given different parameters. Calling the method ‘operator’ on line 16 executes different logic from calling the method ‘operator’ on line 17 as the parameters have different data types. Therefore, the processing of the method ‘operator’ changes based on the parameters provided when the method is called.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Imperative paradigm

A

old paradigm where data and processes are separated and the entire program is a single algorithm or has complete functionality and is written linearly, that is, step-by-step. sometimes it is used when speed and efficiency is prioritised.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Object orientated programing paradigm

A

Object-oriented programming is a programming paradigm based on the concept of objects, which can contain data and formed from classes: data in the form of attribute values, and code in the form of classes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is meant by an object?

A

An object is an instance of a class and has specific values for its attributes. Hence two objects of the same class can have different values for its attributes, indicating its current state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are classes?

A

A template that encapsulates the methods and attributes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Describe system modelling.

A

System modelling - covers the manual (user-side) and mechanic (automatic/computer-side) operations as well as the computing operations of a system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

System defintion

A

comprises of hardware, software, and people interacting with it

17
Q

Structured programming

A

Describes any programming when functionality is divided into units (block structures) including for loops, while loops, if … then and so on. These units (functions) can be re-used.

18
Q

Modular programming

A

Refers to when chunks of code are created to form packages that are general purpose and re-usable. These modules can then be compiled together.

19
Q

Describe what a data flow diagram is and what it does.

A

A data flow diagram (DFD) is a visual representation of the information flow through a process or system, including processes, external entities and data stores.

20
Q

advantages and disadvantages of a structure chart.

A

Advantages of a structure chart:
Hierarchy of modules
Indicates whether a module is called based on a condition being true as well as whether it is repeatedly called
Illustrates the data required to call a module
Illustrates the return values from a module

Disadvantages of a structure chart:
Too much information can cause clutter
Harder to understand the flow compared to simple hierarchy charts
Takes longer to design

21
Q

Describe what a class diagram is and what it does.

A

It is an abstraction of a class illustrating its attributes and methods, data types of attributes, method signatures(headers), parameters expected and return types of the method, in addition it also identifies whether an attribute or a method is private or public.

22
Q

Method signatures meaning

A

first message headers of a method - you know how the method needs to be called without needing the finer details - reduces the time of checking the values that need to be parsed

23
Q

Task definition definition

A

A task definition, sometimes referred to as a problem statement, is a short, clear explanation of an issue or challenge that sums up what you want to change.

24
Q

Top-down and bottom-up

A

In programming, a top-down approach, also referred to as stepwise design, is a complex algorithm broken down into smaller units referred to as modules.

Bottom-up approach entails designing an algorithm by starting at the very basic level and building it up towards the complex level.  In the approach the modules are designed independently and are then integrated together to form a complete algorithmic design.

25
Q

Facade pattern defintion

A

A Facade pattern hides the complexities of the system and provides an interface to the client from where the client can access the system.
Dividing a system into subsystems helps reduce complexity.
To minimise the communication and dependencies between subsystems a facade object provides a single, simplified interface to the more general facilities of a subsystem.
The facade pattern is used when:

26
Q

The agility of a program

A

The agility of a program is described as its ability to adapt to unspecified or changing needs of the client.
The object-oriented paradigm enhances the programmer’s ability to make these changes without modifying the front-end design of the program.

27
Q

Benefits of the Facade pattern

A
  1. Simplicity for service receivers to interact with subsystems
  2. Decoupling - isolates service receivers from subsystem details
  3. Consistency - always follows the same streamlined process
28
Q

Advantages of encapsulation

A
  1. Access restriction - hiding methods and attributes from other objects
  2. Lower maintenance errors
  3. Information Security via the principle of least privilege
29
Q

Benefits of Instantiation

A
  1. Data Encapsulation:
    allows for better modularity and separation of concerns.
  2. Individual State:
    Each instance maintains its own state.
  3. Reusability:
    Classes can be reused to create multiple objects.
  4. Ease of Maintenance:
    Changes to a class definition automatically propagate to all instances.method.
  5. Inheritance and Polymorphism:
30
Q

How does version control support collaborative code development.

A

Version control systems (VCS) like Git enable multiple developers to work on a codebase simultaneously. It tracks changes, manages different versions, and resolves conflicts, facilitating collaboration. VCS allows developers to work on branches and merge changes, ensuring code integrity and history.

31
Q

Explain how you used message passing between objects in your project or with a new example below.

A

Message passing is a technique used in object-oriented programming where objects communicate by sending messages to each other. This often involves calling methods on objects to perform actions or retrieve data.
In a Rock Paper Scissors game, message passing can be illustrated through the interaction between different classes:
Example:
Class Definitions:
Game: Manages the overall game flow.
Player: Handles player-specific actions like making a choice.
Computer: Handles computer-specific actions like making a random choice.
ScoreBoard: Keeps track of scores and displays them.
Message Passing Example:
Game Object initializes and starts the game.
Game Object sends a message to Player Object to get the player’s choice.
Player Object returns the player’s choice to Game Object.
Game Object sends a message to Computer Object to get the computer’s choice.
Computer Object returns the computer’s choice to Game Object.
Game Object sends a message to ScoreBoard Object to update and display scores.
In this example, message passing allows the Game object to communicate with Player, Computer, and ScoreBoard objects to manage the game flow, retrieve choices, and update/display scores. This encapsulates the functionality within each class and promotes modularity and code reusability.

32
Q

Write an algorithm to read a fixed sized record from a file using relative file access.

A

BEGIN
OPEN file FOR READING
SET recordSize = 100
SET recordNumber = 5
SET filePointer = (recordNumber - 1) * recordSize
SEEK file TO filePointer
READ record FROM file INTO buffer
CLOSE file
RETURN buffer
END