The paradigm mismatch ADDRESS_ZIPCODE varchar(5), ADDRESS_COUNTRY varchar(15) ) (Free web hosting with ftp)
Tuesday, September 25th, 2007The paradigm mismatch ADDRESS_ZIPCODE varchar(5), ADDRESS_COUNTRY varchar(15) ) Classes in our domain model come in a range of different levels of granularity from coarse-grained entity classes like User, to finer-grained classes like Address, down to simple String-valued properties such as zipcode. In contrast, just two levels of granularity are visible at the level of the SQL database: tables such as USERS, and columns such as ADDRESS_ZIPCODE. Many simple persistence mechanisms fail to recognize this mismatch and so end up forcing the less flexible SQL representation upon the object model. We ve seen countless User classes with properties named zipcode! It turns out that the granularity problem isn t especially difficult to solve. We probably wouldn t even discuss it, were it not for the fact that it s visible in so many existing systems. We describe the solution to this problem in chapter 4, section 4.4, Fine-grained models and mappings. A much more difficult and interesting problem arises when we consider domain models that rely on inheritance, a feature of object-oriented design we may use to bill the users of our e-commerce application in new and interesting ways. 1.2.2 The problem of subtypes In Java, you implement type inheritance using superclasses and subclasses. To illustrate why this can present a mismatch problem, let s add to our e-commerce application so that we now can accept not only bank account billing, but also credit and debit cards. The most natural way to reflect this change in the model is to use inheritance for the BillingDetails class. We may have an abstract BillingDetails superclass, along with several concrete subclasses: CreditCard, BankAccount, and so on. Each of these subclasses defines slightly different data (and completely different functionality that acts on that data). The UML class diagram in figure 1.3 illustrates this model. SQL should probably include standard support for supertables and subtables. This would effectively allow us to create a table that inherits certain columns from Figure 1.3 Using inheritance for different billing strategies
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.