251 reputation
110
bio website ericanastas.com
location San Francisco, CA
age 33
visits member for 4 years, 2 months
seen 2 days ago
I write code

Oct
31
comment Representing category splits in a personal finance database
Wouldn't this be exactly the same as the second example in my original question then? Not that that is necessarily bad, as I was leaning toward that option.
Oct
30
comment Interface to enumerate over files
Yes but the specifics of how the file is "opened" or "closed" may vary. That's why I'm starting to think an abstract class that defines the overall flow may work better then an interface. The parent class could defined the overall flow and when/if exceptions are thrown or caught. Derived classes would then only need to implement the specifics of how files are opened and saved. Something like this pattern: dofactory.com/net/template-method-design-pattern
Oct
30
comment Interface to enumerate over files
Different enumerators which can access data in different sources.
Oct
30
comment Interface to enumerate over files
So while the enumerator may have multiple files open in the background my intent was that the FileProcessor would only be aware of, accessing, and processing one file at a time. Maybe my that would be more clear if I named these methods "GetNextFile()" and "FinishedWithCurrentFile()" instead?
Oct
30
comment Interface to enumerate over files
No the files would be processed in sequence by FileProcessor. However, in regards to having nested data my thought was the enumerator may keep multiple documents opened in the background. So when the FileProcessor calls OpenNext() the enumerator may open a parent document, and then a child document which it returns first. Then "CloseCurrentFile()" would in reality load the child back into the parent. The next call to OpenNext() would return the parent file to be processed, and then CloseCurrentFile() would close and potentially save the parent file.
Oct
30
comment Interface to enumerate over files
Yes the "enumerator" handles closing and saving. Basically I don't want the processor class to have to worry about where the data came from at all. Maybe it is just a file on a drive. Maybe the data had to be downloaded from an FTP site, or a web service. The caveat that I'm struggling with is the processor does need to know if the enumerator ends up saving the file so that it can include that information in the reported "ProcesssingJobResult".
Oct
30
comment Representing category splits in a personal finance database
Also I don't really understand the purpose of "SplitLineID". This looks like it's used to store the order of the split amounts? I don't think I care about the order though?
Oct
30
awarded  Critic
Oct
30
revised Representing category splits in a personal finance database
Added more columns to example tables
Oct
30
comment Representing category splits in a personal finance database
Thanks for the answer, but the problem I have with this idea is there is other information associated with the transaction that is not split like Date, Tags, Comments, AccountId etc...
Oct
30
asked Representing category splits in a personal finance database
Oct
29
awarded  Commentator
Oct
29
comment Interface to enumerate over files
The overall application I'm developing is a macro/automation tool which may be run on a scheduled with out any direct involvement from a user. So I also want the results of running a "ProcesssJob" on some enumerated set of files to be returned as a single "ProcesssingJobResult" which I can converted into a report, save to a database, saved to a log file etc..
Oct
29
comment Interface to enumerate over files
Part of the problem is acquiring the list of files can be a long process. Each file may need to be downloaded, and opened to find nested contents etc..etc. So I want to do the processing as the files are being iterated over rather then opening them twice. I've added a more elaborate example of my "FileProcessor" code which is consuming my IFileEnumerator
Oct
29
revised Interface to enumerate over files
added 1346 characters in body
Oct
29
comment Interface to enumerate over files
At the moment the method call to run all this looks something like: ProcessResult r = Processor. Run(docEnumerator, processJob); Where processJob is a collection of tasks to perform on each document. Processer reads each document from the enumerator, runs all the tasks, and compiles the results from all the documents into the returned ProcessResult.
Oct
29
comment Interface to enumerate over files
"Document" is a class in a third party API which I do not have control over. Yes I planned to have some implementation(s) of my interface traverse the file/document tree. But I don't want my Processor class to have to worry about this. The Processor class should only have to worry about processing documents one at a time in sequence. Also the status of each Document processed depends in part on the enumerator, as I was going to make read-only enumerators which open but do not save the documents.
Oct
29
comment Interface to enumerate over files
Although, your answer just gave me an idea. The iteration always follows certain steps GetFile->OpenFile->ProcessFile->SaveFile->CloseFile etc..But what actually happens during each step depends on the source. Sometimes "Save" means load back into the parent document, other times it means upload to the server. What if instead of using an interface I create an abstract class with abstract methods of each of these steps which concrete classes have to implement. dofactory.com/net/template-method-design-pattern
Oct
29
comment Interface to enumerate over files
The point of the IFileEnumerator is to abstract away the complexity of downloading/uploading/nested documents from the "Processor" class.
Oct
29
comment Interface to enumerate over files
Interesting way to look at it. The problem though is I do not know the full list of "files" at the beginning to pass into the FileEnumerator like you show. In reality these aren't actually files but instances of a "Document" class from a third party API. I used the term "File" to avoid overly complicating my question. The Documents can potentially be nested in other Documents which can be saved on a file system or on a couple different types of servers. So in some cases I wont know what Documents exist until a file is downloaded and the contents are read.