In a DDD CQRS API, is it preferable to have a separate DTO per query or per representation of a resource?

I am in the middle of starting up a new project and just wanted some reassurance as to which approach to DTO’s returned by the read-side was easier to maintain in a real world application with reasonable complexity.

I realize with a DTO per query, it would allow for a specific query’s response to diverge from the others more easily in the future. However, common properties between that query and other queries would require changes in multiple places (e.g. the same resource could have multiple queries in the form of GetById, GetAll, GetByStatus, GetBySomethingElse, etc.) and there is more repetition.

If a DTO is created per representation of a resource, a GetById might return a DetailedDto with many properties, while a GetAll might return a SummarizedDto with fewer properties. This would require less changes for common properties and diverging queries would just require a new version of the DTO to be created. The biggest disadvantage to this approach is that I’m terrible at naming classes and coming up with words, so “Detailed” + “Summarized” is the extent of my imagination.

I’m leaning towards refactoring my first attempt at writing this application from using the “DTO per query” to the “DTO per representation” approach. Are there any benefits to sticking with the “DTO per query” or is “DTO per representation” a good way to go?

Is there a connection between representation theory and PDEs?

As a PhD student, if I want to do something algebraic / linear-algebraic such as representation theory as well as do PDEs, in both the theoretical and numerical aspects of PDEs, would this combination be compatible and / or useful? Is it feasible?

I’d be grateful for an online resource to look into.


Representation of the space of lattices in $\Bbb R^n$

The space of 2D lattices in $ \Bbb R^2$ can be represented with the two Eisenstein series $ G_4$ and $ G_6$ . Each lattice uniquely maps to a point in $ \Bbb C^2$ using these two invariants, and the points $ (1,0)$ and $ (0,1)$ map to the unit square and triangular lattices.

This representation requires us to treat $ \Bbb R^2$ as being isomorphic to $ \Bbb C$ , so that we can evaluate, for some lattice $ \Lambda(\omega_1, \omega_2)$ generated by $ \omega_1$ and $ \omega_2$

$ $ G_k(\Lambda) = \Bbb \sum_{0 \neq \omega \in \Lambda(\omega_1, \omega_2)} \frac{1}{\omega^k} $ $

where each element $ \omega \in \Lambda$ is then treated as having the algebra structure from $ \Bbb C$ .

The above is often treated in the setting of modular forms, where it is assumed that everything is in $ \Bbb C$ from the start, and that one of the lattice vectors is $ 1$ . However, it is also given fairly often as an equivalent treatment in terms of real lattices.

So the basic question is, how do you develop a similar theory for $ \Bbb R^n$ ? Is there a similar algebra structure one can place on $ \Bbb R^n$ taking the place of $ \Bbb C$ ?

My big-picture questions:

  1. What is a direct formula to represent the space of lattices in $ \Bbb R^n$ , so that every lattice corresponds to a unique point?
  2. If the above is too complicated, is there an easier representation if we allow for things like “signed lattices,” or allow different automorphisms of the same lattice to be represented with different elements of the same space, etc? (As an example, in $ \Bbb R^2$ , suppose we differentiated between two 90 degree rotations of the square lattice, or three 60 degree rotations of the triangular lattice, while equivocating between any 180 degree rotation of the same lattice.)

Assuming some generalization of the Eisenstein series is relevant, then the follow-up questions would be

  1. How do you generalize the Eisenstein series to lattices in $ \Bbb R^3$ , or $ \Bbb R^n$ in general?
  2. Assuming you manage to do that, the space of lattices for $ \Bbb R^n$ should have dimension $ n^2$ . Which Eisenstein invariants are needed to uniquely represent this space of lattices?
  3. The Eisenstein/Weierstrass invariants can be viewed as coefficients from the Laurent expansion of the Weierstrass elliptic function. Is the above simplified from looking at the Laurent expansions of higher-dimensional elliptic functions?

I have been pointed in a few interesting directions – Eisenstein Series on Real, Complex, and Quaternionic Half-Spaces, Eisenstein Series in Complexified Clifford Analysis, Generalization of Weierstrass Elliptic functions to $ \Bbb R^n$ , On a New Type of Eisenstein Series in Clifford Analysis, Clifford analysis with generalized elliptic and quasi elliptic functions. People have suggested the theory of automorphic forms and the Langlands’ Eisenstein series.

However, I have somehow been unable to unpack all this to get a simple definition of the space of n-dimensional real lattices. I would assume that some generalized Eisenstein series would be necessary, but I don’t know how to build them for arbitrary $ \Bbb R^n$ . Some of the suggestions for replacing $ \Bbb C$ with an arbitrary Clifford algebra can sometimes equivocate between different lattices. For instance, even in the simplest case of $ \Bbb R^4$ , where we can treat the entire thing as the quaternion algebra, we tend to have that the lattices $ \Lambda(1,2\mathbf e_1,\mathbf e_2,\mathbf e_3)$ and $ \Lambda(1,\mathbf e_1,2\mathbf e_2,\mathbf e_3)$ produce the same Eisenstein series, if we naively use the formula $ \sum_{0 \neq \omega \in \Lambda} \frac{1}{\omega^k}$ .

