Option D. Object Oriented Programming

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

1/77

flashcard set

Earn XP

Description and Tags

D.1, D.2, D.3, and D.4

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

78 Terms

1
New cards

Object

representation of a real world entity. describes that data that this entity has (properties/attributes) and actions that this entity can perform (methods)).

2
New cards

Unified Modeling Language (UML)

Provides a way to visualize the design of any software system and has evolved into the standard for modeling object-oriented programs. Modern extension of flow charts and can be though of as a superset of flowcharts.

3
New cards
<p>UML Class Diagram</p>

UML Class Diagram

Depict the classes within an object-oriented program as well as their collaborations. Classes within an object-orientated program are connected in various ways with each other and UML class diagrams represent those connections.

4
New cards

Association

how classes are connected. Represented by a line connecting the two classes. Each association has two roles and each role has a direction. Each association also has a multiplicities.

5
New cards

Multiplicities

Placed at each end of an association line and indicate the number of objects of one class linked to one object of the other class.

6
New cards

What does “1” as a Multiplicity mean?

Exactly One

7
New cards

What does “0..1” as a Multiplicity mean?

zero or one

8
New cards

What does “*” as a Multiplicity mean?

Many

9
New cards

What does “0..*” as a Multiplicity mean?

Zero or Many

10
New cards

What does “1..*” as a Multiplicity mean?

One or many

11
New cards

Inheritance

is a or is like relationship. In UML diagrams inheritance is displayed with hollow arrows.

12
New cards

Decomposition

breaking up the problem into several related objects.

13
New cards

What are the four relationships that can be described in a UML class diagram

  • Association

  • Dependency

  • Aggregation

  • Inheritance

14
New cards

Association

The simplest relationship that can be present between two or more objects. It is represented with a solid line. One or two roles labels may be present to signify the type of association that takes place.

15
New cards

Dependency (“uses” relationship)

one object is dependent on one or more objects in order to function. The implementation of an object depends on one or more other objects. Represented with a dashed arrow, that goes from the object to the object that the first one depends on.

16
New cards

Inheritance (“is a” relationship)

Signifies that one object is a specialized form of another object. Represented by a hollow triangle with a line. The triangle points to the parent

17
New cards

