2b: How to Design Data Flashcards

1
Q

What is a data definition?

A

It’s a new kind of design element.

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

Suppose you’re working on a program that somebody else wrote, and the program has to do with simulating traffic. What’s reasonable to expect from that code?

A

The code has to do with traffic lights, and cars, and trucks, and things like that.

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

Suppose you’re working on a program that somebody else wrote, and the program has to do with simulating traffic. What’s reasonable to expect from that code?

A

The code has to do with traffic lights, and cars, and trucks, and things like that.

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

If you came across this function while reading the program, would you think it’s clear?

(define (next-color c)
(cond [(= c 0) 2]
[(= c 1) 0]
[(= c 2) 1]

A

No. It’s not very clear what the function does from just looking at it (even if you followed the HtdF recipe, it wouldn’t be clear).

To understand this problem we have to understand something important about data in programs called the PROBLEM DOMAIN.

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

What is the problem domain?

A

The problem domain is the AREA where the PROBLEMS your application is intended to SOLVE, belong to. It is simply looking at only the topics you are interested in, and excluding everything else.

It is all information that defines the problem and constrains the solution (the constraints being part of the problem).

It is anything and everything that is needed to define the area under analysis, fully understand the inputs and outputs of its processes, and achieve the goals of the area under analysis, but nothing more.

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

What’s going on between the problem domain and the program when we design a program?

A

We’re playing a game where we represent information in the problem domain using data in the program.

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

What is a DATA DEFINITION? And where is it placed location wise?

A

Data Definition tells us everything we need to know about how we represent information as data. It is placed in the beginning as a first section before the 2nd section on Functions.
1- Start with a type_comment.
2- Template skeleton for 1-argument functions.

IT shows how to form data of a new type.
How to represent information as data.
How to interpret data as information.
Template for operating on data.

IT shows restrictions of data consumed and what data can be produced.
Helps generate examples.
Provides templates.

Relationship between information and data.

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

How is the template for a function determined?

A

By the TYPE of data it CONSUMES.

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

What is the “interpretation” step?

A

The interpretation should describe the correspondence between the information and data.

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

What should the examples do?

A

The examples should help us understand what the data definition represents.

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

How do you write the data-driven TEMPLATE?

A

From the Data Driven Templates page, the body of the template for atomic non-distinct data should include the parameter name after the dots. In this case, the template body should be (… cn).

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

How do you name predicate functions that produce a boolean value?

A

YOU name the predicates with a ? mark.

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