Friday, June 19, 2020

Domain Driven Design Chapter 8 Summary

Chapter 8: Breakthrough
    • "The returns from refactoring are not linear. Usually there is a marginal return for a small effort, and the small improvements add up. They fight entropy, and they are the frontline protection against a fossilized legacy. But some of the most important insights come abruptly and send a shock through the project."
    • "This sort of breakthrough is not a technique; it is an event. The challenge lies in recognizing what is happening and deciding how to deal with it. To convey what this experience feels like, I’ll tell a true story of a project I worked on some years ago, and how we arrived at a very valuable deep model."
  • Story of a Breakthrough
      • "When Intel wants to build a billion-dollar factory, they need a loan that is too big for any single lending company to take on, so the lenders form a syndicate that pools its resources to support a facility [...]. An investment bank usually acts as syndicate leader, coordinating transactions and other services. Our project was to build software to track and support this whole process."
      • "In the domain of commercial banking, a facility is a commitment by a company to lend."
    • A Decent Model, and Yet...
      • "We were feeling pretty good. Four months before, we had been in deep trouble with a completely unworkable, inherited code base, which we had since wrestled into a coherent model-driven design. The model [...] makes the common case very simple. [...] But there were some disconcerting signs. We kept stumbling over unexpected requirements that complicated the design."
    • The Breakthrough
      • "Suddenly one week it dawned on us what was wrong. Our model tied together the Facility and Loan shares in a way that was not appropriate to the business. This revelation had wide repercussions. With the business experts nodding, enthusiastically helping—and, I dare say, wondering what took us so long—we hashed out a new model on a whiteboard. Although the details hadn’t jelled yet, we knew the crucial feature of the new model: shares of the Loan and those of the Facility could change independently of each other."
    • A Deeper Model
      • "[We had] the realization that our “Investments” and “Loan Investments” were just two special cases of a general and fundamental concept: shares. Shares of a facility, shares of a loan, shares of a payment distribution. Shares, shares everywhere. Shares of any divisible value. "
      • "There were no longer specialized objects for the shares of a Facility or a Loan. They both were broken down into the more intuitive “Share Pie.” This generalization allowed the introduction of “shares math,” vastly simplifying the calculation of shares in any transaction, and making those calculations more expressive, concise, and easily combined."
      • "But most of all, problems went away because the new model removed an inappropriate constraint. It freed the Loan’s Shares to depart from the proportions of the Facility’s Shares, while keeping in place the valid constraints on totals, fee distributions, and so on. The Share Pie of the Loan could be adjusted directly, so the Loan Adjustment was no longer needed, and a large amount of special-case logic was eliminated."
      • "Suddenly, on the basis of this new way of looking at the domain, we could run through every scenario we had ever encountered relatively effortlessly, much more simply than ever before. And our model diagrams made perfect sense to the business experts, who had often indicated that the diagrams were “too technical” for them. Even just sketching on a whiteboard, we could see that our most persistent rounding problems would be pulled out by the roots, allowing us to scrap some of the complicated rounding code."
    • A Sobering Decision
      • "You might reasonably assume that we would have been elated at this point. We were not. We were under a severe deadline; the project was already dangerously behind schedule. Our dominant emotion was fear."
      • "The gospel of refactoring is that you always go in small steps, always keeping everything working. But to refactor our code to this new model would require changing a lot of supporting code, and there would be few, if any, stable stopping points in between."
      • Conversation with project manager:
        • "Q: How long would it take to get back to current functionality with the new design?"

          "A: About three weeks."

          "Q: Could we solve the problems without it?"

          "A: Probably. But no way to be sure."

          "Q: Would we be able to move forward in the next release if we didn’t do it now?"

          "A: Forward movement would be slow without the change. And the change would be much harder once we had an installed base."

          "Q: Did we think it was the right thing to do?"

          "A: We knew the political situation was unstable, so we’d cope if we had to. And we were tired. But, yes, it was a simpler solution that fit the business much better. In the long run it was lower risk."
    • The Payoff
      • "The mystifyingly unexpected requirement changes stopped. The rounding logic, though never exactly simple, stabilized and made sense."
      • "As version two evolved, this Share Pie became the unifying theme of the whole application. Technical people and business experts used it to discuss the system. Marketing people used it to explain the features to prospective customers. Those prospects and customers immediately grasped it and used it to discuss features. It truly became part of the ubiquitous language because it got to the heart of what loan syndication is about."
  • Opportunities
    • "Much as we might like it to be otherwise, progress isn’t a smooth ride. The transition to a really deep model is a profound shift in your thinking and demands a major change to the design. On many projects the most important progress in model and design come in these breakthroughs."
  • Focus on Basics
    • "Don’t become paralyzed trying to bring about a breakthrough. The possibility usually comes after many modest refactorings. Most of the time is spent making piecemeal improvements, with model insights emerging gradually during each successive refinement."
  • Epilogue: A Cascade of New Insights
    • "That breakthrough got us out of the woods, but it was not the end of the story. The deeper model opened unexpected opportunities to make the application richer and the design clearer."
    • "As is often the case after a real breakthrough to a deep model, the clarity and simplicity of the new design, combined with the enhanced communication based on the new ubiquitous language, had led to yet another modeling breakthrough."