Aggregation (“has a” relationship

One object belongs to another object and none other. A special kind of association between two objects. The two objects are not dependent on one another. It is represented by a hollow diamond from the parent class then a line.

18
New cards

Dependencies

When one object uses another object, the first object depends on the second since it cannot function without it. Whenever the first object needs to be used, the second object will be used as well. Dependencies are directional.

19
New cards

What are Coupled Classes?

Two classes which use one another. The degrees of the relationship between Coupled Classes is continuous not discrete.

20
New cards

Why are dependencies are bad?

They decrease reuse. Reuse is found in code where parts are reiterated or have a replicated structure; helpful in code readability.

Changes in one class will affect other classes which may increase errors in code.

21
New cards

Data Types

Allow programs to classify these data into different types.

  • Integers

  • Real numbers (float and double)

  • Boolean

  • Strings

22
New cards

Parameter

the name of the information that is used in a method, function, or procedure

23
New cards

Argument

the value that is passed into a method, function, or procedure

24
New cards

Encapsulation

the inclusion of both data and actions into a single component. Classes contain data and actions that are built-in such a way so that their structure is hidden and can only be accessed outside the class via specific methods.

  • Plays the protective wall that prevents data and actions from being accessed from outside a class.

  • Creates a ‘black box’ for an object, separating its behavior and implementation by restricting access to data and actions as necessary

25
New cards

Polymorphism

the ability to have many forms

26
New cards

Static Polymorphism

Understanding the method signatures and decide the method that needs to be invoked for a particular method call depending on the number and types of parameters passed

27
New cards

Dynamic Polymorphism

A subclass overrides actions of the superclass. It allows for subclasses to alter any parent class actions and make them specific to their needs.

28
New cards

Advantages of Encapsulation

  • Data in a class can be made read or write only

  • A class restricts the ways that its data and actions can be altered or called

  • A class can hide the way that data is stored

  • Easier to maintain as changes to data and actions in a class can take place without being apparent on the outside, as long as data and actions can still be accessed through the same way

  • Increase in usability

29
New cards

Advantages of Inheritance

  • Extensibility: all child classes inherit the actions and data of a parent class. Furthermore, child class may add new functionality, extending the parent’s actions and data, or even redefining them

  • Reusability: child classes that inherit the actions and data of a parent class will not need to be altered in the event that an inherited action or data needs to be upgraded. When parent class actions are upgraded, all child classes that inherit from the parent class will automatically use the new upgraded version of these actions. This fact reduces maintenance overheads as an action needs only to be changed once and all the dependent child classes will use it

  • Information hiding: the parent class determines what actions and data are available to the child classes

  • Overriding of Actions: child classes may override parent actions in order to implement meaningful actions for their needs. AS such, for a child class, inheriting from a parent class means that it can use whichever data and actions needed, as well as implement or improve on any parent actions.

30
New cards

Advantages of Polymorphism

  • Object actions can have the same name but different parameter lists and processes

  • Subclasses can have their own unique actions, as well as being able to override or improve on parent actions

  • Subclasses inherit all parent data and actions, without rewriting code, and can alter the actions that they deem necessary. This allows for code reusability

  • Polymorphism provides a high degree of decoupling since to an external program the implementation behind actions is hidden. A common interface exists for a family of objects that abstracts and hides the details of the implementation.

31
New cards

Libraries of Objects

Collections of classes that have already been written in code and can be used by a programmer while developing a program. The availability of libraries as well as their use simplifies the work that has to be put into a project since standard, tested, working code is available for various functions.

32
New cards

Advantages of Libraries

  • Saves development time - classes and their methods do not need to be rewritten

  • Promotes abstraction - reusable code exists that functions without knowledge of internal working

  • libraries contain error-free/ robust code - because it has been used and tested many times;

  • promotes efficiency/organization - as code will be shorter/easier to read/ develop

  • familiarity with libraries - allow for easier maintenance/ modification

33
New cards

Disadvantages of Object Oriented Programming

Good for large-scale projects, but not for small projects with few developers and modules.

  • Size: much larger than other programs

  • Effort: requires a greater level of planning before any code is written

  • Speed: typically run slower due to their size.

34
New cards

Use of Programming Teams

Modular nature of OOP means that objects can be assigned to a different coder to program, as long as any shared methods are known.

35
New cards

Advantages of Programming Teams

  • Larger projects can be taken since more developers can work on them

  • Compared to a solo developer, members of a team may bring various ideas to the table that would not have come about without member collaboration

  • the strengths of some team members may offset the weaknesses of other members

  • team members do not know the workings of the whole project, and can thus concentrate their time and energy in developing part of a project to a higher standard

36
New cards

Disadvantages of Programming Teams

  • There needs to be honest, well-mannered communication between team members. There needs to be a common “language” to enable collaboration

  • Weakness of some team members may end up undermining the group as a whole

  • Since team members will not be aware of the project as a whole and because members will be working on different aspects, decisions, and project planning takes longer compared to a single developer project

37
New cards

Modularity

related to the process of dividing a computer program into separate smaller sub-programs that can be implemented and tested on their own before combining them all together to build the final program. Makes the program more effective when there are logic boundaries between the sub-programs and there are very few dependencies with each other.

38
New cards

Advantages of Modularity

  • Subprograms can be reused in other applications

  • Less new code needs to be written for a program

  • Team support.

  • The code of a program is comprised of a short, simple, and easy to understand smaller subprograms that are easier to maintain and debug

  • The structure of a program is easier to understand

  • Subprograms works as “black boxes” that can be changed or updated without other team members needing to be involved

  • Speedier completion of the subprograms and as a result the whole program itself, compared to taking on the program as one large problem

39
New cards

Class

Defines the fields and methods for a group of similar objects. An object is an instance of a class

40
New cards

Identifier

A broad terms for the name of a variable or method.

41
New cards

Primitive (Data Type)

int, long, double, char, Boolean, byte, etc.

42
New cards

instance variable

the fields in a class. When an object is created of that class type, it has its own version of the fields

43
New cards

Parameter Variable

Information sent into a method from the calling program.

example: public int add(int x, int y)

44
New cards

Local Variable

A variable which exists only as long as the code to which it belongs exists. So if declared in a method which is no longer being run; the variable no longer exists/it is overwritten

45
New cards

Method

a program routine or behavior contained within an object designed to preform a particular task on the fields within an object

46
New cards

Accessor

A method that allows access to the fields within an object

Example: getName()

47
New cards

Mutator

A method that looks the values of the files in an object to be changed

Example: setName()

48
New cards

Constructor

the method that correctly initializes and sets up an object when it is created. This method has the same name as the class it belongs to and has no return data type

example: public person()

49
New cards

Signature

the method name and its parameter types

example: doSomething(String y)

50
New cards

Return Value

The value returned by a method to the calling program

51
New cards

Private

Variables, methods, fields, and constructors that can only be accessed within the declared class itself. Classes cannot be private. An object is able to encapsulate itself and hide its data from outside access

52
New cards

Protected

Variables, methods, fields and constructors declared protected in the super-class can only be accessed by the sub-classes

53
New cards

Public

variables, methods, fields and constructors declared public can be access from any other classE

54
New cards

xtends

this is used by a sub-class to say that it inherits the fields and methods from a super-class

55
New cards

Static

A static is a member of a class which isn’t associated with the instance of a class. It belongs to the class itself. AS such, you can access the static member without first creating a class instance

56
New cards

8 primitive Data types

  • Byte

  • Short

  • Int

  • Long

  • Float

  • Double

  • Char

  • Boolean

  • String

57
New cards

Byte

  • Minimum value: -128

  • Max Value: 127

  • It occupies 8 bits of memory

  • Typically used for saving memory in large arrays of small numbers

58
New cards

Short

  • Minimum Value : -32,768

  • Maximum Value: 32767

  • It occupies 16 bits of memory

  • Typically used for the same reasons as a byte, but for a wider range of number

59
New cards

Int

  • min value: -2³1

  • Max: 2³1 - 1

  • It occupies 32 bits of memory

  • Most commonly used as primitive Data type to represent integer numbers

60
New cards

Long

  • Minimum value -2^63

  • max Value: 2^63 - 1

  • It occupies 64 bits of memory

  • Primitive Data type to represent integer numbers when the range of the int data type is not sufficient

61
New cards

Float

  • 1.4 ^-45 to 3.4³8

  • It occupies 32 bits of memory

  • Typically used for saving memory in large arrays of floating point numbers. Should not be used as a data type for numbers that need precision

62
New cards

Double

  • 4.9^-324 to 1.7³08

  • It occupies 64 bits of memory

  • Most commonly used data type for the representation of decimal values. Should not be used as a data type for precise values such as currency

63
New cards

Char

  • Minimum Value: ‘\u000’ - 0

  • max Value: ‘\ufff’ -65535

  • It occupies 16 bits of memory

  • represents a Unicode character

64
New cards

Boolean

  • Can take only take one of two values: true or false

  • Typically used for conditions that may have one of two outcomes

65
New cards

String

  • It is not a primitive Data type but rather a reference class

  • Typically used to represent series of characters

  • Once it is created its value cannot change and it is thus immutable

66
New cards

Common Character Sets

Used among many platforms and languages, like Unicode. Unlike ASCII, Unicode has a larger number of characters so has letters and symbols from different alphabets/languages

67
New cards

Platform independent Languages

High Level Programming languages like java enable code to run on many different plateforms

68
New cards

Ethical/Moral Obligations

  • Adequate Testing: to prevent possibilities of commercial or other damage

  • Plagiarism: Acknowledge the work of other programmer to avoid being accused of plagiarism

  • Open Source Movement: increasing support for open-source software where you are given access to the code for free, allowing you to make changes/customization to meet exact needs.

69
New cards

Advantages of Objects

  • Objects can be easily passed around the program, and so are modular in nature

  • Allows for re-use for objects already created

  • Debugging ease; if a bicycle is broke you replace the bolt, not the whole bike. Similarly, you can replace and diagnose specific objects

70
New cards

Members/Attributes/Features

Objects have their own variables, constants and methods associated to it. These are broadly known as ‘Members’ or ‘Features’ or “Attributes of an Object'“

71
New cards

Expressions

A construct made up of variables, Operators and method invocations which evaluate to a value. Expressions are the core components of statements; and these statements may be grouped into ‘statement blocks’

72
New cards

Statements

Statements are like sentences, it is a complete unit of execution; each line in a program is a statement. Methods are defined by the statements within them, since these create their behavior. Statements specify a sequence of actions which should be performed when the method is invoked

73
New cards

Statement Blocks

Any sequence of statements can be grouped together to function as a single statement when expressed within braces - {}.

A statement block can be written inside another statement, this is known as ‘nesting’ they are used to define methods.

74
New cards

Control Flow Statement

Statements are executed sequentially on their own. However, Java has control statements which break the sequential flow of code, and allow repetitive execution of statements and conditional execution of statements

75
New cards

Case-Switch-Break/default

A switch statement can have any number of possible execution paths for int, char and byte data types.

76
New cards

Break

Terminates a loop when a value is found or statement block completeE

77
New cards

Return

Exits from the current method and returns to where the method was originally invoked. By specifying a value with return, the exit can be achieved whilst sending the value back.

78
New cards

Benefit of Decomposition

Decomposing a problem into several related objects and then decomposing those objects again into even simpler related objects allows for the reduction of the complexity of a problem and makes it easier to deal with.