software development in general Flashcards

1
Q

why do we need indirection (pointers)

A

in functions you can only pass by value but you can use pointers instead

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

what function do we use to compare strings

A

strcomp; takes two strings and returns the difference between them

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

what are some issues with variables

A

can only represent simple scalar values
declared with a fixed size
go out of scope at the end of the scope they’re declared in
incur overhead when copied

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

what can we use to overcome some of the issues with variables

A

compound variables
dynamic memory
passing pointers

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

where are dynamic variables allocated

A

heap; dynamic memory

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

dynamic memory

A

allocated at run time
requires managing; must free and return to the heap once finished
extreme care required to avoid memory problems

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

what piece of code is used to allocate memory to the heap

A

malloc; the space allocated is saved until you give it back

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

what is an example of a compound variable type

A

structs; a user defined grouping of variables that combines simple types into one entity

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

api

A

application programming interface

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

file

A

a collection of typically related data that can be viewed as bytes

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

software interface

A

a set of operation defined for interaction for this system in a controlled way (api) || set of functions that you can call that are declared in a header file

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

what are advantages of having an entire project in one file

A

only one file for the compiler to parse to find all functions
the programmer only has one place to look
you only have to pass around one source file

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

what are some disadvantages of having an entire project in one file

A

hard to reuse code
scrolling becomes difficult
not ideal for teamwork

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

why is the header file needed at the top of each file

A

so the file know which functions to expect

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

how do you combine multiple files

A

gcc -o main main.c queue.c

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

how do you combine compiled files

A

gcc -c queue. c : creates the object file
gcc -o main main.c queue.o : combines all files into a single executable

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

how do you package files into a library

A

ar ras libq.a queue.o

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

what is version control

A

specifically choosing to mark/track certain changes in the code
a version history can be stored over the timeline of a project

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

how is a new version created

A

when you mark a new set of changes

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

what are the main principles of version controls

A

you need to create a repository (repo)
add the files you want to track
you periodically commit versions to the repo with a meaningful commit message

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

what is a positive of version control

A

enables teamwork

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

what is the main principle of modular code

A

code comes in smaller pieces that you can put together and relies on standards (api)

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

what are some main principles of procedural programming

A

has a well defined start (main())
code is modularised through functions
variables are passed through parameters or can be global
data modularity only occurs in data structures or not at all
data and code are treated as separate concepts

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

what is a con of global variables

A

you can’t use the same variable name more than once

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

what is a con of passing through parameters

A

you may have to pass through a large amount of variables

26
Q

objects

A

data fields with unique attributes and variables

27
Q

encapsulation

A

combining multiple pieces of data into a single class

28
Q

how do objects provide encapsulation

A

data and code can’t be separated
data is defined through attributes
behaviour is defined through methods

29
Q

how do objects protect their inner workings via APIs

A

the programmer only exposes what they choose to which provides control
you can only interact with objects through their methods

30
Q

accessors

A

get methods: return a attribute

31
Q

mutators

A

set methods: changes an attribute

32
Q

what is the benefit of accessors and mutators

A

you don’t have to make anything public

33
Q

constructors

A

a method automatically called when an object is created without a return type that initialises variables

34
Q

destructor

A

a method automatically called when an object is destroyed; explicitly deleted or goes out of scope

35
Q

what are some benefits of constructors

A

safety: programmers can’t create invalid or inconsistent attributes
control: the programmer can define and enforce the class’ api

36
Q

library

A

collections of prewritten recompiled code

37
Q

what is the flag for libraries

A

-c

38
Q

what is an -o object file

A

precompiled files waiting to be called

39
Q

namespace

A

provide a space to define functions and variables

40
Q

what is the purpose of namespaces

A

differentiates functions classes and variables with the same name available in different libraries; when you’re working with others its helpful when you don’cit have to have different variable names
defines a scope

41
Q

virtual machine

A

software emulation of a physical computer that runs programs in an isolated environment

42
Q

what are virtual machines required for

A

platform independence
WORA: write once, run anywhere

43
Q

what is a pro of virtual machines

A

reduces the number of memory related errors as they handle memory allocation and garbage collection

44
Q

what is java usually used for

A

high reliability and good performance

45
Q

what does the java virtual machine do

A

acts as a translation layer between an app and a machine at runtime
excecutes its own machine language called byte code. ( an intermediate language)

46
Q

intermediate langauge

A

not directly excecuted by the computer
generated from the program source code

47
Q

primitive/value types

A

used when its the data itself that you’re accessing/passing as a parameter
e.g. int float etc

48
Q

reference type

A

anything that isnt a value type including object references
e.g. String Car

49
Q

inheritance

A

one class taking on methods and attributes from another in order to create a new class

50
Q

inheritance keyword

A

extends

51
Q

multiple inheritance languages

A

a class can have many superclasses
e.g. c++ python

52
Q

what is a con of multiple inheritance languages

A

when there are multiple attributes with the same name it becomes ambiguous making the program more complex

53
Q

single inheritance languages

A

subclasses can only have one superclass
e.g. java

54
Q

what does it mean that inheritance is transitive

A

subclasses can be superclasses of other classes

55
Q

method overriding

A

creating a method in the subclass with the same name and parameters as the one in the superclass but changing the implementation

56
Q

method overloading

A

having a new method with the same name but different parameters means its treated as a completely different method

57
Q

polymorphism (is a)

A

an inherited class is treated as a type of its superclass

58
Q

abstract class

A

when classes are made simply to act as a superclass
provide a template with no implementation

59
Q

abstract methods

A

act as a placeholder and are made to be overwritteni

60
Q

interfaces

A

an abstract class with abstract classes || a names specification of methods

61
Q
A