Com. Urp. Command. fileframework (3)
It's been a week before the previous article, and the work is still busy, and the project is still confused and cannot see the future clearly. If you don't talk about this, let's talk about your own stuff. I didn't submit any new articles last week, but I didn't want to write them myself. As the design went on, more and more things were considered, and more things I had never done. A lot of questions need to be written first to see how to design a function and then refactor it. Haha, there is a little bit of extreme programming experience. In fact, I have explained the lack of experience from the other side.
This week, the entire structure has changed significantly. To support dataset and collection at the same time, an additional layer is provided for no reason. Because. in net, Microsoft didn't let it inherit the ilist interface. In other words, there is no way to standardize it with the collection, so we can only write one more idataadapter interface and use the Object Adapter to put the dataset, the collection package seems to solve the problem. (Both dataset and datatable have an interface that inherits an ilistsource and provides the function of returning objects to the list of data sources that can be bound to them. It seems that the number of returned data sources is somewhat related to ilist, and the actual usage is not, there are not many articles on the Internet)
The idataadapter class diagram is as follows:
Dataadapterfactory is a simple factory that calls a static method and returns the idataadapter name to be instantiated to instantiate the idataadapter. Collectionadapter contains a modelcollection. modelcollection inherits from collectionbase. Each row records a model. Datatableadapter contains a datatable. Arrayadapter contains an object [] array, which is applicable to three different persistent layers. It should be said that the implementation of datatable is relatively easier, and many operations are equivalent to a simple database query, and you can directly fill the data into the datatable. Collectionadapter is relatively more complex and needs to implement its own data structure. It needs to build a row and column by imitating the datatable, and requires the user program to have its own model layer to provide get for each private field, set attribute to complete fill. However, datatableadapter may be the best in terms of efficiency, because it is a one-time read, as long as you access a file, and many times collectionadapter needs to read the file data in a row.
After this change, the idataadapter is mainly responsible for data persistence, data storage, reading data from the file into the memory, and finally importing the database, we only need to obtain the idataadapter, the read process is completed using ifileapi.
The class diagram of importfileframe and exportfileframe is as follows:
Added an abstract class of abstractfileframe. Open, close, and so on all mentioned in this class to facilitate future reuse. We expect import and export in importfileframe and exportfileframe to be implemented using the template method, for example:
Protected void import ()
{
Try {
Processfile (); // Save the temporary file to the server
Openfile (); // open the file
Importcheck (); // Import Verification
Import (); // Import
Deletefile (); // delete a temporary file
}
Catch (exception ex ){
}
Finally {
Closefile (); // close the file
}
}
Up to now, the four main frame classes have basically been formed. According to the changes in importfileframe and exportfileframe, there has not been too much impact on the first two frames, indicating that our functional design is still relatively successful. It should be noted that the ifileapi creation is somewhat different from the previous one, because the methods for reading files and data in the collectionadapter and ableableadapter are different, it is possible that it is best to create another set of classes inherited from ifileapi, and their instantiation factory should be determined by the idataadapter, so let's take this into consideration for the moment.
The import sequence diagram is as follows: