I am surprised that NPEs are one of the most important part of applications but one of the most limited ones. Also sometimes not reliable. Some examples:
- We can only use many-to-many and many-to-one relations from NPE to PE. But in real life apps, there are so many actual one-to-one relations masked as many-to-many or many-to-one! The developers just use singleton pattern - they always retrieve with Head and allow creating only 1 object. This way they achieve functional one-to-one associations which look like many-to-one or many-to-many in domain model. I find this as ugly architectural pattern. The code is unnessecarily complicated and not well readable. We need actual 1-1 to have clean and readable code.
- Many times we need something like "mirror" entity. For example in a wizard, we could fill in an NPE and if everything is finished, we mirror the data to PE entity and commit. In this example which is used very often, it would be right to have 1-1 association or NPE should be inherited from PE - both not possible, so developers are using ugly workarounds all the time.
- Someone would think that NPE would be a good place to temporarily store some data and retrieve them later. Not true. NPEs are very unreliable if used like this. In some places of the app, a retrieve simply returns empty (which can probably have several reasons - multiple states, garbage collection etc. - it is not alway even clear). The only reliable way is currently to store the temporary data to NPE and pass the NPE as a parametr to a page/DS right away and work with it/display it.
Because NPEs are one of the Mendix fundamentals, I would suggest to give it more care and keep up with how NPEs are actually used in the real life apps.