Hey, In Qi4j today we think of an Application as a set of Layers, each stacked on top of each other. We call the top one "UI" and the bottom "Infrastructure", typically. But this has always seemed wrong to me, as it is not so much that "Infrastructure" is in the "bottom", but more like the domain is in the MIDDLE, with UI being input and infrastructure being output. Thus, if "infrastructure" is considered OUTPUT, there is nothing wrong with putting Swing components in it, which could be used by the domain to perform norifications or somesuch. It is simply one thing that the domain uses to output stuff, as is the database.
This pattern has been recognized as "Hexagonal architecture" by Alistair Cockburn, and has been described here: http://alistair.cockburn.us/Hexagonal+architecture The more I think about it, the more correct it seems to me, and it would dramatically simplify testing of the domain model also. Basically both inputs (UI, http, tests) AND outputs (database, email, http, UI) could be mocked, and the whole thing run in a "headless mode". There is nothing inherently that disallows Qi4j from running like this, but there is one catch: the "UI" layer, the "top" one in a traditional architecture, can be used by the domain layer! Something like this: uiLayer.uses(applicationLayer); applicationLayer.uses(domainLayer); domainLayer.uses(databaseLayer); domainLayer.uses(uiLayer); so that there is a circular graph rather than a directed graph. This would allow an input from the UI to trigger domain rules, which would trigger the UI, which could trigger domain rules, etc. etc. in a loop. The visibility rules would still apply, so the domain layer can still only see what the UI, as "provider", makes explicitly available. The bulk of the UI is as hidden to the domain as the bulk of the domain is hidden from the UI. In a testing situation you would do: testCaseLayer.uses(applicationLayer); applicationLayer.uses(domainLayer); domainLayer.uses(mockDataLayer); domainLayer.uses(mockUiLayer); The domain is the same, but what comes in and where things are sent out varies. This is similar to the SCA architecture, where you have components with "inputs" and "outputs", but not really any "layering" to speak of. Interesting stuff! /Rickard _______________________________________________ qi4j-dev mailing list [email protected] http://lists.ops4j.org/mailman/listinfo/qi4j-dev

