## DDD & composition

I have a project to build, which has the following requirements:

• topup a wallet by paying money in exchange for credit; this has also the constraint of needing an approval from the finance team, if the payment used is bank transfer. The finance team will then (in the future) issue invoices.
• transfer credit from one wallet to another; requires no approvals or payments.
• refund credit transferred to another wallet; this also requires approving from the finance team.

Wallets and Users logic live in separate services, so the above will only have to deal with moving credit around.

Trying to model this following a DDD approach, I came up with 2 possible solutions:

• use composition and build a transaction class with interfaces such as Approvable, Payable, etc. Transaction will then become the Aggregate Root and encapsulate approvals within it. I like this approach, however I feel approvals may need to live in its own bounded context.
• create more fine grained Aggregate Roots (Topup, Transfer, Refund, Approval) and have Approval live in its own bounded context. This means using composition on Approvals by having the AR satisfy an interface (Approve(), Reject()). The problem with this is cyclic dependencies and more complex application services.

I thought of a 3rd option, which is using events. However I feel this approach would be very close to option 2 and has another layer of complexity to take in consideration.

I understand this question may sound opinion-based and requires some insights in the domain knowledge, but I’m asking if there’s any other approach that could be a better design or which, out of the 3 above, would be the best choice?

## composition rule in category theory

I just started with learning category theory and one of rule to be qualified as category is Composition according to which if there is morphism/arrow :

A->B and B->C and there should be arrow from object A to C i.e A->C must exist.

I have a very basic question: Is there any situation where above rule cannot be met in first place ? Probably some example would be helpful.

## derivative of scalar function with composition of vector function

