Defensive Programming Flashcards

1
Q

a practice wherein developers anticipate failure in their code and add supporting code to detect, isolate and recover from that failure

A

Defensive programming

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

Application should behave in a consistent and predictable manner even in cases of unexpected conditions

A

Defensive programming

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

Three hardcore topics related to defensive programming

A
  1. Security 2. Data integrity 3. Privacy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is OWASP and what does it do

A

Open Web Application Security Project;

An organisation focused on improving security of software

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

Why is defensive programming important

A

For security (being free from danger) and safety (being protected)

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

It was destroyed because of a software error wherein a 64 but floating point number related to the horizontal velocity of the rocket was converted into a 16 bit signed integer

A

European space agency’s ARIANE 5 flight 501

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

It is responsible for atleast 5 deaths in the 80’s wherein it malfunctioned (MALFUNCTION 54) specifically, it cannot determine if underdose or overdose

A

Therac 25 radiation therapy machine

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

Its system clock drifted 1/3 of a second over.a period of 100 hours causing a failure in locating an incoming missile
(Object tracking and time conversion error)

A

MIM 104 Patriot

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

6 tips and guidelines of defensive programming

A
>debug
>never trust user input
>never trust developers’ code
>write tests
>write SOLID
>use frameworks
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

A principle that states that a class should only have one job

A

Single responsibility principle

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

A principle that states that objects should be open to EXTENSION but closed for MODIFICATION

A

Open/close principle

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

If q(x) is provable on x (type T) then g(y) is provable on y (type S w/c is a subset of T)

A

Liskov substitution principle

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

A principle stating that client s should never be forces to implement an interface/method they do not use

A

Interface segregation principle

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

High level modules should not depend on low level modules but on abstractions

A

Dependency inversion principle

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