Part 1

The kinds of data-object pattern 

   
Did you have a broad overview on the data-object pattern you have used? Be carefully, we can find out the three kinds of data-object pattern we have used frequently.
    1. Single
    This kind of data-object pattern we touched it very more, 
                     
                                        Figure 1
   On the top, the figure shows the single data-object pattern, It is so simple; the Payment object has three attributes.
   2.Master/Detail
   We also usually use the master/detail pattern, usually a master table corresponds to a detail or multiple details with  a synthetic identity,
               
                                                    Figure 2
    In this kind of pattern, we should pay two points on it:
    2.1. When got the  data from database, it gave me two records or more, should take care for the corresponding of data.

    2.2. When submitted the data into database, there will at least has two statements. To keep the two statements excuting successfully is the key point.
    3.Tree
    Tree pattern was used very popular , becuase it gives me a directly vision, and most of users want this kind of user interface, sorry, here we are not talking about the interface.
               
                                                                                            Figure 3
    In this kind of patern, we should pay more concern on how to give the synchro data from the database, there are two kinds of way to keep synchro data.
    3.1. When the app is initiating, get the all data of the tree, this way can save waiting time when user are requesting the data, but also has a downfall, if the data is a much more large scale, and will consume a lot of time on loading the data, so it may give a delay when it is initiating.
    
    3.2. Another way I think you have thought, We can load the top data only, when users are requesting the data, then populate the data the users need. as I saied on the previous way, it also has the downfall, it may give a delay when users are requesting the data they need.
   
Here I would like give my options, the two way can be used on different conditions, How to decide? in general, if the data is small enough,
I recommend the previous, if the data is a large scale, I recommend the next.

    Comparison
    On the above words, I go a listing for the general data-object patterns we have used very popular, Certianly you can give  the new patterns, next we will disscus the difference with the three kinds of data-object patterns.
    1.Complexity; you can directly see from the figures, you can find the first pattern is the simplest. yes, you are good eyes, the first pattern is the simplest so that can describe the simplest entity, in general the first pattern is mapping a table in a relational database. the next is more complex than the first so that it can describe more entities, it can be mapping two or more tables with a relational database. The third is the most complex pattern,it can describle the most entities, can be mapping three or more tables with a relational database. In genaral,I don't recommend the third pattern if you develop a web based app becuase of a problem existed that it is very difficult display  a tree figure in web apps.I prefer to recommend the second pattern based on web developing.

    2.O/R mapping layer's desgin; Certianly, we should desgin the O/R mapping layer to service the business logic layer, The first pattern is easiest to work out a class to suit the entity. The second pattern is easier to work out the class to suit the entities,you may inherit a class. The third pattern you must pay more concern to how to work out the class to suit the entity, becuase this pattern is very complex, if the entity has three layers, you may use more than three classes to suit the entities.

    Ok, in this part,we have talked three kinds of pattern, have compared the differences. In the next part we will discuss about how to try out a common model for the three kinds of pattern.








 

posted @ 2005-01-04 08:56  23热爱,自学业余码农。  阅读(317)  评论(0编辑  收藏  举报