This was originally posted and bountied at MSE:

I am hoping for some basic explication of how to do this that doesn’t require extremely deep knowledge of elliptic curve geometry and etc – I just want a basic representation for the space of n-d lattices.

portable hashable string representation of data object

I have a class of (flat) objects that are going to be passed around between three different parties, each possibly running a different software stack.

my_object:   item: "string_a"   money:     amount: 99.9     currency: "EUR"   metadata: 5   origin: "" 

These objects will need to be signed and the signatures will need to be verifiable.
In order for the signed hash to be stable from one party to another, there has to be an exact canonical string representation.

For example, both the following are valid string representations of the above object, but they’ll have different hashes.

<my_object xmlns="">   <item>string_a</item>   <money>     <amount>99.9</amount>     <currency>EUR</currency>   </money>   <metadata>5</metadata>   <origin></origin> </my_object> 
<my_object xmlns="">   <item>string_a</item>   <money><amount>99.9</amount><currency>EUR</currency></money>   <metadata>5.0</metadata>   <origin></origin> </my_object> 

All parties will be parsing the objects, so it’s the values that need to be verifiable in the signature process. In the above example, the data that needs to be signed is
{“string_a”, 99.9, “EUR”, 5, “”}.
Of course there must be no ambiguity about which value goes with which key; for example it must be clear that 5 is the metadata and not the amount.
That said, it seems reasonable to have the original serialization of the data treated as a data-value in-itself, and the contained data parsed out of it as needed. This would solve the above problem of a byte-perfect canonical version.

I think it’s a good idea to define the “outer” signed object in XML.

<signed_object xmlns="">   <data>string representation of the inner data object</data>   <signature>RSA signature of the SHA512 hash of the value in `data`</signature> </signed_object> 

Clearly I have a variety of options for what should go in that inner <data> tag.

  • An escaped XML string would work.
    • We know all the parties have xml parsing set up.
    • We could help with verification by providing an XSD.
    • The relatively large size of an xml string isn’t a big deal because this will all get compressed.
    • On the other hand, it would be a pain for a human to look at an xml-escaped xml string and understand what was going on.
    • Also, a naive implementer might try to rebuild the XML from the contained data, get a different hash, and decline a valid signature.
  • JSON and Yaml might be slightly better than XML for human readability, but would have the same problem that “equivalent” objects could have different hashes.
  • A delimited string (with commas, pipes, etc) would more be human-readable, and would clearly be string data in itself.
  • Taking that idea even farther, we could provide a canonical regex with capture groups for unambiguously validating and parsing these strings.
  • And finally, we could decide not to worry about having a canonical string version of each such object, and instead have a really well defined process for serializing the data for hashing.
    • This would look the best.
    • This would be the easiest to screw up.

Expanding on that last option (because it’s the one I’ve actually seen done in the wild):

  • Simply concatenating the values in an explicit order probably won’t work: what if item ends with numeric characters?
  • Concatenating the keys and values in an explicit order would probably work, the only problems I can think of are ambiguities in how to represent numbers (5 vs 5.0), or possibly conversions between UTF-8/UTF-32/ASCII.

I like the idea of defining the string format using a regex. Is that a bad idea for any reason?

EDIT: I’ll be asking other people to implement parts of this system, on a variety of platforms. What system will be the easiest and/or most reliable to implement, in general?

Intuitive representation of “increase priority”

We have a grid, each row represent a pending download. By default, downloads will proceed top-down, first row first, second row after that, etc.

We want to put a column in the grid with a symbol/icon/button suggestions inside
so the user can use that control to say: i want this row to be transferred after first row, and then this… in other words, priorize transfer order overriding the default 1 to N order.

NOTE: sorting rows is not an option. Order has other implications and has to be kept as is.

Here´s a mock of the existing gui i am trying to improve.

The user adds items (hard covers, chapters, index, maps, etc) to build a book. The table can be sorted, and this will change the items order in the book.
As the user adds one item the app begins to download additional info (this process is sometimes a bit long). Let our book be: front cover, index, chapter 1, chapter 2, chapter 3, back cover. We add the proper items…

enter image description here

And the transfers begin automatically.

After a while, item 1 has succesfully downloaded its info, so item 2 begins to download info too.

enter image description here

Now guess chapter 1 and 2 are approved and has no recent changes, so no need for further inspection. but Chapter 3 and Back cover are the ones we want to check before approve the hole thing.

So we want to instruct the download queue to first download Hard Cover, and after that proceed with Chapter 3. Otherways we have to wait for previous transfers to complete while doing nothing because we dont need the info.

