You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by da...@apache.org on 2023/06/18 17:13:01 UTC

[causeway] 08/12: CAUSEWAY-3395: reworking user guide

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/causeway.git

commit 17246ed54c2c8f218ff74152940d7ed22a90209d
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Sun Jun 18 16:17:39 2023 +0100

    CAUSEWAY-3395: reworking user guide
---
 .../userguide/modules/ROOT/pages/about.adoc        |  7 +++--
 .../modules/ROOT/pages/business-rules.adoc         | 21 +------------
 .../userguide/modules/ROOT/pages/events.adoc       |  7 +++++
 .../userguide/modules/ROOT/pages/overview.adoc     | 16 +++++++++-
 .../userguide/modules/ROOT/pages/ui.adoc           |  4 +--
 .../_intro.adoc}                                   | 34 +++++-----------------
 .../partials/domain-services/introduction.adoc     | 26 +++--------------
 .../modules/ROOT/partials/overview/events.adoc     |  5 ++--
 8 files changed, 43 insertions(+), 77 deletions(-)

diff --git a/antora/components/userguide/modules/ROOT/pages/about.adoc b/antora/components/userguide/modules/ROOT/pages/about.adoc
index 128d609308..e2895827b6 100644
--- a/antora/components/userguide/modules/ROOT/pages/about.adoc
+++ b/antora/components/userguide/modules/ROOT/pages/about.adoc
@@ -57,17 +57,18 @@ Sometimes a view model is a projection of some an underlying entity/ies for a pa
 Both domain entities and view models are built from values.
 The framework does (of course) have built-in support for primitives, strings, dates and so on.
 But it also allows you to define your own custom value types, either scalar or composite.
-http://localhost:5000
+
 +
 Meta-annotations provide an alternative way to factor out common rules, also extending the vocabulary (ubiquitous language) into your app.
 
-* xref:userguide:ROOT:modules.adoc[Modules] and xref:userguide:ROOT:mixins.adoc[Mixins]
+* xref:userguide:ROOT:modules.adoc[Modules], xref:userguide:ROOT:mixins.adoc[Mixins] and xref:userguide:ROOT:events.adoc[Events]
 +
 Causeway emphasises rapid development and a fast feedback loop with your domain expert.
 Modularity is key to preserving that feedback loop as your application's capability grows.
 +
 Mixins provide a powerful mechanism to decouple the various concerns within your application, allowing even the largest of monolith applications to keep modular.
-
++
+Events are broadcast on an intra-process event bus, allowing subscribers in other modules to influence the domain logic being executed, hook into persistence or to refine the UI.
 
 The first part of the user guide ends with a look at the xref:userguide:ROOT:background-context-and-theory.adoc[background, context and theory] that underpin the framework: domain driven design, the naked objects pattern, the hexagonal architecture and aspect orientation to name a few.
 
diff --git a/antora/components/userguide/modules/ROOT/pages/business-rules.adoc b/antora/components/userguide/modules/ROOT/pages/business-rules.adoc
index a189ed0ab8..86a7b939d9 100644
--- a/antora/components/userguide/modules/ROOT/pages/business-rules.adoc
+++ b/antora/components/userguide/modules/ROOT/pages/business-rules.adoc
@@ -4,27 +4,8 @@
 :page-partial:
 
 
-As explained xref:overview.adoc#business-rules[in the overview], when a domain object is rendered in the UI or the end-user interacts with the domain object through the UI, the framework applies a series of precondition business rules to each object member.
-These can be summarised as *"see it, use it, do it"*.
-
-.See it, use it, do it
-****
-
-* is the object member visible?
-
-* if so, is the object member enabled?
-
-* if so, are the supplied values valid? (can the user "do" it)?
-****
-
-The framework provides a multitude of ways to implement these business rules.
-
-The simplest mechanism is to just implement the business rules imperatively in the domain object, or in a xref:mixins.adoc[mixin] for the object.
-
-A more sophisticated approach, useful for decoupling functionality, is using xref:userguide:ROOT:overview.adoc#domain-events[domain events].
-The domain event is emitted multiple times, for the various types of precondition checks (and if not vetoed, they are also emitted on the execution of the action itself).
-
 
+include::partial$business-rules/_intro.adoc[leveloffset=+1]
 include::partial$business-rules/visibility.adoc[leveloffset=+1]
 include::partial$business-rules/usability.adoc[leveloffset=+1]
 include::partial$business-rules/validity.adoc[leveloffset=+1]
