Software Development Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What does the SDLC represent?

A

The development of software as phases or sets of activities

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

What causes the SDLC?

A

The desire to define a predictable process to improve quality

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

What does the SDLC involve?

A

Creating processes that can be effectively managed

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

What are the 5 broad categories of the SDLC?

A
  1. Requirement Analysis
  2. Design
  3. Implementation
  4. Testing
  5. Evolution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Requirement Analysis?

A

What business/scientific problem is the system addressing?

What will the system do? Who are the users?

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

What is Design?

A

Hardware, software and network requirements

What parts are in-house, and what is externally developed or bought of the shelf

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

What is Implementation

A

The process of turning a software design into a working system by writing code, integrating components, and deploying it for use.

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

What is Testing?

A

The process of evaluating software to ensure it works as expected, is free of bugs, and meets user requirements.

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

What is Evolution?

A

Has system accomplished its goals, are there any modifications

Also includes maintenance of the system

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

What are the 4 Software Development Methodologies?

A
  1. Waterfall
  2. Prototyping
  3. Rapid Application Development
  4. Agile Development
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a Waterfall?

A

Breaks process down into distinct sequential phases

  • Each phase needs sign-off befoore moving to the next
  • Leads to very well documented projects
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Rapid Application Development?

A

A fast, flexible software development method that emphasizes user feedback, quick iterations, and prototyping over extensive planning.

  • Often development deadlinne prioritised over requirements.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is Agile Development?

A

A flexible, collaborative software development method focused on delivering small, functional pieces of software quickly and adapting to change.

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

What is Prototyping?

A

Creating a simplified, working model of the software to test ideas, gather feedback, and refine before the final version is built.

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

What are the advantages of Agile Development

A
  1. User engagement
  2. Rapid Development of a usable product
  3. Early testing catches bugs and results in a high quality product
  4. Small incremental changes mitigate potential risk of introducing large change to system
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a Scrum?

A

A framework within Agile development that organizes work into short, focused cycles called sprints (typically 2-4 weeks) to deliver small, workable software increments.

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

What is a Sprint planning meeting?

A

Part of a scrum that focuses on:

  1. Which items will be worked on
  2. Identify sprint tasks
  3. Divide the sprint into timeboxes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is a Daily scrum meeting?

A

Part of a scrum that focuses on:

  1. Summarising previous day’s work and coming day’s work
  2. Intended to foster collaboration
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is a sprint review meeting?

A

Part of a scrum that focuses on:

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

What are the advantages of OOP?

A
  • Encapsulation/information hiding
  • Inheritance
  • Polymorphism
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is the difference with OOP in comparison to procedural programming?

A

Puts code into objects, in contrast to procedural programming where no relationships are defined for each entity.

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

What should classes in OOP include and how does encapsulation sometimes cause issues?

A
  • Classes in OOP should usually be specified to include only code
    related to their specific function.
  • Encapsulation can cause issues with tightly coupled classes that rely
    heavily on each other’s members.
  • This creates a lot of work in designing functions to access those -
    members.
  • These issues are more common in GUI programming.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Define a Nested Class

A

Classes defined within classes

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

What are two types of Nested Class?

A
  • Static nested class
  • Inner class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What modifiers can be used for standard outer classes and nested classes in Java?

A

Standard outer classes (top-level classes) can only be declared with two modifiers:
- public
- default (package-private)
Nested classes can be declared with any of the standard modifiers:
- public, private, protected, or package-private.

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

What is the main difference between Static Nested Class and Inner Class?

A

Static nested class (doesn’t have access to instance members)

Inner class (does have access to instance members)

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

Why use nested classes?

A
  • Closely linked classes can be located in one place for better
    organization.
  • If one class is only used by another, making it a nested class makes
    this relationship explicit.
  • Increases encapsulation by controlling visibility:
    • If the Engine class is nested inside the Car class, the private
      members of Car are visible to Engine.
  • Can also improve code readability.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

List 4 key features of Inner Classes

