From 08deecf1954f6cf748812057ba5cdd9a0425bfc9 Mon Sep 17 00:00:00 2001 From: Grant Ammons Date: Tue, 3 Oct 2017 07:20:02 -0400 Subject: Refactor the formatter to an interface and rename it This change refactors the formatter to be an interface called Printer. `NewApp` will use the functionality of `ScreenPrinter`, which is what I refactored the old `Formatter` class into. There is a new class the implements the `Printer` interface called `MemoryPrinter`, which will simply store the `groups` as they were passed to it. This will allow tests in `app_test.go` to become much more powerful, since `App` no longer needs to be tightly coupled to printing to the screen. --- memory_printer.go | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 memory_printer.go (limited to 'memory_printer.go') diff --git a/memory_printer.go b/memory_printer.go new file mode 100644 index 0000000..62eaa83 --- /dev/null +++ b/memory_printer.go @@ -0,0 +1,9 @@ +package todolist + +type MemoryPrinter struct { + Groups *GroupedTodos +} + +func (m *MemoryPrinter) Print(groupedTodos *GroupedTodos, printNotes bool) { + f.Groups = groupedTodos +} -- cgit v1.3