Open cjcodeproj opened 2 months ago
Code should work something like this.
formatter = FormatterClass.new(Style.TEXT)
formatter.format(Output.LIST)
output = formatter.headers()
output += formatter.format_batch(in_batch)
output += formatter.close()
print(output)
There could be other methods, but the idea is the code could output either plain text or HTML without any code change at the application level. The code should also automatically change it's behavior based on the type of content that is being output.
For the tools that generate output reports, most of the processing is based on loading and sorting the data. The output part is easy, and most of that code is in other modules.
Consider an API framework that abstracted the output even further; so a tool like
media.tools.movies.list
could handle multiple output formats with very little change to the code base.