martes, febrero 22, 2005

OO: el desafío de "Muchos a Muchos"

Costin Cozianu trae a discusión un desafío del SQL y las bases de datos relacionales hecho al mundo de Orientación a Objetos: resolver en forma sintética algunas acciones sobre una relacion de muchos a muchos (en el ejemplo, usuarios asociados a grupos -un usuario en más de un grupo-). El enlace al problema en el título de esta nota.
El desafío:
  • Model the relationship between Users and Groups (many to many)
  • For all domain objects (Users and Groups), handle:
    • creation of new objects
    • updating of existing objects
    • deleting of existing objects (including cascading: if a group is deleted, any relationships are invalidated)
  • Querying for a set of objects which match a simple but arbitrary condition
  • Creating a relationship between any two instances
  • Removing a relationship between any two instances (including deletion as a result of deleting a member of the relationship)
  • Navigating the relationship both ways in better than linear time
  • If solution is not SQL, supply the entire implementation.
  • Make it thread safe and deadlock safe (this is functionality provided out of the box by SQL DBMSes).
El objetivo: "demostrar que SQL mantiene funcionalidad que no está rápidamente disponible, ni trivialmente implementable" en ambientes OO:

The challenge was intended to demonstrate that SQL has useful functionality that is not readily available, nor trivially implementable in OO environments. This is in contrast to claims of OO developers (DbasGoneBad, PrevalenceLayer, etc) that if we could only get SQL databases out of the picture then we'd have all milk and honey. Since many books on OO talk quite a lot and quite without substance about OO "relationships" (aggregation, composition, ownership, directionality, etc), and since I know from experience that managing OO relationships is a frequent source of bugs in OO programs, I put this challenge with the intent to make some OoWeenie?s out there painfully aware of the limitations of their own tools. In particular this page debunks a pervasive misconception (see quotes in ObjectRelationalPsychologicalMismatch) that RelationalModel is not as good at representing "relationships" as object models. Which claim should be judged ridiculous on the face of it, but it is amusing how many "important names" in the OO camp make it.

No hay comentarios.: