TimFinucane / Ainur

Solution for parallel task scheduling problem, inspired by the tale of the Lord of the Rings
Other
5 stars 0 forks source link

Interpretting Dot files #28

Closed nathan-cairns closed 6 years ago

nathan-cairns commented 6 years ago

Kia ora. Should the reader and writer classes be responsible to validating whether or not a file is of the correct format? i.e. check whether file is .dot, if not throw like an incorrectFileFormat exception or something? OR should it be the responsibility of the class which calls .read()/.write() in the reader/writer?

DILEMMA

emipeanz commented 6 years ago

I think the class calling it should check as read and writer get input/output streams, rather than the actual reader and writer opening/creating file to read. Cause main hands in a stream, and the reader class doesnt have anything to do with actually reading the file

Buster-Darragh-Major commented 6 years ago

at the moment the reader will throw an unchecked exception if the file is not semantically valid, which it can only tell if the file is in .dot format. Any incorrect format should end up throwing this exception and end the program.

Note that this will allow for syntactically incorrect PARTS of the file, but as long as there is a semantically valid graph somewhere that adheres to .dot format embedded in the incorrectly formatted file it should in theory work. Do we want it to do this? or for it to be more strict?

If you wanted to display some error to the user you could catch the unchecked exception that is currently being thrown

TimFinucane commented 6 years ago

When it comes to how correct the reader is, it only needs to read (at most) all possible correct graphs, not fail to read all bad ones. When it comes to how we want to display errors we should probably look at what normal java apps do. At the moment I think an unchecked exception makes sense because we would never be able to recover from a bad dot file, we would have to exit at that point.