Suppose I have a scalar function $$f(u(w(v_k))$$, where

$$u=[u_1(w(v_k)),u_2(w(v_k))]$$

w is a another scalar function, and $$v_k$$ is the independent variable. If I was interested in calculating $$\frac{df}{dv_k}$$, I would think that the derivative would be

$$\frac{df}{dv_k} = \frac{\partial f}{ \partial u} \frac{\partial u }{ \partial w} \frac{\partial w}{ \partial v_k}$$.

The two first terms seem to me to be two vectors, and the last is a scalar. I believe somehow the first two terms are an inner product somehow (I’m missing a transpose)?

Can Someone give me some insight on this?

## Inheritance or composition for a more advanced implementation of a class?

So i have a class called VirtualMouse, it is used to perform mouse actions such as moving and clicking.

public class VirtualMouse {     public VirtualMouse()     {      }      public void MoveByOffset(int offsetX, int offsetY)     {        // Implementation.     }      public void MoveToPosition(Point position)     {         // Implementation.     }      public void ClickLeftButton()     {        // Implementation.     }      public void PressLeftButton()     {         // Implementation.     }      public void ReleaseLeftButton()     {         // Implementation.     } } 

This is to implement basic mouse automation. Now I also wanna have the ability to create a class that is specialized, for example a HumanVirtualMouse which would have the same methods but would move the mouse in a human like way.

Should I inherit from VirtualMouse and call the base class methods in succession to create human patterns(for example I can use MoveByOffset inside a loop) or have an instance of VirtualMouse inside the HumanMouse class?

I guess i should favor inheritance because HumanMouse is-a VirtualMouse and i only need to modify the movement methods, click, press and release remain the same…

## An example of Aggregation and Composition [on hold]

Consider the following :

• For some Course, students are members of teams
• A Team must compete zero to three assignments
• And Finally, every Student should complete a single Midterm test

So, Is there any aggregation or composition relationship between the student and the midterm classes?

## Usage of composition relationship between two class in UML

I’m having quite a difficulty with what i think would suit a Patient class and a Record class in UML

Basically the Record class stores the patient’s information such as name, vitals, gender, age and etc.

However, when linking these two classes together, I’m very much confused as to which relationship would be suitable for these.

Currently, I’m creating a composite relationship between the two,

Based on the way i interpret it, a patient record wouldn’t exist without it’s patient. However, in most examples i researched online, composition relationship is represented in an example as such:

I’m starting to wonder, would my interpretation of Patient and Record having a composite relationship is acceptable?

## Interpretation of composition operator when applying a function to the output of another function

Refreshing my calculus skills a bit, I reviewed the chain rule:

I wondered if the composition operation $$\circ$$ in $$g \circ f(x)$$ could actually also be written as $$g(f(x))$$ as this would resemble how one might think about such an operation from a (functional) programming perspective.

## Disclaimer

My background is in Software Engineering combined with Applied Statistical Analysis within the context of a degree in Business Administration – so unfortunately never had heavy formal training on theoretical Math. Thus apologies if I might sometimes not use the correct technical terms and/or express things a bit “unmathy”.

## Composition vs Prefix @

Whats the difference between Composition @* and prefix @?

Composition[f,g,h][x] f@g@h[x]

Functionally they both seem to give the same result.

## Non-normal numbers definable without parameters in the langauge of differential rings with composition

Background: It is currently unknown whether $$e$$ is normal. A natural way to approach this question is to find a class to which $$e$$ belongs, and prove all members of that class are normal. For example, if we want to know whether $$\sqrt{2}$$ is normal, it makes sense to consider the class of irrational algebraic numbers, but it is still an open problem whether every irrational algebraic number is normal. Finding a counter-example to this conjecture, or a similar conjecture for an appropriate class containing $$e$$, would be quite useful to understanding the problem in general.

Differential Rings with Composition: One natural class containing $$e$$ seems to be numbers definable without parameters in the language of differential rings with composition, say in the space of analytic functions on $$\mathbb{C}$$. The language of differential rings with composition is $$(0,1,+,*,\partial,\circ)$$, where $$0$$, $$1$$ are the additive and multiplicative identities (constant functions), $$+$$ and $$*$$ are addition and multiplication, $$\partial$$ is a derivation (in this case differentiation), and $$\circ$$ is composition. We can define the constant function $$e$$ in this language by the formula $$\psi(x) : (\partial f = f) \wedge (f \circ 0 = 1) \wedge (f \circ 1 = x)$$

Question: Is there a non-normal irrational number definable without parameters in the ring of analytic functions on $$\mathbb{C}$$ in the language of differential rings with composition?

This is a larger class of numbers than algebraic numbers, so in principle it should be an easier question to answer in the positive than the corresponding question of whether there is a non-normal irrational algbraic number, but I expect this is also quite a hard question, so answers slightly modifying the question would also be welcome. For example, perhaps it helps to generalize to algebraic elements in this differential ring with composition, rather than just definable elements, or to work in a different differential ring into which $$\mathbb{R}$$ embeds.

## Is composition after capture against any traditional photography rules?

I use my mobile phone for photography. Normally when I notice anything interesting, I take a picture with the point of interest somewhere near the region I want it to be. But I do this with the clear assumption that the final composition after I edit it using Snapseed might be completely different. I do this because I feel that I get a greater level of freedom and convenience when I compose offline, when I am sitting somewhere comfortably.

My question is whether this is a common practice among photographers? Or maybe traditional photographers do the composition when they capture?

More specifically, is offline composing considered as cheating or something?

Example of my offline composition

ORIGINAL FINAL

It wasn’t me who added the “ethics” tag. And honestly I wasn’t thinking of ethics when I used the word cheating. What I meant is taking shortcuts. Technology has made it very easy to take good pictures. A better phrasing of the question would be whether offline composition is frowned upon by traditional photographers?

I take photos as an outlet of my creativity. I don’t intend to make money with it or use it for promoting anything. I just upload it to 500px.

I don’t go to places to take photos. I take pictures of interesting stuff I find in places that life takes me. Being an introvert, I am not comfortable carrying a big camera and tripod etc in crowded places and attracting attention. So I prefer a phone with good camera specs(LG G6) now. And I prefer taking pictures fast and not sticking around. That’s why I prefer to compose later. Of course I do minimum composition when I capture.

Even though I got the answers I need, I am finding it very hard to select the most appropriate answer here. Should I wait for a few days and select the answer with the highest votes?