A
  • Can be difficult to spot in code
  • Will produce two class files on compilation
  • Inner classes can be directly accessed by the enclosing instance
  • All nested classes can be accessed externally through either the containing class or object
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How does the scope with inner classes work?

A

“this” refers to the inner type instance

“OuterClass.this” refers to the instance of the surrounding (outer) class, when within the inner class code blocks.

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

What are local classes?

A

Local classes are defined and exist solely within a block (usually a method)

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

What can’t local class declaration contain?

A

Cannot contain public, protected, private, or static.

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

What can local classes access and not access?

A

Can access all members of outer class instance like standard inner class member

Cannot access method local variables unless they are declared as final

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

Define an anonymous class

A

Classes that are declared without any class name at all

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

How can anonymous classes be defined?

A

Not only may these be defined within a method, they may also be defined within an argument to a method.

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

Define Concurrency

A

To be able to perform multiple processes at same time

Each process happens in parallel without having to wait for each other to be scheduled

(including the potential interaction between them)

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

What is multiple tasks at the same time called?

A

Parallelism

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

Why is concurrency important?

A

Most efficient use of hardware - gets the most out of the processor and its cores

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

What is a thread?

A

Can be treated as lightweight processes

Threads exist within a process

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

Why use threads instead of separate programs?

A

Easier to manage multiple threads under a process than have multiple different programs

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

What is Multi-threading

A

OS can run threads in parallel
- Virtually, on a single core processor
- Actually, on a multi-core processor

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

Define Nondeterminism

A

Where the exact order in which processes are executed cannot be predicted

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

What causes Nondeterminism?

A

Multiple tasks are running at the same time, and the OS may decide to swich between them at different moments

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

What is Liveness?

A

Being concerned both when code doesn’t perform correctly and that code performs correctly in time

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

What are the 2 ways threads can be created in Java?

A
  1. Using the Thread class
  2. Using the Runnable interface
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

How to stop a Thread?

A
  1. Setting a flag
  2. Interrupting
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

What are Race Conditions?

A

When two threads try to access/change data at the same time

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

Define an Atomic Action

A

In programming, atomic actions are self-contained, they can’t be stopped in the middle

  • They either happen or don’t
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

What is Deadlock?

A

When thread 1 needs a resource in thread 2, and thread 2 needs a resourse in thread 1

This creates a deadlock and nothing happens as to run they both require resources from each other, creating an infinite cycle - deadlock

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

Define Starvation

A

Where a thread can’t gain regular access to shared resouces because another thread is frequently calling the objects methods

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

Define Livelock

A

Similar to deadlock, except that it occurs when 2 threads are too busy responding to one another to work

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

What does wait() do?

A

Releases the lock and regains it using the notify()

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

What is the difference between Wait and Sleep?

A

Wait
- Must occur in block synchronised on the monitor object
- Releases the monitor (lock) when called; doesn’t sacrifice the remainder of its time slice
- Will wake up if notified via call

Sleep
- Doesn’t need to occur in a synchronized block
- Retains the monitor (lock) when called and sacrifices the remainder of its time slice
- Can only be woken up by an interruption (not by notify)

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

What is a Thread lifecycle?

A

Thread needs to wait to start until the start method is invoked goes between runnable and running, this is dependent on the OS

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

What is Yield()?

A

Identifies the current thread as doing something not particularly important

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

How does Yield() work?

A

Causes the currently executing thread object to pause and allow other threads to execute

If no other threads of the same priority need to execute, the thread continues.

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

What is Join()?

A

Allows one thread to wait for the completion of another

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

How to stop a Join()?

A

Like sleep, responds to an interrupt

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

What is important about the data threads access?

A

Need to ensure the data our threads are accessing is fresh (up to date)

Stale data can lead to large issues

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

What are Atomic Variables?

A

Variables that support atomic operations, ensuring that increments, decrements or reads happen as a signle uninterruptible action

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

Explain volatile & data freshness

A

Declaring a variable volatile tells the compiler not to optimize accesses and forces the next read to see the last write

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

