1
This directory contains "controllers". These are non-GUI objects that
2
manage GUI objects by connecting to their signals and updating them as
3
appropriate. Using controllers to manage GUI elements rather than
4
creating new widget types has several benefits:
6
1) It allows logic that involves several collaborating widgets to be
7
localized into a single code module. e.g., the widgets involved
8
in performing a package search might be in different parts of the
9
GUI rather than in a single container, but a single controller
10
can manage all of them.
12
2) It can make it easier to reuse logic in a new context (due to 1).
14
3) It can simplify some memory management considerations, by using
15
classes whose lifetimes are detached from the lifetimes of the
16
physical widgets they manage.
18
4) If controllers don't interact explicitly with GUI objects, they
19
can be unit-tested. e.g., the controller could interact with the
20
GUI via an abstract interface, and the unit test could provide an
21
implementation of this interface that is entirely non-interactive.
23
This directory, being in the generic section of the aptitude source
24
code, should not contain references to any UI-level objects.
26
For at least some of aptitude's code, 4) will require refactoring,
27
which should be done opportunistically as usual.
29
Controllers might provide an interface to the outside world; if so,
30
they should declare that interface as an abstract class in their
31
header file, deriving from sigc::trackable. This reduces compile-time
32
build dependencies and allows the controller to be mocked out for
35
Unlike views, controllers are implemented in this directory. This is
36
because controllers are less likely to have multiple implementations,
37
and also because they won't contaminate the abstract interface file
38
with GUI dependencies (whereas view implementations by definition must
39
be constructed from GUI objects).