Conceptualizing my program

Trying to work my way towards squeaky new beginner to beginner/intermediate. Below is a simple beginning of a program I am working on. The idea of the program is to calculate and write out a report of the total page count in a directory of tif and/or pdf files. Sounds simple enough though I plan on expanding on it a bit to offer simple or detailed report, file by file, page by page and write it out to a CSV file. Scanning bureaus can charge scans by page and/or page size too (takes more resources and time to scan an 11×17 document than an 8.5×11)

So essential a folder will be selected by the user, an option to produce a simple or detailed report will be provided, and eventually a means to record a cost per page based on the size of the document.

The program will read in all the files (tif or pdf only), make these discoveries and write them out. I had the thought too to make this script-enabled from the command line also. So I'll need to separate my functionality out into a dll that either the GUI and another smaller program can use.

Now the advice I've received thus far is to use Interfaces. I've started that concept below. I need a nudge in the right direction as I expand on this. One example of what I'm struggling with is that the program will return an Enumerable list of files it finds. Surely I don't want to create a new Class for each file that is found, right?

I have already done some research on ,Net capabilities to get the page count and other attributes. I'll be using iText to get the pdf attributes I want. I'll be retrieving the same attributes whether it is a tif or pdf, but how they are retrieved will be different (except file size of course)

namespace pgcnt { public interface IDocFile { int PageCount { get; } long FileSize { get; } int GetPageCount(string FileName); int GetFileSize(string FileName); } } namespace pgcnt { public class TifDocFile : IDocFile { public int PageCount { get { return 0; }} public long FileSize { get { return 0; }} public int GetPageCount(string FileName) { return 0; //code here to retrieve tif page count } public int GetFileSize(string FileName) { return 0; //code here to retrieve file size } } } 

by Zamdrist via /r/csharp

Leave a Reply