What is publishing?

A

Publishing an object is when you make it available outside its current scope

55
Q

By default should you publish an object?

A

By default, we shouldn’t have to publish an object unless we have to
- if we do, we may need to confirm the thread-safe nature of the
publishing

56
Q

What is an escaped object?

A

An object published when it should not have been

57
Q

List 4 key points about thread confinement.

A

One of the simplest ways to ensure thread-safety
If the data doesn’t need to be shared, confine it to a single thread
If data is only used by a single thread then its said to be confined
Thread confinement is an element of the programs design

58
Q

What is a Lambda expression?

A

Essentially a block of code that you can pass a round between objects

59
Q

Define Version Control

A

Tracking and managing your files by recording changes over time, you can recall specific versions later

60
Q

How does a Version Control System work?

A

In a team setting if a change is made that isn’t wanted by other members, they can revert the changes back to before

61
Q

What are three key factors of a Version Control System?

A
  • If a new person joins a team they can check the older versions to
    understand the progress of the project
  • Sharing of files and information about the project
  • Modern version cvontrol systems have atomic commits
62
Q

What are the advantages of using a Version Control System?

A

Gives a development team a project wide undo button

Place to store all files/documents/directories - repository

Repository acts as a server

Allows multiple developers to work on same code in controlled manner

Keeps record of changes

Can support multiple releases at same time

Time machine can examine how project looked at particular dates/versions

Can see who added/changed code - name/blame

63
Q

Centralized vs Distributed repositories

A

As soon as you commit to a centralized repository others can see your changes

Developers must push changes and pull updates from distributed repositories

64
Q

Copies vs Versions in Version Control Systems

A

Doesn’t just store copies, it stores every version that has ever been checked in

65
Q

What are Revision Tags?

A

Allow you to provide text for particularly important revisions

Easier to remember and more informative than version numbers

66
Q

What is a Trunk?

A

Main code base that developers are working on

67
Q

What is Branching?

A

Like creating a copy of your project to work on separately without affecting the main version. You can make changes, try new features, or fix bugs in the branch, and later merge it back into the main project once everything works well.

68
Q

What is Forking?

A

Forking means creating a personal copy of someone else’s project in your own repository. It’s like copying the whole project to your account so you can work on it independently.

69
Q

What is Merging?

A

Merging back the changes made in branch

70
Q

What is Strict Locking?

A

Only one person can change a file at any one time

71
Q

What is Optimistic Locking?

A

All files can be changed, but if changed in the repository since last check out then local copy needs to be updated before you can commit a change

72
Q

What are the implications of Optimistic Locking?

A

The version control system doesn’t know what you want - so it leaves it up to you to sort out

If you commit a file which has changed since you last updated you will be ttold the commit has failed

73
Q

What is an Event?

A

Something that happens in a program

(Such as: pressing a key)

74
Q

What is a Listener?

A

A function/piece of code that waits for a specific event to happen, and responds by executing some action.

75
Q

Polling vs Event-Driven Programming.

A

In event-driven programming, instead of repeatedly checking for events, the system waits and responds to an event only when it occurs - typically more efficient

Polling on the other hand is less efficient, because it consumes resources even when nothing happens

76
Q

What are Alternatives to Polling?

A

Interrupts - where the hardware or OS alerts the software when an event occurs
Event Listeners - where the system waits for an event to trigger a specific action

77
Q

Why use Events & Listeners - GUIS?

A
  • Can check for button presses and clicking on graphical icons
  • Efficient use of resources
78
Q

What is a source?

A

An object that generates an event

79
Q

What is a key model used in Software Development?

A

V-Model

80
Q

What is the V-Model?

A

Extends the Waterfall Model by emphasizing testing at every stage. Follows a sequential process, where each development phase has a corresponding testing phase.

The V shape illustrates thee relationship between developing on the left and testing on the right of the V.

It ensures early testing and verification, but is rigid, making it less flexible for changes once a phase is complete

81
Q

What is the concept of operations in the V-Model?

