Design
======

These are some notes about how to think about the design of a program. It
applies to designs of programs in general but has some specific parts about
Timeline.

Paradigm
--------

A paradigm in programming lets you think of think of a program in a certain
way. A paradigm influence the way we think about problems and their solutions.

Timeline is mainly written using the object-oriented paradigm which lets you
think of the program as a set of interacting objects. The object is the main
building block for abstractions.

See also:

  * [Programming paradigm (Wikipedia)](http://en.wikipedia.org/wiki/Programming_paradigm)

CRC Cards
---------

CRC (Class Responsibility Collaborator) cards is a tool for discovering what
objects are needed to solve a problem in an object-oriented system.

It can also be used when refactoring objects: If an object is difficult to use
or understand it might be an indication that its responsibilities are not
clearly defined, or that is has too many responsibilities. The solution is to
divide the responsibilities among a set of objects so that the original object
gets less responsibilities but more collaborators (other objects that does some
tasks for it).

Another way to think of an object (which is maybe the same as CRC cards) is by
asking these questions:

  * What is it? (Class name)
  * What can it do? (Responsibilities)
  * What problems does it solve? (Responsibilities)

See also:

  * [Class-Responsibility-Collaboration card (Wikipedia)](http://en.wikipedia.org/wiki/Class-Responsibility-Collaboration_card)

Object Responsibility
---------------------

### Example Sentences

Sometimes I find it difficult to define responsibilities in short sentences.
Here are some examples that I found that can work as inspiration:

  * Know the elements of which it is composed
  * Maintain the ordering between elements
  * Change the ordering of elements
  * Know how to display its elements
  * Store on, and restore from, a file

### Data

What are the responsibilities of objects that only contain data (and maybe some
simple methods to query that data)? Are they just responsible for keeping the
data together?

Take an object for handling 3D vectors as example. Is the responsibility to
provide a convenient way of working with 3D vectors? Or is it knowing how to
manipulate 3D vectors?

### GUI

The responsibilities of GUI components should in general be to present some
kind of information to the user and allow the user to interact with the
application.