Friday, June 12, 2020

Domain Driven Design Chapter 7 Summary

Chapter 7: Using the Language: An Extended Example
    • "In the earlier examples, the patterns were mostly applied one at a time, but on a real project you have to combine them. This chapter presents one elaborate example (still drastically simpler than a real project, of course)."
  • Introducing the Cargo Shipping System
    • Initial Requirements for cargo shipping company software:
      • Track key handling of customer cargo
      • Book cargo in advance
      • Send invoices to customers automatically when the cargo reaches some point in its handling
    • A diagram for an initial model is given, defining relationships between Customer, Role, Cargo, Delivery History, Delivery Specification, Handling Event, Carrier Movement, and Location
      • "A Handling Event is a discrete action taken with the Cargo, such as loading it onto a ship or clearing it through customs."
      • "Delivery Specification defines a delivery goal, which at minimum would include a destination and an arrival date, but it can be more complex."
      • "A role distinguishes the different parts played by Customers in a shipment. One is the “shipper,” one the “receiver,” one the “payer,” and so on. Because only one Customer can play a given role for a particular Cargo, the association becomes a qualified many-to-one instead of many-to-many."
      • "Carrier Movement represents one particular trip by a particular Carrier (such as a truck or a ship) from one Location to another."
      • "Delivery History reflects what has actually happened to a Cargo, as opposed to the Delivery Specification, which describes goals. A Delivery History object can compute the current Location of the Cargo by analyzing the last load or unload and the destination of the corresponding Carrier Movement."
  • Isolating the Domain: Introducing the Applications
    • Three user-level application functions:
      •  A Tracking Query that can access past and present handling of a particular Cargo
      • A Booking Application that allows a new Cargo to be registered and prepares the system for it
      • An Incident Logging Application that can record each handling of the Cargo (providing the information that is found by the Tracking Query)
  • Distinguishing Entities and Value Objects
    • In this section each of the objects are examined and identified as either entities or value objects.
    • Customer, Cargo, Handling Event, Carrier Movement, Location, and Delivery History are identified as entities.
      • There is a note on Delivery history that it has a one to one relationship  with its Cargo, and doesn't have an identity on its own.
    • Delivery Specification is identified as a value object
    • Role and Other Attributes
      • "Role says something about the association it qualifies, but it has no history or continuity. It is a value object, and it could be shared among different Cargo/Customer associations."
      • "Other attributes such as time stamps or names are value objects."
  • Designing Associations in the Shipping Domain
    • The association between Customer and Cargo should go from Cargo to Customer:
      • "It would be cumbersome for the Customer entity to cart around every Cargo it was ever involved in. A repository could provide access in the other direction."
    • "[The association between Cargo and Delivery History] remains bidirectional. Tracking is core to Cargo in this application. A history must refer to its subject."
    • There should be a one directional association from Cargo to Delivery Specification:
      • "Value objects usually shouldn’t reference their owners. The concept of Delivery Specification actually relates more to Delivery History than to Cargo."
    • The association goes from Handling Event to Carrier Movement:
      • "The directionality of this association relieves developers from dealing with the multiplicity in the untraversed direction."
    • "An ENTITY as basic as Location may be used by many objects for many reasons. This is only practical if it is unburdened of tracking its users."
  • Aggregate Boundaries
    • Cargo, Role, Delivery History, and Delivery Specification are grouped into a single aggregate.
      • Cargo
        • "Root of aggregate. Globally unique identifier."
      • Delivery History
        • "Internal to aggregate. Delivery History has meaning and identity only in association with Cargo."
    • Handling Event was kept separate
      • "A Handling Event needs to be created in a low-contention transaction—one reason to make it the root of its own aggregate."
  • Selecting Repositories
    • Needs are identified for a Customer Repository, a Cargo Repository, a Location Repository, and a Carrier Movement Repository.
    • "For now there is no Handling Event Repository, because we decided to implement the association with Delivery History as a collection in the first iteration, and we have no application requirement to find out what has been loaded onto a Carrier Movement. Either of these reasons could change; if they did, then we would add a repository."
  • Walking Through Scenarios
    • "To cross-check all these decisions, we have to constantly step through scenarios to confirm that we can solve application problems effectively."
    • Sample Application Feature: Changing the Destination of a Cargo
      • "Occasionally a Customer calls up and says, “Oh no! We said to send our cargo to Hackensack, but we really need it in Hoboken.” We are here to serve, so the system is required to provide for this change."
      • "Delivery Specification is a value object, so it would be simplest to just to throw it away and get a new one, then use a setter method on Cargo to replace the old one with the new one."
    • Sample Application Feature: Repeat Business
      • "The users say that repeated bookings from the same Customers tend to be similar, so they want to use old Cargoes as prototypes for new ones."
      • The example goes through in detail the necessary steps of using a previous cargo as a prototype, evaluating what to copy and what to modify.
      • "Notice that we have copied everything inside the Cargo aggregate boundary, we have made some modifications to the copy, but we have affected nothing outside the aggregate boundary at all."
  • Object Creation
    • Factories and Constructors for Cargo
      • For the "Repeat Business" we could consider a factory method on Cargo like this:

        public Cargo copyPrototype(String newTrackingID)

        Or perhaps a standalone factory:

        public Cargo newCargo(Cargo prototype, String newTrackingID)

        The standalone factory could perhaps encapsulate the process of getting the auto generated id, and could be simplified to this:

        public Cargo newCargo(Cargo prototype)
    • Adding a Handling Event
      • "Every class must have primitive constructors. Because the Handling Event is an entity, all attributes that define its identity must be passed to the constructor. As discussed previously, the Handling Event is uniquely identified by the combination of the ID of its Cargo, the completion time, and the event type."
      • Constructor could look like this:

        public HandlingEvent(Cargo c, String eventType, Date timeStamp) {
            handled = c;
            type = eventType;
            completionTime = timeStamp;
        }
      • "In this case, all attributes of the Handling Event are going to be set in the initial transaction and never altered (except possibly for correcting a data-entry error), so it could be convenient, and make client code more expressive, to add a simple factory method to Handling Event for each event type, taking all the necessary arguments. For example, a “loading event” does involve a Carrier Movement:"

        public static HandlingEvent newLoading(
            Cargo c, CarrierMovement loadedOnto, Date timeStamp) {
           
            HandlingEvent result = new HandlingEvent(c, LOADING_EVENT, timeStamp);
            result.setCarrierMovement(loadedOnto);
            return result;
        }
  • Pause for Refactoring: An Alternative Design of the Cargo Aggregate
    • There are complications that arise from the circular reference from Cargo to Delivery History to Handling Event, and back to Cargo again. Specifically, any time that a Handling Event is added, it must traverse the Cargo to the Delivery History and update the Delivery History to add the Handling Event.
    • This can be fixed by adding a Handling Event Repository, removing the persistent Delivery History reference from the Cargo, and instead recreate the Delivery History through calls to the repository on an as needed basis.
  • Modules in the Shipping Model
    • To show the importance of modules, the cargo delivery software is further built out with more moving pieces. The author the proceeds to show example module groupings in two diagrams to illustrate the point that poor grouping leads to high coupling. 
    • In one diagram, he groups modules as Entities, Values, and Services, and the diagram has a multiplicity of connections moving between each of the packages.
    • In a subsequent diagram, the same objects are instead grouped in the modules Customer, Billing, and Shipping, with a max of two connections between each module.
  • Introducing a New Feature: Allocation Checking
    • At this point, a new feature is requested that wasn't part of the original specification. This feature deals with allocating how much of any given product can be sold so that more profitable business transactions will not be crowded out by less profitable transactions. This will involve integrating the software with the software used in the sales department.
    • Connecting the Two Systems
      • "The Sales Management System was not written with the same model in mind that we are working with here. If the Booking Application interacts with it directly, our application will have to accommodate the other system’s design, which will make it harder to keep a clear model-driven design and will confuse the ubiquitous language. Instead, let’s create another class whose job it will be to translate between our model and the language of the Sales Management System. It will not be a general translation mechanism. It will expose just the features our application needs, and it will reabstract them in terms of our domain model. This class will act as an anticorruption layer (discussed in Chapter 14)."
    • Enhancing the Model: Segmenting the Business
      • Our system does not yet define "type" for Cargo. We could point blank use the information coming from the sales system, but there's a potentially better way.
      • An analysis pattern that could be used is the enterprise segment.
      • "An enterprise segment is a set of dimensions that define a way of breaking down a business. These dimensions could include all those mentioned already for the shipping business, as well as time dimensions, such as month to date."
      • This will be further discussed in chapter 11.
    • Performance Tuning
      • Depending on various situations or limitations with the other system that we must integrate with, various trade offs may need to be made in order to ensure performance.
  • A Final Look
    • "That’s it. This integration could have turned our simple, conceptually consistent design into a tangled mess, but now, using an anticorruption layer, a service, and some enterprise segments, we have integrated the functionality of the Sales Management System into our booking system cleanly, enriching the domain."
    • "A final design question: Why not give Cargo the responsibility of deriving the Enterprise Segment? At first glance it seems elegant, if all the data the derivation is based on is in the Cargo, to make it a derived attribute of Cargo. Unfortunately, it is not that simple. Enterprise Segments are defined arbitrarily to divide along lines useful for business strategy. The same entities could be segmented differently for different purposes. We are deriving the segment for a particular Cargo for booking allocation purposes, but it could have a completely different Enterprise Segment for tax accounting purposes. Even the allocation Enterprise Segment could change if the Sales Management System is reconfigured because of a new sales strategy. So the Cargo would have to know about the Allocation Checker, which is well outside its conceptual responsibility, and it would be laden with methods for deriving specific types of Enterprise Segment. Therefore, the responsibility for deriving this value lies properly with the object that knows the rules for segmentation, rather than the object that has the data to which those rules apply. Those rules could be split out into a separate “Strategy” object, which could be passed to a Cargo to allow it to derive an Enterprise Segment. That solution seems to go beyond the requirements we have here, but it would be an option for a later design and shouldn’t be a very disruptive change."

