OOD/OOP and databases

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas Jespersen

    OOD/OOP and databases

    Hello

    I've been reading a lot of great OOD/OOP books lately (e.g.. Martin Fowlers
    UML Distilled, Patterns of Enterprise Application Architecture, Refactoring,
    Kent Becks's Test Driven Development, and also a book called Design Patterns
    Explained.)... al of them with the focus on Java, because I think the best
    books are targeted Java. But the all fit very well to the .NET platform.

    I have one big problem when reading these great books, and that is that they
    focus almost entirely on the Domain Model (that is the Middle Layer in a 3
    layered architecture). They hardly mention that the code you write is to be
    used in a UI interface and committed to a database ([PoEAA] might be an
    exception). I find the separation of Business Login and UI to be the hardest
    thing. And also I find the performance issues when talking to the Database
    to a very tricky thing, that calls for a few hack in the Domain Layer (I'm
    almost only doing thick clients... that is no web).

    So I would like to know how you OO Guys really work (references to books or
    articles would be great).

    Don't you design your database the same way that you design you Business
    Model if you are responsible for all 3 layers/tiers?

    How much time does you spend on writing the DAL (the mapping between the OO
    and the Database)? Do you use any kind of O/R Mappers to help you write the
    DAL?

    Where do you place the tiers in a Smart Client configuration? The way I see
    it the UI and Domain Model must be on the client. Because you Domain Model
    contains a lot of information e.g. about validation the input, and I don't
    want a Server Round Trip every time the users enters something in a textbox.
    But I'm also thinking about putting the same domain objects on the server
    aswell and use some kind of serialization using .NET Remoting or Web
    Services. Anyone else placing the Domain Model on both the Client and
    Server?

    Can you recommend any third party frameworks, which addresses any of these
    problems? I find many of the MS Reference application to be to exotic.

    I know these are big questions for a thread in a newsgroup... but never the
    less, I haven't found any books or articles that really deals with these
    issues.

    Best regards,
    Thomas
    MCSD, MCSE+I, MCP+SB


  • Nick Malik

    #2
    Re: OOD/OOP and databases

    Yes... that's a lot for a newsgroup.

    Start here:


    I, too, have read many of the same books. You didn't mention the Design
    Patterns book itself (Gang of Four: Gamma, Helm, Johnson, and Vlissides) but
    it, too, is an excellent volume. There are also a number of patterns books
    that describe code in C# that have been coming out in the past two years.

    The books do not focus on a particular tier. The Design Patterns books,
    specifically, focus on a specific level of abstraction. The Fowler book
    focuses on a different level of abstraction. Buschmann takes on the
    architectural level. Honestly, to answer your questions, Buschmann is the
    best of the group.

    The Microsoft site has some very specific advice for the .NET platform with
    regards to optimizations.. . worth looking into.

    As for me: my middle tier is normally tailored to one thing: hiding the
    business rules. That requires real analysis: what are the business rules...
    what will change... how will they change... how will we maintain them.

    Config files are not good for business rule changes... they are too
    tactical. You can change the name of a stored proc in the config file. To
    change the business rules, you need to encapsulate logic, not just
    constants. Using pluggable components will only get you so far.

    So, if the business layer has very few business rules, it's really thin.
    For many purposes, especially for domain tables (lookup tables), I don't
    have any logic at all in the middle tier. In that case, I often simply pass
    the data through directly from the DAL to the UI layer as an array of
    DataRows. I'll even occasionally bind directly to a control (not often, but
    for drop-downs, it's good). On the other hand, if the business layer has
    business rules to encapsulate, then I will organize the objects so that
    managing those rules makes sense. This is where we start to deviate from
    "business objects that mirror the database". This is where the design
    patterns come in handy. You really have to map your data into objects that
    isolate change and minimize complexity.

    I've yet to find a tool or framework that does more than simply
    copy-and-reflect operations from the database through the middle tier. I
    don't use them. WHat a massive waste of time and processing power. Heck...
    the DataSet object does a better job than most of these, and it doesn't
    require a huge amount of effort to use! (I don't use it either... I'm just
    making a point).

    As for copying the validation rules: For a thick client app, I'd have the
    same validation dll on both the client and the server. That way, you can
    insure common rules. Note: business rules are much more than validation.
    I'd have basic validation types that I can use in both places, but the rest
    of the rules are quite different.

    As for use of remoting: depends on the kind and style of scalability you
    want to achieve. For my preference, remoting is too tightly coupled for the
    kinds of things that I do... I tend toward web services... but that may not
    be advice that you can use... depends on your app.

    I hope this info is helpful.
    --- Nick Malik
    Application Architect
    MCSD, CFPS, Certified Scrummaster
    "Thomas Jespersen" <tje@nospam.men tum.dk> wrote in message
    news:ecFEdt%23l EHA.2880@TK2MSF TNGP14.phx.gbl. ..[color=blue]
    > Hello
    >
    > I've been reading a lot of great OOD/OOP books lately (e.g.. Martin[/color]
    Fowlers[color=blue]
    > UML Distilled, Patterns of Enterprise Application Architecture,[/color]
    Refactoring,[color=blue]
    > Kent Becks's Test Driven Development, and also a book called Design[/color]
    Patterns[color=blue]
    > Explained.)... al of them with the focus on Java, because I think the best
    > books are targeted Java. But the all fit very well to the .NET platform.
    >
    > I have one big problem when reading these great books, and that is that[/color]
    they[color=blue]
    > focus almost entirely on the Domain Model (that is the Middle Layer in a 3
    > layered architecture). They hardly mention that the code you write is to[/color]
    be[color=blue]
    > used in a UI interface and committed to a database ([PoEAA] might be an
    > exception). I find the separation of Business Login and UI to be the[/color]
    hardest[color=blue]
    > thing. And also I find the performance issues when talking to the Database
    > to a very tricky thing, that calls for a few hack in the Domain Layer (I'm
    > almost only doing thick clients... that is no web).
    >
    > So I would like to know how you OO Guys really work (references to books[/color]
    or[color=blue]
    > articles would be great).
    >
    > Don't you design your database the same way that you design you Business
    > Model if you are responsible for all 3 layers/tiers?
    >
    > How much time does you spend on writing the DAL (the mapping between the[/color]
    OO[color=blue]
    > and the Database)? Do you use any kind of O/R Mappers to help you write[/color]
    the[color=blue]
    > DAL?
    >
    > Where do you place the tiers in a Smart Client configuration? The way I[/color]
    see[color=blue]
    > it the UI and Domain Model must be on the client. Because you Domain Model
    > contains a lot of information e.g. about validation the input, and I don't
    > want a Server Round Trip every time the users enters something in a[/color]
    textbox.[color=blue]
    > But I'm also thinking about putting the same domain objects on the server
    > aswell and use some kind of serialization using .NET Remoting or Web
    > Services. Anyone else placing the Domain Model on both the Client and
    > Server?
    >
    > Can you recommend any third party frameworks, which addresses any of these
    > problems? I find many of the MS Reference application to be to exotic.
    >
    > I know these are big questions for a thread in a newsgroup... but never[/color]
    the[color=blue]
    > less, I haven't found any books or articles that really deals with these
    > issues.
    >
    > Best regards,
    > Thomas
    > MCSD, MCSE+I, MCP+SB
    >
    >[/color]


    Comment

    • Jay B. Harlow [MVP - Outlook]

      #3
      Re: OOD/OOP and databases

      Thomas,
      I would consider a Table Module & Table Data Gateway approach if my "Domain
      objects" did not have any real logic to them. See
      http://www.martinfowler.com/eaaCatalog/tableModule.html &
      http://www.martinfowler.com/eaaCatal...taGateway.html patterns. I
      consider DataSets (both typed & untyped) to be ideal for implementing Table
      Module & Table Data Gateways.

      However if my "Domain Objects" had heavy logic to them, then I would use a
      Domain Model and Data Mapper approach. See:
      http://www.martinfowler.com/eaaCatalog/domainModel.html &
      http://www.martinfowler.com/eaaCatalog/dataMapper.html patterns.
      [color=blue]
      > Don't you design your database the same way that you design you Business
      > Model if you are responsible for all 3 layers/tiers?[/color]
      I don't (at least I attempt not to) when using a Domain Model, although they
      may be close. Martin's PoEAA has a number of patterns useful here.

      However! with Table Module they tend to work out that way.
      [color=blue]
      > How much time does you spend on writing the DAL (the mapping between the
      > OO
      > and the Database)? Do you use any kind of O/R Mappers to help you write
      > the
      > DAL?[/color]
      I have not used an O/R mapper yet.

      [color=blue]
      > Can you recommend any third party frameworks, which addresses any of these
      > problems? I find many of the MS Reference application to be to exotic.[/color]

      Rockford Lhotka's book "Expert One-on-One Visual Basic .NET Business
      Objects" from A! Press provides a pre-implemented variation of Fowler's
      Domain Model & Data Mapper patterns. See CSLA.NET at:


      [color=blue]
      > Services. Anyone else placing the Domain Model on both the Client and
      > Server?[/color]
      Lhotka's CSLA.NET is leverages .NET remoting if you choose to use it.


      Hope this helps
      Jay


      "Thomas Jespersen" <tje@nospam.men tum.dk> wrote in message
      news:ecFEdt%23l EHA.2880@TK2MSF TNGP14.phx.gbl. ..[color=blue]
      > Hello
      >
      > I've been reading a lot of great OOD/OOP books lately (e.g.. Martin
      > Fowlers
      > UML Distilled, Patterns of Enterprise Application Architecture,
      > Refactoring,
      > Kent Becks's Test Driven Development, and also a book called Design
      > Patterns
      > Explained.)... al of them with the focus on Java, because I think the best
      > books are targeted Java. But the all fit very well to the .NET platform.
      >
      > I have one big problem when reading these great books, and that is that
      > they
      > focus almost entirely on the Domain Model (that is the Middle Layer in a 3
      > layered architecture). They hardly mention that the code you write is to
      > be
      > used in a UI interface and committed to a database ([PoEAA] might be an
      > exception). I find the separation of Business Login and UI to be the
      > hardest
      > thing. And also I find the performance issues when talking to the Database
      > to a very tricky thing, that calls for a few hack in the Domain Layer (I'm
      > almost only doing thick clients... that is no web).
      >
      > So I would like to know how you OO Guys really work (references to books
      > or
      > articles would be great).
      >
      > Don't you design your database the same way that you design you Business
      > Model if you are responsible for all 3 layers/tiers?
      >
      > How much time does you spend on writing the DAL (the mapping between the
      > OO
      > and the Database)? Do you use any kind of O/R Mappers to help you write
      > the
      > DAL?
      >
      > Where do you place the tiers in a Smart Client configuration? The way I
      > see
      > it the UI and Domain Model must be on the client. Because you Domain Model
      > contains a lot of information e.g. about validation the input, and I don't
      > want a Server Round Trip every time the users enters something in a
      > textbox.
      > But I'm also thinking about putting the same domain objects on the server
      > aswell and use some kind of serialization using .NET Remoting or Web
      > Services. Anyone else placing the Domain Model on both the Client and
      > Server?
      >
      > Can you recommend any third party frameworks, which addresses any of these
      > problems? I find many of the MS Reference application to be to exotic.
      >
      > I know these are big questions for a thread in a newsgroup... but never
      > the
      > less, I haven't found any books or articles that really deals with these
      > issues.
      >
      > Best regards,
      > Thomas
      > MCSD, MCSE+I, MCP+SB
      >
      >[/color]


      Comment

      • Thomas Jespersen

        #4
        Re: OOD/OOP and databases

        Hello Nick

        Thanks for you input.

        First... Yes, you are right, I haven't read the GoF book yet. I thought I
        start with something a bit lighter which Design Patterns Explained was (a
        great introduction to OOD though). Is it readable for a .NET guy?

        Buschmann... never heard of him (embarrassed smiley here). I took a look on
        Amazon... can you recommend a specific book?

        I read a lot from the Microsoft Patterns & Practices group. I like the
        Application Blocks, although I don't really see them as a design guide....
        they are just... well Application Blocks.

        Regarding my problem about separating the Business and the UI. I agree that
        business rules is much more than validation. But I often find that all kind
        of rules are need in the UI. E.g. which menu items is shown, warnings and
        other things to make sure that exceptions doesn't occurs when calling the
        Domain Model. This might sound odd, but e.g. I might have a rule that I
        can't call Customer.AddCon tactInformation , if the customer is inactive or
        unsaved. So I'd make a Property on the Customer called
        AddContactInfor mationAllowed. I use this property to decide whether a
        certain menu option is available, and/or I call this before
        AddContactInfor mation, to make sure that it doesn't throw an exception.

        For me this kind of interaction is a must to make a usable client
        application (which is what's count in the end... at least for me), but I
        don't se much of this kind in the OO books. But I will consider splitting up
        the Domain Model in two (on for validation like things, and one for hiding
        business rules)... I'm just not quit sure that this is doable, if related
        responsibilitie s is to be grouped on the same object.

        Thomas

        "Nick Malik" <nickmalik@hotm ail.nospam.com> wrote in message
        news:7MG0d.4177 94$%_6.111013@a ttbi_s01...[color=blue]
        > Yes... that's a lot for a newsgroup.
        >
        > Start here:
        > http://www.microsoft.com/resources/p...s/default.mspx
        >
        > I, too, have read many of the same books. You didn't mention the Design
        > Patterns book itself (Gang of Four: Gamma, Helm, Johnson, and Vlissides)[/color]
        but[color=blue]
        > it, too, is an excellent volume. There are also a number of patterns[/color]
        books[color=blue]
        > that describe code in C# that have been coming out in the past two years.
        >
        > The books do not focus on a particular tier. The Design Patterns books,
        > specifically, focus on a specific level of abstraction. The Fowler book
        > focuses on a different level of abstraction. Buschmann takes on the
        > architectural level. Honestly, to answer your questions, Buschmann is the
        > best of the group.
        >
        > The Microsoft site has some very specific advice for the .NET platform[/color]
        with[color=blue]
        > regards to optimizations.. . worth looking into.
        >
        > As for me: my middle tier is normally tailored to one thing: hiding the
        > business rules. That requires real analysis: what are the business[/color]
        rules...[color=blue]
        > what will change... how will they change... how will we maintain them.
        >
        > Config files are not good for business rule changes... they are too
        > tactical. You can change the name of a stored proc in the config file.[/color]
        To[color=blue]
        > change the business rules, you need to encapsulate logic, not just
        > constants. Using pluggable components will only get you so far.
        >
        > So, if the business layer has very few business rules, it's really thin.
        > For many purposes, especially for domain tables (lookup tables), I don't
        > have any logic at all in the middle tier. In that case, I often simply[/color]
        pass[color=blue]
        > the data through directly from the DAL to the UI layer as an array of
        > DataRows. I'll even occasionally bind directly to a control (not often,[/color]
        but[color=blue]
        > for drop-downs, it's good). On the other hand, if the business layer has
        > business rules to encapsulate, then I will organize the objects so that
        > managing those rules makes sense. This is where we start to deviate from
        > "business objects that mirror the database". This is where the design
        > patterns come in handy. You really have to map your data into objects[/color]
        that[color=blue]
        > isolate change and minimize complexity.
        >
        > I've yet to find a tool or framework that does more than simply
        > copy-and-reflect operations from the database through the middle tier. I
        > don't use them. WHat a massive waste of time and processing power.[/color]
        Heck...[color=blue]
        > the DataSet object does a better job than most of these, and it doesn't
        > require a huge amount of effort to use! (I don't use it either... I'm[/color]
        just[color=blue]
        > making a point).
        >
        > As for copying the validation rules: For a thick client app, I'd have the
        > same validation dll on both the client and the server. That way, you can
        > insure common rules. Note: business rules are much more than validation.
        > I'd have basic validation types that I can use in both places, but the[/color]
        rest[color=blue]
        > of the rules are quite different.
        >
        > As for use of remoting: depends on the kind and style of scalability you
        > want to achieve. For my preference, remoting is too tightly coupled for[/color]
        the[color=blue]
        > kinds of things that I do... I tend toward web services... but that may[/color]
        not[color=blue]
        > be advice that you can use... depends on your app.
        >
        > I hope this info is helpful.
        > --- Nick Malik
        > Application Architect
        > MCSD, CFPS, Certified Scrummaster
        > "Thomas Jespersen" <tje@nospam.men tum.dk> wrote in message
        > news:ecFEdt%23l EHA.2880@TK2MSF TNGP14.phx.gbl. ..[color=green]
        > > Hello
        > >
        > > I've been reading a lot of great OOD/OOP books lately (e.g.. Martin[/color]
        > Fowlers[color=green]
        > > UML Distilled, Patterns of Enterprise Application Architecture,[/color]
        > Refactoring,[color=green]
        > > Kent Becks's Test Driven Development, and also a book called Design[/color]
        > Patterns[color=green]
        > > Explained.)... al of them with the focus on Java, because I think the[/color][/color]
        best[color=blue][color=green]
        > > books are targeted Java. But the all fit very well to the .NET platform.
        > >
        > > I have one big problem when reading these great books, and that is that[/color]
        > they[color=green]
        > > focus almost entirely on the Domain Model (that is the Middle Layer in a[/color][/color]
        3[color=blue][color=green]
        > > layered architecture). They hardly mention that the code you write is to[/color]
        > be[color=green]
        > > used in a UI interface and committed to a database ([PoEAA] might be an
        > > exception). I find the separation of Business Login and UI to be the[/color]
        > hardest[color=green]
        > > thing. And also I find the performance issues when talking to the[/color][/color]
        Database[color=blue][color=green]
        > > to a very tricky thing, that calls for a few hack in the Domain Layer[/color][/color]
        (I'm[color=blue][color=green]
        > > almost only doing thick clients... that is no web).
        > >
        > > So I would like to know how you OO Guys really work (references to books[/color]
        > or[color=green]
        > > articles would be great).
        > >
        > > Don't you design your database the same way that you design you Business
        > > Model if you are responsible for all 3 layers/tiers?
        > >
        > > How much time does you spend on writing the DAL (the mapping between the[/color]
        > OO[color=green]
        > > and the Database)? Do you use any kind of O/R Mappers to help you write[/color]
        > the[color=green]
        > > DAL?
        > >
        > > Where do you place the tiers in a Smart Client configuration? The way I[/color]
        > see[color=green]
        > > it the UI and Domain Model must be on the client. Because you Domain[/color][/color]
        Model[color=blue][color=green]
        > > contains a lot of information e.g. about validation the input, and I[/color][/color]
        don't[color=blue][color=green]
        > > want a Server Round Trip every time the users enters something in a[/color]
        > textbox.[color=green]
        > > But I'm also thinking about putting the same domain objects on the[/color][/color]
        server[color=blue][color=green]
        > > aswell and use some kind of serialization using .NET Remoting or Web
        > > Services. Anyone else placing the Domain Model on both the Client and
        > > Server?
        > >
        > > Can you recommend any third party frameworks, which addresses any of[/color][/color]
        these[color=blue][color=green]
        > > problems? I find many of the MS Reference application to be to exotic.
        > >
        > > I know these are big questions for a thread in a newsgroup... but never[/color]
        > the[color=green]
        > > less, I haven't found any books or articles that really deals with these
        > > issues.
        > >
        > > Best regards,
        > > Thomas
        > > MCSD, MCSE+I, MCP+SB
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Jay B. Harlow [MVP - Outlook]

          #5
          Re: OOD/OOP and databases

          Thomas,
          I would recommend Joshua Kerievsky's book "Refactorin g to Patterns" by
          Addison-Wesley.

          In stead of a AddContactInfor mationAllowed property I would consider
          implementing some form of Self-Evaluating Rule. Where the domain object
          offers the UI a collection or composite of Self-Evaluating Rules that
          indicate to the UI what is or is not allowed. This allows the UI to easily
          validate against the domain object without the domain object raising
          exceptions. Also its allows the UI to be one step further decoupled from the
          domain. If I went the Self-Evaluating Rule approach I would consider making
          controls that are Self-Evaluating Rule aware...

          Self-Evaluating Rule are defined by David West in his book "Object Thinking"
          from MS Press.

          Hope this helps
          Jay

          "Thomas Jespersen" <tje@nospam.men tum.dk> wrote in message
          news:eTrwrSdmEH A.3520@TK2MSFTN GP11.phx.gbl...[color=blue]
          > Hello Nick
          >
          > Thanks for you input.
          >
          > First... Yes, you are right, I haven't read the GoF book yet. I thought I
          > start with something a bit lighter which Design Patterns Explained was (a
          > great introduction to OOD though). Is it readable for a .NET guy?
          >
          > Buschmann... never heard of him (embarrassed smiley here). I took a look
          > on
          > Amazon... can you recommend a specific book?
          >
          > I read a lot from the Microsoft Patterns & Practices group. I like the
          > Application Blocks, although I don't really see them as a design guide....
          > they are just... well Application Blocks.
          >
          > Regarding my problem about separating the Business and the UI. I agree
          > that
          > business rules is much more than validation. But I often find that all
          > kind
          > of rules are need in the UI. E.g. which menu items is shown, warnings and
          > other things to make sure that exceptions doesn't occurs when calling the
          > Domain Model. This might sound odd, but e.g. I might have a rule that I
          > can't call Customer.AddCon tactInformation , if the customer is inactive or
          > unsaved. So I'd make a Property on the Customer called
          > AddContactInfor mationAllowed. I use this property to decide whether a
          > certain menu option is available, and/or I call this before
          > AddContactInfor mation, to make sure that it doesn't throw an exception.
          >
          > For me this kind of interaction is a must to make a usable client
          > application (which is what's count in the end... at least for me), but I
          > don't se much of this kind in the OO books. But I will consider splitting
          > up
          > the Domain Model in two (on for validation like things, and one for hiding
          > business rules)... I'm just not quit sure that this is doable, if related
          > responsibilitie s is to be grouped on the same object.
          >
          > Thomas
          >
          > "Nick Malik" <nickmalik@hotm ail.nospam.com> wrote in message
          > news:7MG0d.4177 94$%_6.111013@a ttbi_s01...[color=green]
          >> Yes... that's a lot for a newsgroup.
          >>
          >> Start here:
          >> http://www.microsoft.com/resources/p...s/default.mspx
          >>
          >> I, too, have read many of the same books. You didn't mention the Design
          >> Patterns book itself (Gang of Four: Gamma, Helm, Johnson, and Vlissides)[/color]
          > but[color=green]
          >> it, too, is an excellent volume. There are also a number of patterns[/color]
          > books[color=green]
          >> that describe code in C# that have been coming out in the past two years.
          >>
          >> The books do not focus on a particular tier. The Design Patterns books,
          >> specifically, focus on a specific level of abstraction. The Fowler book
          >> focuses on a different level of abstraction. Buschmann takes on the
          >> architectural level. Honestly, to answer your questions, Buschmann is
          >> the
          >> best of the group.
          >>
          >> The Microsoft site has some very specific advice for the .NET platform[/color]
          > with[color=green]
          >> regards to optimizations.. . worth looking into.
          >>
          >> As for me: my middle tier is normally tailored to one thing: hiding the
          >> business rules. That requires real analysis: what are the business[/color]
          > rules...[color=green]
          >> what will change... how will they change... how will we maintain them.
          >>
          >> Config files are not good for business rule changes... they are too
          >> tactical. You can change the name of a stored proc in the config file.[/color]
          > To[color=green]
          >> change the business rules, you need to encapsulate logic, not just
          >> constants. Using pluggable components will only get you so far.
          >>
          >> So, if the business layer has very few business rules, it's really thin.
          >> For many purposes, especially for domain tables (lookup tables), I don't
          >> have any logic at all in the middle tier. In that case, I often simply[/color]
          > pass[color=green]
          >> the data through directly from the DAL to the UI layer as an array of
          >> DataRows. I'll even occasionally bind directly to a control (not often,[/color]
          > but[color=green]
          >> for drop-downs, it's good). On the other hand, if the business layer has
          >> business rules to encapsulate, then I will organize the objects so that
          >> managing those rules makes sense. This is where we start to deviate from
          >> "business objects that mirror the database". This is where the design
          >> patterns come in handy. You really have to map your data into objects[/color]
          > that[color=green]
          >> isolate change and minimize complexity.
          >>
          >> I've yet to find a tool or framework that does more than simply
          >> copy-and-reflect operations from the database through the middle tier. I
          >> don't use them. WHat a massive waste of time and processing power.[/color]
          > Heck...[color=green]
          >> the DataSet object does a better job than most of these, and it doesn't
          >> require a huge amount of effort to use! (I don't use it either... I'm[/color]
          > just[color=green]
          >> making a point).
          >>
          >> As for copying the validation rules: For a thick client app, I'd have the
          >> same validation dll on both the client and the server. That way, you can
          >> insure common rules. Note: business rules are much more than validation.
          >> I'd have basic validation types that I can use in both places, but the[/color]
          > rest[color=green]
          >> of the rules are quite different.
          >>
          >> As for use of remoting: depends on the kind and style of scalability you
          >> want to achieve. For my preference, remoting is too tightly coupled for[/color]
          > the[color=green]
          >> kinds of things that I do... I tend toward web services... but that may[/color]
          > not[color=green]
          >> be advice that you can use... depends on your app.
          >>
          >> I hope this info is helpful.
          >> --- Nick Malik
          >> Application Architect
          >> MCSD, CFPS, Certified Scrummaster
          >> "Thomas Jespersen" <tje@nospam.men tum.dk> wrote in message
          >> news:ecFEdt%23l EHA.2880@TK2MSF TNGP14.phx.gbl. ..[color=darkred]
          >> > Hello
          >> >
          >> > I've been reading a lot of great OOD/OOP books lately (e.g.. Martin[/color]
          >> Fowlers[color=darkred]
          >> > UML Distilled, Patterns of Enterprise Application Architecture,[/color]
          >> Refactoring,[color=darkred]
          >> > Kent Becks's Test Driven Development, and also a book called Design[/color]
          >> Patterns[color=darkred]
          >> > Explained.)... al of them with the focus on Java, because I think the[/color][/color]
          > best[color=green][color=darkred]
          >> > books are targeted Java. But the all fit very well to the .NET
          >> > platform.
          >> >
          >> > I have one big problem when reading these great books, and that is that[/color]
          >> they[color=darkred]
          >> > focus almost entirely on the Domain Model (that is the Middle Layer in
          >> > a[/color][/color]
          > 3[color=green][color=darkred]
          >> > layered architecture). They hardly mention that the code you write is
          >> > to[/color]
          >> be[color=darkred]
          >> > used in a UI interface and committed to a database ([PoEAA] might be an
          >> > exception). I find the separation of Business Login and UI to be the[/color]
          >> hardest[color=darkred]
          >> > thing. And also I find the performance issues when talking to the[/color][/color]
          > Database[color=green][color=darkred]
          >> > to a very tricky thing, that calls for a few hack in the Domain Layer[/color][/color]
          > (I'm[color=green][color=darkred]
          >> > almost only doing thick clients... that is no web).
          >> >
          >> > So I would like to know how you OO Guys really work (references to
          >> > books[/color]
          >> or[color=darkred]
          >> > articles would be great).
          >> >
          >> > Don't you design your database the same way that you design you
          >> > Business
          >> > Model if you are responsible for all 3 layers/tiers?
          >> >
          >> > How much time does you spend on writing the DAL (the mapping between
          >> > the[/color]
          >> OO[color=darkred]
          >> > and the Database)? Do you use any kind of O/R Mappers to help you write[/color]
          >> the[color=darkred]
          >> > DAL?
          >> >
          >> > Where do you place the tiers in a Smart Client configuration? The way I[/color]
          >> see[color=darkred]
          >> > it the UI and Domain Model must be on the client. Because you Domain[/color][/color]
          > Model[color=green][color=darkred]
          >> > contains a lot of information e.g. about validation the input, and I[/color][/color]
          > don't[color=green][color=darkred]
          >> > want a Server Round Trip every time the users enters something in a[/color]
          >> textbox.[color=darkred]
          >> > But I'm also thinking about putting the same domain objects on the[/color][/color]
          > server[color=green][color=darkred]
          >> > aswell and use some kind of serialization using .NET Remoting or Web
          >> > Services. Anyone else placing the Domain Model on both the Client and
          >> > Server?
          >> >
          >> > Can you recommend any third party frameworks, which addresses any of[/color][/color]
          > these[color=green][color=darkred]
          >> > problems? I find many of the MS Reference application to be to exotic.
          >> >
          >> > I know these are big questions for a thread in a newsgroup... but never[/color]
          >> the[color=darkred]
          >> > less, I haven't found any books or articles that really deals with
          >> > these
          >> > issues.
          >> >
          >> > Best regards,
          >> > Thomas
          >> > MCSD, MCSE+I, MCP+SB
          >> >
          >> >[/color]
          >>
          >>[/color]
          >
          >[/color]


          Comment

          • Nick Malik

            #6
            Re: OOD/OOP and databases

            Buschmann: Pattern Oriented Software Architecture


            Microsoft Patterns and Practices: discussion of the Layers pattern (Not an
            application block!)


            GoF is never easy. But it is much more comprehensive than the DP Explained
            book.

            Now: for the follow-up:
            If you view the interaction with the domain model as a series of messages,
            then it's not too difficult to seperate the View from the Model.

            In other words, you wouldn't need to warn the user that they cannot add
            contact information on the unsaved user record, since the act of adding
            contact information would necessarily trigger a request to send the user
            record to the domain model. Either that, or you don't prevent the user from
            adding contact info to an unsaved record. (Why NOT add contact info to an
            unsaved user? The most common reason I hear is when folks are using
            Identity columns as their primary keys in the Database... but that's easy to
            work around... use GUIDs. Since the app can generate a unique id, there is
            no need to create a transaction to write a record just to get the joining
            data value back. Just create the Guid, use it as the primary key in one
            message, and the foreign key in another. No problems and no need to
            round-trip one transaction before generating another).

            That goes back to my comment about creating a services interface between the
            front end and the domain model. It really forces you to decouple your
            system.

            Good luck and I hope this helps,

            --- Nick

            "Thomas Jespersen" <tje@nospam.men tum.dk> wrote in message
            news:eTrwrSdmEH A.3520@TK2MSFTN GP11.phx.gbl...[color=blue]
            > Hello Nick
            >
            > Thanks for you input.
            >
            > First... Yes, you are right, I haven't read the GoF book yet. I thought I
            > start with something a bit lighter which Design Patterns Explained was (a
            > great introduction to OOD though). Is it readable for a .NET guy?
            >
            > Buschmann... never heard of him (embarrassed smiley here). I took a look[/color]
            on[color=blue]
            > Amazon... can you recommend a specific book?
            >
            > I read a lot from the Microsoft Patterns & Practices group. I like the
            > Application Blocks, although I don't really see them as a design guide....
            > they are just... well Application Blocks.
            >
            > Regarding my problem about separating the Business and the UI. I agree[/color]
            that[color=blue]
            > business rules is much more than validation. But I often find that all[/color]
            kind[color=blue]
            > of rules are need in the UI. E.g. which menu items is shown, warnings and
            > other things to make sure that exceptions doesn't occurs when calling the
            > Domain Model. This might sound odd, but e.g. I might have a rule that I
            > can't call Customer.AddCon tactInformation , if the customer is inactive or
            > unsaved. So I'd make a Property on the Customer called
            > AddContactInfor mationAllowed. I use this property to decide whether a
            > certain menu option is available, and/or I call this before
            > AddContactInfor mation, to make sure that it doesn't throw an exception.
            >
            > For me this kind of interaction is a must to make a usable client
            > application (which is what's count in the end... at least for me), but I
            > don't se much of this kind in the OO books. But I will consider splitting[/color]
            up[color=blue]
            > the Domain Model in two (on for validation like things, and one for hiding
            > business rules)... I'm just not quit sure that this is doable, if related
            > responsibilitie s is to be grouped on the same object.
            >
            > Thomas
            >
            > "Nick Malik" <nickmalik@hotm ail.nospam.com> wrote in message
            > news:7MG0d.4177 94$%_6.111013@a ttbi_s01...[color=green]
            > > Yes... that's a lot for a newsgroup.
            > >
            > > Start here:
            > > http://www.microsoft.com/resources/p...s/default.mspx
            > >
            > > I, too, have read many of the same books. You didn't mention the Design
            > > Patterns book itself (Gang of Four: Gamma, Helm, Johnson, and Vlissides)[/color]
            > but[color=green]
            > > it, too, is an excellent volume. There are also a number of patterns[/color]
            > books[color=green]
            > > that describe code in C# that have been coming out in the past two[/color][/color]
            years.[color=blue][color=green]
            > >
            > > The books do not focus on a particular tier. The Design Patterns books,
            > > specifically, focus on a specific level of abstraction. The Fowler book
            > > focuses on a different level of abstraction. Buschmann takes on the
            > > architectural level. Honestly, to answer your questions, Buschmann is[/color][/color]
            the[color=blue][color=green]
            > > best of the group.
            > >
            > > The Microsoft site has some very specific advice for the .NET platform[/color]
            > with[color=green]
            > > regards to optimizations.. . worth looking into.
            > >
            > > As for me: my middle tier is normally tailored to one thing: hiding the
            > > business rules. That requires real analysis: what are the business[/color]
            > rules...[color=green]
            > > what will change... how will they change... how will we maintain them.
            > >
            > > Config files are not good for business rule changes... they are too
            > > tactical. You can change the name of a stored proc in the config file.[/color]
            > To[color=green]
            > > change the business rules, you need to encapsulate logic, not just
            > > constants. Using pluggable components will only get you so far.
            > >
            > > So, if the business layer has very few business rules, it's really thin.
            > > For many purposes, especially for domain tables (lookup tables), I don't
            > > have any logic at all in the middle tier. In that case, I often simply[/color]
            > pass[color=green]
            > > the data through directly from the DAL to the UI layer as an array of
            > > DataRows. I'll even occasionally bind directly to a control (not often,[/color]
            > but[color=green]
            > > for drop-downs, it's good). On the other hand, if the business layer[/color][/color]
            has[color=blue][color=green]
            > > business rules to encapsulate, then I will organize the objects so that
            > > managing those rules makes sense. This is where we start to deviate[/color][/color]
            from[color=blue][color=green]
            > > "business objects that mirror the database". This is where the design
            > > patterns come in handy. You really have to map your data into objects[/color]
            > that[color=green]
            > > isolate change and minimize complexity.
            > >
            > > I've yet to find a tool or framework that does more than simply
            > > copy-and-reflect operations from the database through the middle tier.[/color][/color]
            I[color=blue][color=green]
            > > don't use them. WHat a massive waste of time and processing power.[/color]
            > Heck...[color=green]
            > > the DataSet object does a better job than most of these, and it doesn't
            > > require a huge amount of effort to use! (I don't use it either... I'm[/color]
            > just[color=green]
            > > making a point).
            > >
            > > As for copying the validation rules: For a thick client app, I'd have[/color][/color]
            the[color=blue][color=green]
            > > same validation dll on both the client and the server. That way, you[/color][/color]
            can[color=blue][color=green]
            > > insure common rules. Note: business rules are much more than[/color][/color]
            validation.[color=blue][color=green]
            > > I'd have basic validation types that I can use in both places, but the[/color]
            > rest[color=green]
            > > of the rules are quite different.
            > >
            > > As for use of remoting: depends on the kind and style of scalability you
            > > want to achieve. For my preference, remoting is too tightly coupled for[/color]
            > the[color=green]
            > > kinds of things that I do... I tend toward web services... but that may[/color]
            > not[color=green]
            > > be advice that you can use... depends on your app.
            > >
            > > I hope this info is helpful.
            > > --- Nick Malik
            > > Application Architect
            > > MCSD, CFPS, Certified Scrummaster
            > > "Thomas Jespersen" <tje@nospam.men tum.dk> wrote in message
            > > news:ecFEdt%23l EHA.2880@TK2MSF TNGP14.phx.gbl. ..[color=darkred]
            > > > Hello
            > > >
            > > > I've been reading a lot of great OOD/OOP books lately (e.g.. Martin[/color]
            > > Fowlers[color=darkred]
            > > > UML Distilled, Patterns of Enterprise Application Architecture,[/color]
            > > Refactoring,[color=darkred]
            > > > Kent Becks's Test Driven Development, and also a book called Design[/color]
            > > Patterns[color=darkred]
            > > > Explained.)... al of them with the focus on Java, because I think the[/color][/color]
            > best[color=green][color=darkred]
            > > > books are targeted Java. But the all fit very well to the .NET[/color][/color][/color]
            platform.[color=blue][color=green][color=darkred]
            > > >
            > > > I have one big problem when reading these great books, and that is[/color][/color][/color]
            that[color=blue][color=green]
            > > they[color=darkred]
            > > > focus almost entirely on the Domain Model (that is the Middle Layer in[/color][/color][/color]
            a[color=blue]
            > 3[color=green][color=darkred]
            > > > layered architecture). They hardly mention that the code you write is[/color][/color][/color]
            to[color=blue][color=green]
            > > be[color=darkred]
            > > > used in a UI interface and committed to a database ([PoEAA] might be[/color][/color][/color]
            an[color=blue][color=green][color=darkred]
            > > > exception). I find the separation of Business Login and UI to be the[/color]
            > > hardest[color=darkred]
            > > > thing. And also I find the performance issues when talking to the[/color][/color]
            > Database[color=green][color=darkred]
            > > > to a very tricky thing, that calls for a few hack in the Domain Layer[/color][/color]
            > (I'm[color=green][color=darkred]
            > > > almost only doing thick clients... that is no web).
            > > >
            > > > So I would like to know how you OO Guys really work (references to[/color][/color][/color]
            books[color=blue][color=green]
            > > or[color=darkred]
            > > > articles would be great).
            > > >
            > > > Don't you design your database the same way that you design you[/color][/color][/color]
            Business[color=blue][color=green][color=darkred]
            > > > Model if you are responsible for all 3 layers/tiers?
            > > >
            > > > How much time does you spend on writing the DAL (the mapping between[/color][/color][/color]
            the[color=blue][color=green]
            > > OO[color=darkred]
            > > > and the Database)? Do you use any kind of O/R Mappers to help you[/color][/color][/color]
            write[color=blue][color=green]
            > > the[color=darkred]
            > > > DAL?
            > > >
            > > > Where do you place the tiers in a Smart Client configuration? The way[/color][/color][/color]
            I[color=blue][color=green]
            > > see[color=darkred]
            > > > it the UI and Domain Model must be on the client. Because you Domain[/color][/color]
            > Model[color=green][color=darkred]
            > > > contains a lot of information e.g. about validation the input, and I[/color][/color]
            > don't[color=green][color=darkred]
            > > > want a Server Round Trip every time the users enters something in a[/color]
            > > textbox.[color=darkred]
            > > > But I'm also thinking about putting the same domain objects on the[/color][/color]
            > server[color=green][color=darkred]
            > > > aswell and use some kind of serialization using .NET Remoting or Web
            > > > Services. Anyone else placing the Domain Model on both the Client and
            > > > Server?
            > > >
            > > > Can you recommend any third party frameworks, which addresses any of[/color][/color]
            > these[color=green][color=darkred]
            > > > problems? I find many of the MS Reference application to be to exotic.
            > > >
            > > > I know these are big questions for a thread in a newsgroup... but[/color][/color][/color]
            never[color=blue][color=green]
            > > the[color=darkred]
            > > > less, I haven't found any books or articles that really deals with[/color][/color][/color]
            these[color=blue][color=green][color=darkred]
            > > > issues.
            > > >
            > > > Best regards,
            > > > Thomas
            > > > MCSD, MCSE+I, MCP+SB
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            Working...