diff --git a/antora/components/userguide/modules/ROOT/pages/events.adoc b/antora/components/userguide/modules/ROOT/pages/events.adoc
new file mode 100644
index 0000000000..833d7bf01c
--- /dev/null
+++ b/antora/components/userguide/modules/ROOT/pages/events.adoc
@@ -0,0 +1,7 @@
+[#events]
+= Events
+
+:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or ag [...]
+:page-partial:
+
+
diff --git a/antora/components/userguide/modules/ROOT/pages/overview.adoc b/antora/components/userguide/modules/ROOT/pages/overview.adoc
index e43fb3fc5f..2b067aa6aa 100644
--- a/antora/components/userguide/modules/ROOT/pages/overview.adoc
+++ b/antora/components/userguide/modules/ROOT/pages/overview.adoc
@@ -48,8 +48,22 @@ Every domain object in Apache Causeway consists of three types of members:
 In addition, xref:mixins.adoc[mixins] can contribute both actions (ie behaviour) and derived (read-only) state to an underlying domain object.
 
 
+== Business Rules
+
+When a domain object is rendered in the UI or the end-user interacts with the domain object through the UI, the framework applies a series of precondition business rules to each object member (property, collection or action).
+
+When the object is being rendered, the framework checks:
+
+* is the object member visible? - Members that are not visible are simply omitted from the page.
+* if the object member is visible, is the object member enabled (or is it not editable/greyed out)?
+* for enabled object members, are the supplied arguments valid?
+
+One way to remember this is: *"see it, use it, do it"*.
+
+The framework provides a multitude of ways to implement these business rules.
+The simplest approach is to just implement the business rules imperatively in the domain object, using a supporting method.
+
 
-include::partial$overview/business-rules.adoc[leveloffset=+1]
 include::partial$overview/events.adoc[leveloffset=+1]
 include::partial$overview/modules.adoc[leveloffset=+1]
 include::partial$overview/programming-model.adoc[leveloffset=+1]
diff --git a/antora/components/userguide/modules/ROOT/pages/ui.adoc b/antora/components/userguide/modules/ROOT/pages/ui.adoc
index 7ebca4c9af..53a7afb626 100644
--- a/antora/components/userguide/modules/ROOT/pages/ui.adoc
+++ b/antora/components/userguide/modules/ROOT/pages/ui.adoc
@@ -10,9 +10,9 @@ Nevertheless, some metadata relating solely to the UI is inevitably required.
 
 The Apache Causeway programming model includes several mechanisms to influence the way in which the domain objects are rendered in the UI.
 
-* the layout of application menu items (inferred from xref:domain-services.adoc#domain-services[domain services])
+* the layout of application menu items (inferred from xref:domain-services.adoc[domain services])
 
-* the layout of domain objects (xref:domain-services.adoc#domain-entities[domain entities] and xref:view-models.adoc[view models]) allow the positioning of the xref:object-members.adoc[object members] into columns and tabs
+* the layout of domain objects (xref:domain-entities.adoc[domain entities] and xref:view-models.adoc[view models]) allow the positioning of the xref:object-members.adoc[object members] into columns and tabs
 
 * UI hints provided by the domain object itself returning:
 
diff --git a/antora/components/userguide/modules/ROOT/partials/overview/business-rules.adoc b/antora/components/userguide/modules/ROOT/partials/business-rules/_intro.adoc
similarity index 70%
rename from antora/components/userguide/modules/ROOT/partials/overview/business-rules.adoc
rename to antora/components/userguide/modules/ROOT/partials/business-rules/_intro.adoc
index a80ff5e042..e787af395c 100644
--- a/antora/components/userguide/modules/ROOT/partials/overview/business-rules.adoc
+++ b/antora/components/userguide/modules/ROOT/partials/business-rules/_intro.adoc
@@ -1,13 +1,10 @@
-[#business-rules]
-= Business Rules
+[[introduction]]
+= Introduction
 
 :Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or ag [...]
 :page-partial:
 
-
-When a domain object is rendered in the UI or the end-user interacts with the domain object through the UI, the framework applies a series of precondition business rules to each object member (property, collection or action).
-
-When the object is being rendered, the framework checks:
+When a domain object is rendered in the UI or the end-user interacts with the domain object through the UI, the framework applies a series of precondition business rules to each object member.
 
 * is the object member visible?
 +
@@ -26,8 +23,8 @@ Note that collections are always read-only.
 For an editable property this means validating the proposed new value of the property.
 For an invokable action this means validating that arguments being used to invoke the action.
 
+These can be summarised as *"see it, use it, do it"*.
 
-One way to remember this is: *"see it, use it, do it"*
 
 .See it, use it, do it
 ****
@@ -39,26 +36,9 @@ One way to remember this is: *"see it, use it, do it"*
 * if so, are the supplied values valid? (can the user "do" it)?
 ****
 
-
 The framework provides a multitude of ways to implement these business rules.
-The simplest approach is to just implement the business rules imperatively in the domain object, using a supporting method.
-
-For example,
-
-[source,java]
-----
-public Customer placeOrder(Product p, int quantity) {
-    // ...
-}
-public boolean hidePlaceOrder() {                       // <.>
-    return isBlacklisted();
-}
-----
-<.> supporting method, invoked before rendering the customer.
 
-In this example the "place order" action would not be visible for any customer that had been blacklisted.
+The simplest mechanism is to just implement the business rules imperatively in the domain object, or in a xref:mixins.adoc[mixin] for the object.
 
-[TIP]
-====
-Details on how to actually write business rules (the programming model) can be found xref:userguide:ROOT:business-rules.adoc[here].
-====
+A more sophisticated approach, useful for decoupling functionality, is using xref:userguide:ROOT:overview.adoc#domain-events[domain events].
+The domain event is emitted multiple times, for the various types of precondition checks (and if not vetoed, they are also emitted on the execution of the action itself).
diff --git a/antora/components/userguide/modules/ROOT/partials/domain-services/introduction.adoc b/antora/components/userguide/modules/ROOT/partials/domain-services/introduction.adoc
index 019aea3971..eff5a87226 100644
--- a/antora/components/userguide/modules/ROOT/partials/domain-services/introduction.adoc
+++ b/antora/components/userguide/modules/ROOT/partials/domain-services/introduction.adoc
@@ -38,36 +38,18 @@ Said another way: it is the means by which Apache Causeway helps you avoid the a
 
 Domain services are instantiated once and once only by the framework, and are used to centralize any domain logic that does not logically belong in a domain entity or value.
 
-[TIP]
-====
-Details on how to actually write a domain service (the programming model for domain services) is
-xref:userguide:ROOT:domain-services.adoc#domain-services[here].
-====
-
-=== Hexagonal Architecture
-
-It's worth extending the xref:userguide:ROOT:background-context-and-theory.adoc#hexagonal-architecture[Hexagonal Architecture] to show where domain services fit in:
-
-.The hexagonal architecture with API and SPI implementations
-image::core-concepts/philosophy/hexagonal-architecture-addons.png[width="700px"]
 
-The xref:extensions:ROOT:about.adoc[extensions] catalog provide SPI implementations of the common cross-cutting concerns.
-You can also write your own domain services as well, for example to interface with some external CMS system, say.
+== Programming Model
 
-
-_Domain services_ are (usually) singleton stateless services that provide additional functionality.
-This may be exposed in the UI, or might be invoked programmatically.
-
-However, a service cannot have (persisted) properties, nor can it have (persisted) collections.
+=== Declaring a Domain Service
 
 Domain services that are visible in the UI or REST API are annotated with xref:refguide:applib:index/annotation/DomainService.adoc[@DomainService()], while services that are _programmatic_ in nature should be simply annotated using Spring's link:https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/stereotype/Component.html[@Component] or one of its specializations, eg
 link:https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/stereotype/Service.html[@Service]
 or link:https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/stereotype/Repository.html[@Repository].
 
 Apache Causeway runs on top of Spring Boot, and relies on Spring Boot for dependency injection using `@javax.inject.Inject`.
-The `@javax.annotation.Priority` annotation is used to prioritize multiple service implementations, effectively allowing any framework-provided domain service to be substituted out by a user-defined one encountered with an earlier precedence (= higher priority) if required.
-
-This section looks at the programming model for writing your own domain services.
+The `@javax.annotation.Priority` annotation is used to prioritize multiple service implementations.
+*This allows any framework-provided domain service to be replaced by a user-defined one if required*, simply by assigning it with an earlier precedence (= higher priority).
 
 
 === Nature of Service
diff --git a/antora/components/userguide/modules/ROOT/partials/overview/events.adoc b/antora/components/userguide/modules/ROOT/partials/overview/events.adoc
index 2981ba7d5c..9f2095642f 100644
--- a/antora/components/userguide/modules/ROOT/partials/overview/events.adoc
+++ b/antora/components/userguide/modules/ROOT/partials/overview/events.adoc
@@ -8,11 +8,12 @@
 When the framework renders a domain object, and as the end-user interacts with the domain object, the framework it emits multiple events using the intra-process xref:refguide:applib:index/services/eventbus/EventBusService.adoc[event bus].
 These events enable other domain services (possibly in other modules) to influence how the domain object is rendered, or to perform side-effects or even veto an action invocation.
 
-To receive the events, the domain service should subscribe to the xref:refguide:applib:index/services/eventbus/EventBusService.adoc[EventBusService], and implement an appropriately annotated method to receive the events.
-
 The framework has several categories of events: domain events, UI events and lifecycle events.
 These are explored in the sections below.
 
+To receive the events, the domain service should subscribe to the xref:refguide:applib:index/services/eventbus/EventBusService.adoc[EventBusService], and implement an appropriately annotated method to receive the events.
+
+
 [#domain-events]
 == Domain Events