CSV framework Flashcards

1
Q

Declarative framework

A

You declare what you want, rather than walking the computer through what to do. The latter is referred to as imperative programming.

Python is famous for being very declarative - good and bad. It looks like magic, but it makes things very easy to get done.

Declarative frameworks are helpful if you have:

  • many potential configurations
  • each configuration is known in advance
  • many instances of any given configuration
  • actions that can be performed on a given instance
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Three primary components of a declarative framework

A
  1. Base class - gives frame w place to hook in and process declarations. Attaching a metaclass provides machinery to inspect the declaration at runtime to make adjustments.
  2. Various field types - attributes inside class declarations. represent data attributes in structures defined by your framework. Must know the order in which they’re instantiated, so ordering used in the declaration is the same used later on.
  3. Options container - some type of class-wide option, not specified on every field. –need example
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Managing options

A

primary purpose of an options container is to store and manage options for a given class declaration.

Options are simply a map of names to values.

call it options.py. The bulk of work is done in the __init__() method.

Options should have defaults so users don’t have to keep declaring the most common thing. If something is truly required and doesn’t have a reasonable default, it should be supplied as an argument, rather than being an option.

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

Defining fields

A

containers for data:

databases call them columns

forms call them inputs

functions call them arguments.

  1. define a base field class to describe what it means to be a field
  2. defines API, how subclasses should behave, how they fit in with the system

Fields are part of the declaration and assigned as attributes on the class. Since they’re instantiated as part of the declaration, all the work has to be done in __init__().

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