I'm working on a document processing system.
I feel confident with a
Document class which represents each document being processed.
Document can have a
CoverSheet, and if it does, we need to get
CoverSheetInfo from this
CoverSheet (for renaming and processing). But checking for a
CoverSheet and coercing the info into
CoverSheetInfo involves a fair amount of Apache PDFBox code.
I'm trying to decide on the best place to have this functionality.
Document class will have these methods:
public boolean hasCoverSheet()
public CoverSheetInfo getCoverSheetInfo()
Behavior is close to the data -- the process of checking a
Document for a
CoverSheet takes place in
Document which seems sensible.
This adds a lot of PDFBox - related parsing lines which make the other-wise simple set-get
Document look cluttered and makes the
Document class exceed 300 lines to include this functionality. Thus Option 2...
DocumentParser class which would have:
public boolean hasCoverSheet(Document document)
public CoverSheetInfo getCoverSheetInfo(Document document)
All the PDFBox - specific parsing code is in it's own Class. I think this is a good example of enforcing Single Responsibility/Law of Demeter As I don't think
Document should necessarily know how to parse information from cover sheets.
Awkward(?) separation of behavior from data(?)
Which one seems most reasonable and how so?
Edit: I'm desperate. Any feed back would be absolutely. fricken. loved.
Document is in this case a scanned mortgage document, and it will always be a PDF. A
Document is created when my app finds files in a directory (one
Document is made for each file found).
DocumentParser should process
Documents, right, File was a typo.
At this point,
Document is just a wrapper around the File essentially. In Option 1, it would have
CoverSheetInfo as a field and
File stubFile as well as
boolean regarding the existence of these things.
Here's the "story" for what I'm doing:
Someone will scan a document. It will end up in a directory. My app needs to look at that directory, and
rename the files by their cover sheet (if they have one)
make a stub out of the first 8 pages (if the file is very large)
Upload these files (and any stubs made) to Google Drive.