A
  • Provides a statement of the goals and objectives of the system
  • Includes strategies, tactics, policies and constraints affecting the system - so
    contextualizes the system in the wider business
  • Clear statement of responsibilties and authorities to the various participants
    involved in the system
  • Specifies the processes for iniating, developing, maintaining and retiring the system
82
Q

What is the Requirement analysis in the V-Model?

A

Cover three core areas:
1. Requirement gathering
2. Are the gathered requirements, clear, complete, consistent and unambiguous?
3. Clear statement of responsibilities and authorities to the various participants involved in the system

  • Also what can the system achieve with time?
83
Q

What is the High-Level design in the V-Model?

A

Will describe the platforms, systems, products, services, that the developed system will depend on

Typically will include an architecture diagram - this will show the interface, components and networks that need to be further specifed or developed

84
Q

What is the Detailed design in the V-Model?

A

Specifies how the system will be constructed
- for instance how the functions/objects/methods should be

Once detailed design is generated it should be possible to write the tests before the actual system is implemented

85
Q

What is Unit Testing in the V-Model?

A

Testing individual blocks of code in terms of correctness

(Probably the most widely used testing type that you have done so far)

86
Q

What is Integration Testing in the V-Model?

A

Testing the final system when grouped together or integrated
Unexpected behaviour may arise at this point, which is checked for here

87
Q

What is System Testing in the V-Model?

A

Testing the system as a whole
- Also checks that it doesn’t impair performance on the wider environment
- Affecting broader resource availability on the OS
- Affecting other applications working on the same system

88
Q

What is User Acceptance Testing in the V-Model?

A

Plans are deveoped during requirement analysis phase and are composed by users

Is performed in a user environment that resembles the production environment and uses realistic data

Ensures that the delivered system meets the users requirements and system is ready for use in real time

It’s based on validation rathjer than verification

89
Q

What are the advantages of the V-Model?

A

Highly structured, phases completed one at a time

Works well where all requirements are understood

Simple to understand

Easy to manage - each phase has a definite end with a review

90
Q

What are the disadvantages of the V-Model?

A

Once a project is in the tesing phase it is difficult to go back and change functionality

Not suitable for projects where requirements might change

No working software created until late in the cycle

91
Q

What are the Testing Categories?

A

Static Testing

Dynamic Testing
- White box testing
- Black box testing
- Grey box testing

92
Q

What is Static and Dynamic Testing?

A

Static Testing - accessing documents

Dynamic Testing - testing that involves executing program code

93
Q

What is White box testing?

A

Testing where the internals of the program are known, so can test explicit paths through the system

94
Q

What is Black box testing?

A

Treats code as a “black box”, and therefore is only concerned with functionality

95
Q

What is Grey box testing

A

know both thr required functionality and also some of the implementation concepts which can be used in test design, but not code base exposed

96
Q

What are the advantage/disadvantage of White box testing?

A

Advantage
- Code can be seen so tests can be designed to test many paths through the program

Disadvantage
- Knowledge of the internals will influence the testing - can lead to bias in test design

97
Q

What are the advantage/disadvantage of Black box testing?

A

Advantage
- No knowledge of internals so no bias - more likely to result in tests unexpected by
programmer

Disadvantage
- High probability that tests will only test a small number of paths through the
program

98
Q

What are Unit Tests?

A

Principles of unit test are to test small specific areas of functionality within a program

99
Q

What is Code Coverage?

A

Attempts to measure how much of your code has been tested
It looks at the code directly, and uses a lot of techniques in unit testing to derive a formal message
Different measures of coverage are often reffered to - some are simply infeasible to completely cover
So often a choice has to be made about how much code can be covered

100
Q

What are the four coverage types?

A

Function/method/subroutine coverage
Statement coverage
Decision coverage
Predicate coverage

101
Q

What is Function coverage?

A

Has each method written, had a test written (and run) on

102
Q

What is Statement coverage?

A

Has each line of code been processed by at least one of your suite of tests

103
Q

What is Decision coverage?

