Re: Cayenne design Patterns
Got it. So here are my thoughts on this, none are particularly Cayenne-specific... Many years ago when I started working as a programmer, I borrowed the domain-centric style from the colleagues I was working with at that time. All the data access code was placed in domain objects. This code was a mix of static and instance methods. This was a very domain-oriented API and it made a lot of sense. Not for long though. In bigger systems, when a single model object is reused in many different contexts, a few serious issues emerged: * You can't override a static method to behave differently in a different context. * You can't inject dependencies in a DataObject or a static method. Your choices are passing the dependencies as method parameters (gets unwieldy quickly), or resolve dependencies inside the method itself (which makes your code extremely inflexible, often impossible to test). This realization coincided with the advent of dependency injection technology, and DAOs (or more generally - services) suddenly started to make sense. With DI-managed services you can write a few common interfaces and tweak the implementation according to your needs in a specific context. The most common special context is a unit test environment. And suddenly all your code is testable in isolation, cause you can mock the dependencies. But history is a spiral that keeps returning to where it's been before, though at a slightly different level :) . Watching the evolution of service-heavy architectures with anemic models, I saw them hitting the ceiling of complexity. This is a much higher ceiling, but never the less. The solution that I am seeing to that is avoiding a master model, and instead allow some model duplication between multiple contexts. In simpler terms, if your model scope is small enough, you don't need to override a static method. And now you can maintain a proper ratio of logic between domain objects and services. BTW, LinkETL tool discussed in the parallel thread came from that concept of smaller models. The idea was to have smaller more targeted database schemas as opposed to one huge DB that serves a bunch of unrelated apps within the same enterprise. To summarize, both domain-centric and service-centric architectures have their advantages and downsides. In an ideal world there should be just the right mix of the two. Achieving that can be hard sometimes, and the actual proportion depends on the scope of the system and the tools that you have in your possession. Andrus On Jun 8, 2015, at 7:39 PM, Tony Giaccone anthony.giacc...@nytimes.com wrote: Andrus, My point was not so much to generate examples or pointers to examples but more to talk about the way people are using Cayenne and some thoughts about the relative advantages of each design pattern. Tony On 6/8/15 10:52 AM, Andrus Adamchik wrote: Here is a very simple example of DAO-like service oriented architecture with Cayenne: https://github.com/andrus/wowodc13 Andrus On Jun 8, 2015, at 4:57 PM, Mike Kienenberger mkien...@gmail.com wrote: I tend to use a DAO pattern in projects where I want all cayenne references isolated to a specific package. I use the template generator to create 90%of the code and keep it up to date On Mon, Jun 8, 2015 at 9:48 AM, Gmail tgiacc...@gmail.com wrote: I'm wondering how people on this mailing BG list structure their Cayenne projects. The two most common design patterns I have seen are DAO style where the code that implements access is in its own class and Active record style where the Domain object implements the data access layer. Are most folks here using one of these two patterns or something else all together? Tony Giaccone
Re: Cayenne design Patterns
On 12/06/2015 6:01pm, Andrus Adamchik wrote: To summarize, both domain-centric and service-centric architectures have their advantages and downsides. In an ideal world there should be just the right mix of the two. Achieving that can be hard sometimes, and the actual proportion depends on the scope of the system and the tools that you have in your possession. I'm really liking Groovy these days. It has a concept of categories which allow you to inject additional methods right into your domain objects. http://docs.groovy-lang.org/latest/html/gapi/groovy/lang/Category.html I'm still getting my head around how that changes the architecture of systems, but the ease of mixing groovy inside Java applications is allowing us to explore aspects of this right now. For example, to enhance Cayenne objects when passing them into JasperReports for printing. If Dima is lurking around here, he'll have more to say since I know he is liking the groovy approach. Cheers Ari -- -- Aristedes Maniatis GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
Re: Cayenne design Patterns
Yep, this is exactly what I had in mind when talking how the available tools drive your design decisions. An ability to add something to the object in a given context can be a game changer. It was there in Objective C, but is not present in the vanilla Java. Andrus On Jun 12, 2015, at 12:14 PM, Aristedes Maniatis a...@maniatis.org wrote: On 12/06/2015 6:01pm, Andrus Adamchik wrote: To summarize, both domain-centric and service-centric architectures have their advantages and downsides. In an ideal world there should be just the right mix of the two. Achieving that can be hard sometimes, and the actual proportion depends on the scope of the system and the tools that you have in your possession. I'm really liking Groovy these days. It has a concept of categories which allow you to inject additional methods right into your domain objects. http://docs.groovy-lang.org/latest/html/gapi/groovy/lang/Category.html I'm still getting my head around how that changes the architecture of systems, but the ease of mixing groovy inside Java applications is allowing us to explore aspects of this right now. For example, to enhance Cayenne objects when passing them into JasperReports for printing. If Dima is lurking around here, he'll have more to say since I know he is liking the groovy approach. Cheers Ari -- -- Aristedes Maniatis GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
Re: Cayenne design Patterns
So in the paradigm of everything old is new again here come categories. Which are a carry over from Smalltalk and I am amazed at how right the guys who designed and implemented Smalltalk were and how much they deeply understood software design. Tony Giaccone On Jun 12, 2015, at 5:14 AM, Aristedes Maniatis a...@maniatis.org wrote: On 12/06/2015 6:01pm, Andrus Adamchik wrote: To summarize, both domain-centric and service-centric architectures have their advantages and downsides. In an ideal world there should be just the right mix of the two. Achieving that can be hard sometimes, and the actual proportion depends on the scope of the system and the tools that you have in your possession. I'm really liking Groovy these days. It has a concept of categories which allow you to inject additional methods right into your domain objects. http://docs.groovy-lang.org/latest/html/gapi/groovy/lang/Category.html I'm still getting my head around how that changes the architecture of systems, but the ease of mixing groovy inside Java applications is allowing us to explore aspects of this right now. For example, to enhance Cayenne objects when passing them into JasperReports for printing. If Dima is lurking around here, he'll have more to say since I know he is liking the groovy approach. Cheers Ari -- -- Aristedes Maniatis GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
Re: Cayenne design Patterns
I tend to use a DAO pattern in projects where I want all cayenne references isolated to a specific package. I use the template generator to create 90%of the code and keep it up to date On Mon, Jun 8, 2015 at 9:48 AM, Gmail tgiacc...@gmail.com wrote: I'm wondering how people on this mailing BG list structure their Cayenne projects. The two most common design patterns I have seen are DAO style where the code that implements access is in its own class and Active record style where the Domain object implements the data access layer. Are most folks here using one of these two patterns or something else all together? Tony Giaccone
Cayenne design Patterns
I'm wondering how people on this mailing BG list structure their Cayenne projects. The two most common design patterns I have seen are DAO style where the code that implements access is in its own class and Active record style where the Domain object implements the data access layer. Are most folks here using one of these two patterns or something else all together? Tony Giaccone
Re: Cayenne design Patterns
Here is a very simple example of DAO-like service oriented architecture with Cayenne: https://github.com/andrus/wowodc13 Andrus On Jun 8, 2015, at 4:57 PM, Mike Kienenberger mkien...@gmail.com wrote: I tend to use a DAO pattern in projects where I want all cayenne references isolated to a specific package. I use the template generator to create 90%of the code and keep it up to date On Mon, Jun 8, 2015 at 9:48 AM, Gmail tgiacc...@gmail.com wrote: I'm wondering how people on this mailing BG list structure their Cayenne projects. The two most common design patterns I have seen are DAO style where the code that implements access is in its own class and Active record style where the Domain object implements the data access layer. Are most folks here using one of these two patterns or something else all together? Tony Giaccone
Re: Cayenne design Patterns
Andrus, My point was not so much to generate examples or pointers to examples but more to talk about the way people are using Cayenne and some thoughts about the relative advantages of each design pattern. Tony On 6/8/15 10:52 AM, Andrus Adamchik wrote: Here is a very simple example of DAO-like service oriented architecture with Cayenne: https://github.com/andrus/wowodc13 Andrus On Jun 8, 2015, at 4:57 PM, Mike Kienenberger mkien...@gmail.com wrote: I tend to use a DAO pattern in projects where I want all cayenne references isolated to a specific package. I use the template generator to create 90%of the code and keep it up to date On Mon, Jun 8, 2015 at 9:48 AM, Gmail tgiacc...@gmail.com wrote: I'm wondering how people on this mailing BG list structure their Cayenne projects. The two most common design patterns I have seen are DAO style where the code that implements access is in its own class and Active record style where the Domain object implements the data access layer. Are most folks here using one of these two patterns or something else all together? Tony Giaccone