Open JStonham opened 5 years ago
JsonInterpreter
(actual naming is up to you). Similarly for methods, but here you should also add the method signature, i.e. what does it return, what does it take as arguments, does it throw any exceptions?java.io.File
or a String
? I think perhaps one class for converting (and reading) java.io.File <-> String(JSON)
and another for converting String(JSON) <-> List<Transaction>
will make testing easier. Especially since the latter one is already done, iirc.java.io.File
or connects to a database. Maybe a TransactionAppender
makes more sense?My current thinking (taking into account the code we wrote last time) is something like this. Hopefully you can fill a bit more detail?
Application
:
TransactionAppender
:
String
of JSONList<Transaction>
by calling JsonInterpreter
List<Transaction>
to a String
of JSON againString
to the TransactionRepository
again to write to disk.JsonInterpreter
:
String transactionsToString(List<Transaction)
List<Transaction> stringToTransactions(String)
TransactionRepository
:
String findStoredJson()
void storeJson(String json)
The object is to persist the list of transactions between different instances of the application.
Application
:TransactionAppender
TransactionAppender
:TransactionRepository
to get aString
of JSON.String
into aList<Transaction>
by callingJsonInterpreter
.List<Transaction>
.List<Transaction>
to Application to print.List<Transaction>
to aString
of JSON again by callingJsonInterpreter
.String
to theTransactionRepository
again to write to disk.JsonInterpreter
:String transactionsToString(List<Transaction)
. Get JSONString
fromTransactionRepository
. Acceptance test is aString
in the correct JSON format below.List<Transaction> stringToTransactions(String)
. GetList<Transaction>
fromTransactionAppender
. Acceptance test is list of transactions with correct components. JSONString
example format:TransactionRepository
:String findStoredJson()
if not found create new JSON file{}
, if not valid JSONthrow new RuntimeException("Contact the developer at example.com")
.void storeJson(String json)
. Save to~/.config//budjen/transactions.json
. If file not foundthrow new RuntimeException("Contact the developer at example.com")
.Acceptance Criteria
budjen print
then I expect no transactions.budjen add
then I expect transaction to be saved.budjen print
then I expect a list of transactions.budjen print
then I only expect a message telling me to contact the developer.