Asynchronous Programming Flashcards

(27 cards)

1
Q

single process thread

A

synchronous

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

multiple processes coordinating and running parallel with each other

A

asynchronous

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

in this type of programming, callbacks are used in general

A

asynchronous

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

represents a potential value or error that will be available at some time in the future

A

Future class

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

provides a more linear and readable way to write asynchronous code

A

async/await

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

reduces the need for nested call backs or .then() chains

A

async/await

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

use cases to consider in implementing asynchronous programming (4)

A
  1. reading data from a file asynchronously
  2. receiving data from a network socket
  3. listening to events from a sensor
  4. handling a continuous flow of data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

a continuous sequence of asynchronous events

A

stream

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

blocking operations while in progress, the program is unresponsive to other elements

A

synchronous

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

non-blocking; uses callbacks, futures, and streams to notify the program when they’re finished

A

asynchronous

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

importance of testing (3)

A
  1. ensures app quality - features, UX
  2. reduces bugs - errors
  3. maintainability - incremental
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

types of testing (3)

A
  1. unit testing
  2. widget testing
  3. integration
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

flutter package to use for testing

A

flutter_test

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

what type of testing is being shown by the sample code

void main() {

  test('should double the number', () {

    // Arrange

    int input = 5;

    // Act

    int result = doubleNumber(input);

    // Assert

    expect(result, 10);

  });

  test('should handle zero', () {

    expect(doubleNumber(0), 0);

  });

  test('should handle negative numbers', () {

    expect(doubleNumber(-3), -6);

  });

}
A

unit testing

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

a testing method where individual components of an application are tested to verify their correctness

A

unit testing

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

what type of testing is being shown by the sample code

void main() {

  testWidgets('should display the greeting with the name', (WidgetTester tester) async {

    // Arrange

    String testName = 'Flutter User';

    // Act

    await tester.pumpWidget(MaterialApp( // Wrap the widget in a MaterialApp

      home: GreetingWidget(name: testName),

    ));

    // Assert

    expect(find.text('Hello, $testName!'), findsOneWidget);

  });

}
A

widget testing

17
Q

a testing method used to verify if individual widgets function as expected

A

widget testing

18
Q

a testing method that verifies how different modules or components of an application interact and communicate when combined

A

integration testing

19
Q

% of code executed when your tests are ran

A

code coverage

20
Q

what is a reasonable code coverage

21
Q

flutter command to see code coverage

A

flutter test –coverage

22
Q

pros of unit testing (3)

A
  1. small, fast, isolated
  2. easy to write
  3. early detection
23
Q

cons of unit testing (3)

A
  1. limited to scope
  2. need to setup
  3. refactoring
24
Q

pros of widget testing (3)

A
  1. tests ui
  2. simulate user interaction
  3. more comprehensive
25
cons of widget testing (2)
1. limited scope 2. harder to write than unit testing
26
pros of integration testing (3)
1. tests the whole app 2. simulates real world issues 3. highest confidence
27
cons of integration testing (3)
1. slowest 2. harder to write 3. harder to debug