General design suggestions for a new project
edit: Ok, to put this in a question, I'm asking for possible ways I should be organizing this into classes and which data structures I should use to store the informa开发者_如何学编程tion from transactions. Currently, I have this: (http://dl.dropbox.com/u/9210234/classes.jpg) - not even close to what I want, it's just what I'm working on. And it's currently storing the report data in dictionary objects as strings. I need to be able to easily extract this information, find transactions by searching on fields and things like that, and I'm pretty sure the way I'm currently going at it isn't going to make that easy.
I want to make an easy to use c# library for using the Payflow reporting API. There is a full guide available here. It's extremely nice and makes it easy to get information about past credit card transactions that my company has processed. I've already worked with it already, so actually using it isn't the issue. I'm at the point where I can hack together an app that does what is needed at the moment, or I can design something that is actually good and will be useful in a variety of programs that I could possibly make. Currently, I've been writing down ideas as they come to me, then making classes with appropriate methods to simplify calls to the API, then feeling out all of the possible features this will require. Once I get a prototype working, I plan to go back and design this entirely and then go ahead and create it.
The problem: I have no senior programmer to rely on and am still going through college learning design patterns, data structures and programming in general. I know a little bit about a lot of concepts, but I don't have more than a basic understanding of a few design patterns. I don't know how I should even attempt to organize this or what to do first. The best way I can ask for help here is to give you an idea of what I'm working on and then listening to suggestions of what to look into, which data structures to use, etc. Really, what I'm looking for is any suggestion on how I should design this better, as I don't know what I should be using at this point. The rest of this post is an explanation of what I've done so far, to give you an idea of what I've been doing and what I'm looking for this app to do.
I've created a test app to work on and test classes. Here's a picture of the classes so far: (http://dl.dropbox.com/u/9210234/classes.jpg). Yes, it's a mess. All of the code is in the form document, no interfaces or anything. The ReportWrapper class generates an XML request based on parameters (such as the date range, report type, etc.). Another class called BaseCall takes the request XML and actually sends it to the API and returns the response. ReportMetaData parses a response from a report metaData request and fills the properties with useful information (like the number of data pages). XmlUtility is just a helper class that does things like find out single node values or convert rows of data with unique attributes into key/value dictionaries. This is what gets stored in ReportStorage right now - a dictionary with the actual data of the report. The metaData is then used to determine what the fields in the report data are automatically. Page 36 of the Payflow guide I linked above shows what a data response looks like.
After requesting a data page, the rows are stored in reportStore as XML strings. XmlToAssoc then takes an xml string, tag name, attribute name of that tag (which is used as a unique ID by the API), and optionally a child node name. It returns a dictionary with the attribute value as the key and the innerXml as the value. I can then get information on a single transaction by cross referencing the metadata with the field data to get a complete picture of the transaction. Additionally, there is a dataType returned with the field name, which I'm going to use later.
So with each report data row I need to store the field name, field type, and value. It would look something like this:
reportData
reportDataRow 1:
fieldData 1:
{"Transaction ID", "string", "VLFA6D1CE4A6"}
fieldData 2:
{"Time","date","2010-12-19 00:21:41"}
[...]
reportDataRow 2:
fieldData 1:
{"Transaction ID", "string", "VLFA6D33554C"}
fieldData 2:
{"Time","date","2010-12-19 08:02:57"}
fieldData 3:
[...]
reportDataRow 3:
[...]
Once I have the storage figured out, I can move on to other operations, such as sorting, outputting the data to excel with field headers, etc.
You are obviously familiar with objects so the best suggestion I can give you is to look up object oriented principles. S.O.L.I.D Principles are a great place to start, you can find some really good articles out there.
Here is one of many for you to start with. A google search for object oriented design principles will also probably help you out.
精彩评论