We want this to happen:

enter image description here

My question is:

How can i redesign that “Waiting” column so the user can intuitivelly know that download queue can be altered? Which controls/icons (instead of the “Waiting” label) are best suited for that?
I´d like that someone that is facing the waiting problem could say: Cool, if i click/use this i can alter the download queue and prioritize the items i want most !

Feel free to add a column, replace Waiting label with buttons, icons…
Any suggestions welcome.

Hypergeometric representation of Eisenstein series

It is well known (Fricke ?) that $ E_4^{1/4}$ and $ E_6^{1/6}$ can be represented as Gauss hypergeometric functions of $ 1728/j$ and $ 1728/(1728-j)$ respectively. The same result is true in levels $ 2$ , $ 3$ , and $ 4$ for instance, in which case $ E_4$ , $ E_6$ , and $ j$ must be replaced by analogous modular functions. The standard way of proving this is to show that both sides are solutions of the same linear differential equation of order $ 2$ with suitable additional conditions to ensure uniqueness. But this seems to involve in each case some ad hoc and not completely trivial computations. Is there a simple, more elegant manner to prove these results in a unified way without too much computation ?

Representation of a finite group over a finite field from rational representations

Suppose $ G$ is a the cyclic group of $ n$ elements and $ p$ is a prime not in $ n$ . $ G$ has an action on the cyclotomic field as a $ \mathbb{Q}$ -vector space $ \mathbb{Q}[X] / \langle \Phi_n(X) \rangle$ by multiplication by $ X$ . This is an irreducible $ \mathbb{Q}[G]$ -representation. In particular, it acts as automorphisms on $ \mathbb{Z}[X]/\langle \Phi_N(X) \rangle$ . After reduction modulo $ p$ , $ G$ acts on $ \mathbb{F}_p[X]/\langle \Phi_N(X) \rangle$ . However, after reduction mod $ p$ , the representation is no longer irreducible and splits into isomorphic copies the same irreducible representations. This can be shown by seeing how the polynomial $ \Phi_N(X)$ splits in the finite field.

One can now consider a finite group $ G$ and any prime $ p$ not appearing in $ |G|$ . If we have an irreducible $ \mathbb{Q}[G]$ -representation $ G\rightarrow GL_n(\mathbb{Q})$ , after some conjugation, we can assume $ G \rightarrow GL_n(\mathbb{Z})$ and then consider the induced $ \mathbb{F}_p$ -representation. Are there any similar results that generalize the above result of cyclic groups and let us know something about the irreducible components?

Is there an algorithm or design pattern for converting an object into a string representation involving slightly complex logic?

I am trying to write code to convert a javascript object which might look like this:

var object = {   category: [     {       subcategory: true,       includedValues: ["abc", "cde"]     },     {       subcategory: false,       values: ["xyz"]     },     {       subcategory: true,       excludedValues: ["123"]     }    ],   item: {     includedIDs: [12, 23],     excludedIDs: [65,34]   } }  

Into a filter string which looks like this:

var filter = 'category(true)==["abc","cde"]&category(false)==["xyz"]&category(true)!=["123"]&item==[12,23]&item!=[65,34]' 

As you can see, it is not a trivial stringifying the JSON. What I want to know is what is this process called. I am also doing the reverse of this where I need to convert the string to the JSON object. And I am using nearley.js for that. The only fixed component of the problem is the string. The structure of the object is something I am working on and can be modified/changed. I have most of the string to JSON working. I am trying to find the best way to do the JSON to string conversion. It is my understanding that nearley is not meant to do the conversion from JSON to string. I am not sure if it can even do it. So what would be the best way/methodology to do something like this?

Visual representation for higher-order functions [closed]

I’m creating a visual programming language. I base on functional programming paradigm, because I believe that declarative thing should be mapped to visual more easily. I mostly done with conceptual design but there is one thing that I need to make that language full-featured and I still can’t come to the solution: higher-order functions (the functions that take one or more other functions as its arguments and do whatever it wants but mostly apply that functions to some data and do something with their outputs).

The best solution I found is one by Autodesk’s Max Creation Graph (there is also a good article explaining HOF’s). Here is how it looks:

Here Map is a higher-order function, stuff in white dashed border is its function argument, orange dot with hint – argument of that “child” function, and the rightmost dark-cyan is the output of “child” function. This solution, however, have some obvious weak points. First of all you need a hand-drawn hint, to figure out where input is. Second – what if you have more than one such unconnected orange dots (e.g. optional arguments)? Or more than one unconnected outputs (e.g. some side-effect functions are used)? And finally, what if “child” function need more then one argument (e.g. for Map it can be element and index so you can not only transform an element of the array but also do something based on it’s position in that array) – it’s kind of ಠ_⊙ what the heck will happen in that situation at all…

So, maybe you have some kind of hints, insights or better examples? Or… fresh eye at least.