Thursday, June 4, 2020

Domain Driven Design Chapter 6 Summary

Chapter 6: The Life Cycle of a Domain Object
    • The challenges fall into two categories:
      • Maintaining integrity throughout the life cycle.
      • Preventing the model from getting swamped by the complexity of managing the life cycle.
    • Three patterns to address these issues:
      • Aggregates
        • "[T]ighten up the model itself by defining clear ownership and boundaries, avoiding a chaotic, tangled web of objects."
      • Factories
        • "[C]reate and reconstitute complex objects and aggregates, keeping their internal structure encapsulated."
      • Repositories
        • "[A]ddress the middle and end of the life cycle, providing the means of finding and retrieving persistent objects while encapsulating the immense infrastructure involved."
  • Aggregates
    • "It is difficult to guarantee the consistency of changes to objects in a model with complex associations. Invariants need to be maintained that apply to closely related groups of objects, not just discrete objects. Yet cautious lacking schemes cause multiple users to interfere pointlessly with each other and make a system unusable."
    • "[H]ow do we know where an object made up of other objects begins and ends?"
    • "Although this problem surfaces as technical difficulties in database transactions, it is rooted in the model -- in its lack of defined boundaries. A solution driven from the model will make the model easier to understand and make the design easier to communicate."
    • "An aggregate is a cluster of associated objects that we treat as a unit for the purposes of data changes. Each aggregate has a root and a boundary. The boundary defines what is inside the aggregate. The root is a single, specific entity contained in the aggregate. The root is the only member of the aggregate that outside objects are allowed to hold references to, although objects within the boundary may hold references to each other. Entities other than the root have local identity, but that identity needs to be distinguishable only within the aggregate, because no outside object can ever see it out of the context of the root entity."
    • "Invariants, which are consistency rules that must be maintained whenever data changes, will involve relationships between members of the aggregate. Any rule that spans aggregates will not be expected to be up-to-date at all times. Through event processing, batch processing, or other update mechanisms, other dependencies can be resolved within some specified time. But the invariants applied within an aggregate will be enforced with the completion of each transaction."
    • Rules to apply to all transactions
      • The root has global identity and is responsible for checking invariants.
      • Entities inside the boundary have local identity, unique only within the aggregate.
      • Nothing outside the boundary can hold a reference to anything inside, except the root entity. The root entity can hand out references to internal entities, but they can only be used transiently, and a reference cannot be held. The root may hand out a copy of a value object, and it doesn't matter what happens to it, because it's just a value and no longer has association with the aggregate.
      • Only aggregate roots can be obtained directly with database queries. All other objects must be found by traversal of associations.
      • Objects within the aggregate can hold references to other aggregate roots.
      • A delete operation must remove everything within the aggregate at once.
      • When a change to any object within the aggregate boundary is committed, all invariants of the whole aggregate must be satisfied.
  • Factories
    • "When creation of an object, or an entire aggregate, becomes complicated or reveals too much of the internal structure, factories provide encapsulation."
    • "An object should be distilled until nothing remains that does not relate to its meaning or support its role in interactions. This mid-life cycle responsibility is plenty. Problems arise from overloading a complex object with responsibility for its own creation."
    • "Creation of an object can be a major operation in itself, but complex assembly operations do not fit the responsibility of the created objects. Combining such responsibilities can produce ungainly designs that are hard to understand. Making the client direct construction muddies the design of the client, breaches encapsulation of the assembled object or aggregate, and overly couples the client to the implementation of the created object."
    • The two basic requirements for any good factory are:
      • Each creation method is atomic and enforces all invariants of the created object or aggregate.
      • The factory should be abstracted to the type desired, rather than the concrete class(es) created.
    • Choosing Factories and Their Sites
      • "Generally speaking, you create a factory to build something whose details you want to hide, and you place the factory where you want the control to be. These decisions usually revolve around aggregates."
      • "A factory is very tightly coupled to its product, so a factory should be attached only to an object that has a close natural relationship with the product. When there is something we want to hide [...] yet there doesn't seem to be a natural host, we must create a dedicated factory object or service."
    • When a Constructor is All You Need
      • "[T]here are times when the directness of a constructor makes it the best choice. Factories can actually obscure simple objects that don't use polymorphism."
      • The trade-offs favor a bare, public constructor in the following circumstances.
        • The class is the type. It is not part of any interesting hierarchy, and it isn't used polymorphically by implementing an interface.
        • The client cares about the implementation, perhaps as a way of choosing a strategy
        • All of the attributes of the object are available to the client, so that no object creation gets nested inside the constructor exposed to the client.
        • The construction is not complicated.
        • A public constructor must follow the same rules as a factory: It must be an atomic operation that satisfies all invariants of the created object.
      • "Constructors should be dead simple. Complex assemblies, especially of aggregates, call for factories. The threshold for choosing to use a little factory method isn't high."
    • Designing the Interface
      • Two points to keep in mind
        • Each operation must be atomic.
          • You have to pass in everything needed to create a complete product in a single interaction with the factory. You also have to decide what will happen if creation fails, in the event that some invariant isn't satisfied. You could throw an exception or just return null. To be consistent, consider adopting a coding standard for failures in factories.
        • The factory will be coupled to its arguments.
          • If you are not careful in your selection of input parameters, you can create a rat's nest of dependencies. The degree of coupling will depend on what you do with the argument. If it is simply plugged into the product, you've created a modest dependency. If you are picking parts out of the argument to use in the construction, the coupling gets tighter.
    • Where Does Invariant Logic Go?
      • "[Y]ou should think twice before removing the rules applying to an object outside that object. The factory can delegate invariant checking to the product, and this is often best."
      • "Under some circumstances, there are advantages to placing invariant logic in the factory and reducing clutter in the product. This is especially appealing with aggregate rules (which span many objects). It is especially unappealing with factory methods attached to other domain objects."
      • "An object doesn't need to carry around logic that will never be applied in its active lifetime. In such cases, the factory is a logical place to put invariants, keeping the product simpler."
    • Entity Factories Versus Value Object Factories
      • Entity factories differ from value object factories in two ways.
        • "Value objects are immutable; the product comes out complete in its final form. So the factory operations have to allow for a full description of the product. Entity factories tend to take just the essential attributes required to make a valid aggregate. Details can be added later if they are not required by an invariant."
        • "Then there is the issues involved in assigning identity to an entity -- irrelevant to a value object. [...] When the program is assigning an identifier, the factory is a good place to control it. Although the actual generation of a unique tracking id is typically done by a database "sequence" or other infrastructure mechanism, the factory knows what to ask for and where to put it."
    • Reconstituting Stored Objects
      • A factory used for reconstitution is very similar to one used for creation, with two major differences.
        • An entity factory used for reconstitution does not assign a new tracking ID.
          • "To do so would lose the continuity with the object's previous incarnation. So identifying attributes must be part of the input parameters in a factory reconstituting a stored object."
        • A factory reconstituting an object will handle violation of an invariant differently.
          • "During creation of a new object, a factory should simply balk when an invariant isn't met, but a more flexible response may be necessary in reconstitution. If an object already exists somewhere in the system (such as in the database), this fact cannot be ignored. Yet we also can't ignore the rule violation. There has to be some strategy for repairing such inconsistencies, which can make reconstitution more challenging than the creation of new objects."
  • Repositories
    • "Associations allow us to find an object based on its relationship to another. But we must have a starting point for a traversal to an entity or value in the middle of its life cycle."
    • "A database search is globally accessible and makes it possible to go directly to any object. There is no need for all objects to be interconnected, which allows us to keep the web of objects manageable. Whether to provide a traversal or depend on a search becomes a design decision, trading off the decoupling of the search against the cohesiveness of the association."
    • "[Developers] may use queries to pull the exact data they need from the database, or to pull a few specific objects rather than navigating from aggregate roots. Domain logic moves into queries and client code, and the entities and value objects become mere data containers. The sheer technical complexity of applying most database access infrastructure quickly swamps the client code, which leads developers to dumb down the domain layer, which makes the model irrelevant."
    • Querying a Repository
      • "Although most queries return an object or a collection of objects, it also fits within the concept to return some types of summary calculations, such as an object count, or a sum of a numerical attribute that was intended by the model to be tallied."
    • Client Code Ignores Repository Implementation; Developers Do Not
      • "Encapsulation of the persistence technology allows the client to be very simple, completely decoupled from the implementation of the repository. But as is often the case with encapsulation, the developer must understand what is happening under the hood. The performance implications can be extreme when repositories are used in different ways or work in different ways.
    • Implementing a Repository
      • "The ideal is to hid all the inner workings from the client (although not from the developer of the client), so that the client code will be the same whether the data is stored in an object database, stored in a relational database, or simply held in memory. [...] Encapsulating the mechanisms of storage, retrieval, and query is the most basic feature of a repository implementation."
    • Working Within Your Frameworks
      • "You may find that the framework provides services you can use to easily create a repository, or you may find that the framework fights you all the way. [...] In general, don't fight your frameworks. Seek ways to keep the fundamentals of domain-driven design and let go of the specifics when the framework is antagonistic. [...] This is assuming that you have no choice but to use the framework. [...] If you have the freedom, choose frameworks, or parts of frameworks, that are harmonious with the style of design you want to use."
    • The Relationship with Factories
      • "Because the repository is [...] creating objects based on data, many people consider the repository to be a factory -- indeed it is, from a technical point of view. But it is more useful to keep the model in the forefront, and as mentioned before, the reconstitution of a stored object is not the creation of a new conceptual object. In this domain-driven view of the design, factories and repositories have distinct responsibilities. The factory makes new objects; the repository finds old objects. The client of a repository should be given the illusion that the objects are in memory."
      • "One other case that drives people to combine factory and repository is the desire for "find or create" functionality, in which a client can describe an object it wants and, if no such object is found, will be given a newly created one. This function should be avoided. It is a minor convenience at best. A lot of cases in which it seems useful go away when entities and value objects are distinguished. [...] Usually, the distinction between a new object and an existing object is important in the domain, and a framework that transparently combines them will actually muddle the situation."
  • Designing Objects for Relational Databases
    • "When the database is being viewed as an object store, don't let the data model and the object model diverge far, regardless of the powers of mapping tools. Sacrifice some richness of object relationships to keep close to the relational model. Compromise some formal relational standards, such as normalization, if it helps simplify the object mapping."
    • "Processes outside the object system should not access such an object store. They could violate the invariants enforced by the objects. Also, their access will lock in the data model so that it is hard to change when the objects are refactored."
    • "The tradition of refactoring that has increasingly taken hold in the object world has not really affected relational database design much. What's more, serious data migration issues discourage frequent change. This may create a drag on the refactoring of the object model, but if the object model and the database model start to diverge, transparency can be lost quickly."