A

Has every desicision edge been traversed in your code (if/else)

104
Q

What is Predicate coverage?

A

Has every condition been tested? (not always the same as decision coverage)

105
Q

What are edge cases?

A

Where a variable takes its maximum or minimum possible value

106
Q

What are corner cases?

A

Situations where multiple edge cases occur together, these are even rarer than edge cases, and can be harder to identify and handle

107
Q

Give two examples of corner cases

A

Combining extreme inputs
- Testing with both min and max values together (e.g., a max sized file with invalid
characters)

Multiple boundary conditions
- Checking how a system behaves when several limits are hit at the same time (e.g., a
nearly full database with a complex query

108
Q

What are the Limits of Testing?

A

It’s not possible to test every single aspect of even a moderately simple system
- no. of possible inputs are too large
- Too many possible paths through the system

Testing cannot assert that the software functions correctly under all conditions, but that it functions incorrectly under specific conditions

109
Q

What does Unit Testing prove?

A

It is often very difficult or impossible to “prove” a piece of code works, we can only satisfy ourselves that we haven’t disproved that it works
- Designing tests with this in mind is critical

110
Q

What is the Importance of Unit Testing?

A
  • Reduces time spent on debugging
  • Helps communicate codes inteded use - illustrates how you expect the code to
    perform on various inputs and conditions
  • The code shouldn’t drift away from the limits put on them by tests
111
Q

What does Right-BICEP stand for?

A

Right – are the boundary results correct (or “right”)
B – are all the boundary conditions correct?
I – can you check the inverse relationships?
C – can you cross-check the results using some other means?
E – can you force error conditions to occur?
P – are the performance characteristics within bounds?

112
Q

What are 6 properties of good tests?

A
  1. You’ve flexed your right bicep
  2. Automatic
  3. Thorough
  4. Repeatable (should produce same results each time)
  5. Independent (of each other test and of the environment)
  6. Professional (written and maintained to the same standard as the shipped code)
113
Q

How to test your tests?

A
  • Improve the tests while fixing bugs
  • Prove the tests by introducing bugs
114
Q

What are the naming conventions when structuring Unit Tests?

A

If the production code class is called Account and a method is called createAccount; Test should be called testCreateAccount
You may have more than one test method that tests createAccount but they should all begin with test

115
Q

How would you set up a Unit Test?

A

Test code must be written to do a number of things:
1. Set up all conditions needed for testing (create any required objects, allocate any
needed resources)
2. Call the method to be tested on the object
3. Verify that the object/class to be tested functions as expected
4. Clear up after itself

116
Q

What is an Assertion?

A

Used to verify that the code being tested behaves as expected. If the assertion fails, the test is considered to have failed, and it usually indicates that there is a bug or issue in the code being tested.

117
Q

How does assertEqual & assertNotEqual work?

A

assertEqual(actual, expected) checks if the actual value equals the expected value.

assertNotEqual(actual, expected) checks that the actual value doesn’t equal the expected value.

118
Q

How does assertTrue and assertFalse work work?

A

assertTrue(condition) checks that the boolean condition is True
assertFalse(condition) checks that the boolean condition is False

119
Q

How does assertNull & assertNotNull work?

A

assertNull(value) checks if the value is null
assertNotNull(value) checks if the value is not null

120
Q

How does assertSame & assertNotSame work?

A

assertSame(expected, actual) checks whether two objects are of the same instance
assertNotSame(expected, actual) checks whether two objects are not of the same instance

121
Q

How does fail work?

A

fail(message) wil fail test immediately if flow of control passes to this statement

122
Q

What are Mock Objects?

A

Cheap placeholder objects that are predictable and allow us to test the method we need to in the current class

123
Q

When should you use a Mock Object?

A

When the real object:
- has non deterministic behaviour (not sure how the object will behave)
- is difficult to set up
- has behaviour that is hard to trigger
- is slow
- has (or is) a user interface
- does not yet exist

124
Q

How should you implement a Mock Object?

A
  1. Use an interface to describe the object
  2. Implement the interface for production code
  3. Impelment the interface in a mock object for unit testing
125
Q

What are Test Suites?

A

They allow us to group multiple tests classes to run as a single batch
They also allow us to run a specific subset of unit tests from multiple test classes

126
Q

What are the benefits of Test-driven development?

A

Can help you design your code better
You see the code from the user’s perspective - not the developers

127
Q

What are Invariants?

A

Assertions about classes/objects that should not change - should definitely test these when developing unit tests

128
Q

What are Design Patterns?

A

Meant to provide a general reusable solution to one type of problems during software development

Theory of design patterns is that someone has already solved your similar pattern problems

129
Q

How do Design Patterns relates to OOP design principles?

A

Primarily based on the following principles of OOP design
- Identify the aspects of your application that vary and separate them from what stays
the same
- Program to an interface, not an implementation
- Favour ‘object composition’ over class inheritance

130
Q

What are the 3 types of Design Patterns?

A

Creational Patterns - object creation
Stuctural Patterns - composition of classes and objects
Behavioural Patterns - interaction between objects

131
Q

What is a Factory Pattern?

A

Defines an interface for creating an object, but lets subclasses decide which class to instantiate. It lets a class defer instantiation to subclasses.

132
Q

What is an Abstract Factory Pattern?

A

Provides an interface for creating families of related or dependent object without specifying their concrete classes.

133
Q

Factory Pattern vs Abstract Factory Pattern

A
  • Both used for object creation
    • Factory Pattern uses inheritance and gives you a complete object in one shot
    • Abstract Factory Pattern uses composition and returns a family of related classes
134
Q

What is a Builder Pattern?

A

Separates the constructions of a complex object from its representation so that the same construction processes can create different representations
- Let you vary a products internal representation
- Isolate code for construction and representation
- Finer control over the construction process

135
Q

How does Builder Pattern work?

A
  • The Builder specifies the interface for creating parts of the complex (Product) object.
  • The ConcreteBuilder objects create and assemble the parts that make up the
    Product through the Builder interface.
  • The Director object takes responsibility for the construction process of the complex
    (Product) object, however it delegates the actual creation and assembly to the
    Builder interface.
  • The Product represents the complex object that is created by the ConcreteBuilder
    object(s). The Product consists of multiple parts that are created separately by the
    ConcreteBuilder objects.
136
Q

Factory vs Abstract Factory vs Builder Patterns

A

The main difference is
- Factory pattern construct a complete object in one shot
- Abstract factory pattern returns a family of related classes
- Builder pattern constructs a complex object step by step

137
Q

What are the Benefits of a Builder Pattern?

A
  • Encapsulates the way a complex object is constructed
  • Allows objects to be constructed in a multistep and varying process (as opposed to
    one-step factories)
  • Hides the internal representation of the product from the client
138
Q

What is a Singleton Pattern?

A

Ensures that a class has only one instance, and provides a global point of access to it

139
Q

What are Examples of a Singleton Pattern?

A

Examples
- Windows managers
- File systems
- Print spoolers

140
Q

How to access a Singleton Pattern?

A

Static Member: Create a private static variable of the Singleton class. This is the only instance of Singleton class

Private constructor: Create a private constructor for making sure an outer class can NOT instantiate object from the Singleton class

Static public method: Create a global point of access to get a Singleton instance

141
Q

What is Eager Initialisation?

A

The instance of Singleton class is created at the time of class loading

142
Q

What is Lazy Initialisation?

A

To create the singleton, to ensure that the singleton instance is not created until the getInstance() method is called for the first time

(created only when needed)

143
Q

What is a Thread Safe Singleton?

A

The easier way to create a thread-safe singleton class is to make the global access method synchronized, so that only one thread can execute this method at a time.

144
Q

What is used in an Efficient Thread Safe Singleton?

A

To avoid this extra overhead every time, double checked locking principle is used.

The synchronized block is used inside the if condition with an additional check to ensure that only one instance of singleton class is created.