Placement of entities, global to the app

I am working on a web app with the current website header as shown below enter image description here

From the left,

Product Selection: the app helps the user store data about multiple products. The user can switch between products using the dropdown. Once this is set, the whole app data is within that context

Attributes: The attributes listed are properties of a product. Each Product has these attributes. As soon as a product is selected, the attribute values become specific to that product.

Problem: I have an entity which is global to all products (product agnostic?). Where do I list such an entity.

Creating a separate page through settings (Help and logout become part of the settings dropdown) is the current solution in my mind. Will that be correct?

good ux design patterns to add/edit/remove entities in a mobile app?

I’m looking for Android apps which have good entity management (add/edit/remove) UX. The home page of my app displays a list of configured entity instances. Now I need to give the user the ability to add/edit/remove these entity instances. There could be a “Manage Entities” menu item in the left Drawer menu which would open a “Manage Entities” screen with the following design:

  • The screen could display a search input supporting autosearch.
  • The search input could display an Add button below it to support an Add scenario.
  • Autosearch would return a list of matching entity list items below it on the screen.
  • Each entity item in the list could have a checkbox on the left. When a user selects one or more entity items a Delete button could be rendered at the bottom of the screen.
  • Each entity list item could include an Edit button at the bottom.

These are just off the cuff ideas about how something like this could potentially work. I’m looking for good Android apps which demonstrate a good implementation of these types of UX design patterns so I can decide the approach that I want to take in my own mobile app.

ASPNET EF ‘Validation failed for one or more entities. See ‘EntityValidationErrors’ property for more details.’

Hola amigos estoy tratando de hacer un insert a mi bd , pero obtengo este error

‘Validation failed for one or more entities. See ‘EntityValidationErrors’ property for more details.’

Este es mi Insert

    [Authorize]     [HttpPost]     public ActionResult InsertRole(string role,string id_userCreated)     {          using (DBEnt db = new DBEnt())         {              var rolx = new AspNetRoles()             {                 Name = role ,              };             db.AspNetRoles.Add(rolx);             //db..add(cat);             db.SaveChanges();         }         var action = "Insert";         var comments = "Contadores ingresada por el usuario : ";         InsertInBitacora(id_userCreated, action, comments + id_userCreated);         return RedirectToAction("AdminRoles");     } 

Entinedo que me manda un error porque no le estoy pasando el ID, que junto con Name son los unicas columnas de mi tabla, quiero saber como puedo auto generar el famoso ID, que a todo esto es un nvarchar(128), tal como pasa como pasa cuando se inserta un user en la tabla [AspNetUsers]

Should my game’s entities use global variables?

I have a base class called Entity and several sub classes like Player and Goblin. They all have the method update(delta), but that’s not enough to update Goblin for example, which also requires setTargetPosition(vec2) to get updated properly.

All sub classes are stored together in a single vector vector<Entity*> entities.

Solution 1 is to use some C++ version of JavaScript’s instanceof and depending on class call methods like update() and setTargetPosition().

Solution 2 is to have a source file with global variables like Goblin‘s target position and thus only update() is necessary because all the data that’s needed is in the file with global variables.

Please give me a better solution than those above. Thanks.

Search in Two level nested entities

I’m working on a search page in a website for two nested entities like class and student. the user can searches for specific students like students that has these properties:

gender=male Height=short 

The user can also add other criteria and searches for specific classes that have some students with this properties:

gender=female Height=long 

and

gender=male Weight<50 

So the question is: Have I over complicated the search with this combination?

Is there any other design for support the combination of search in this two level nested entities?

Any feedback would be greatly appreciated.

Should we save clean architecture entities in DB?

I’m a little confused about how to store the entities in DB. According to Uncle Bob, entities encapsulate Enterprise wide business rules. This mean that they can has methods for example.

But it’s correct pass my entity as a parameter to the GatewayInterface / Repository?

I’m been reading some comments here, and some of them tell that is not recommend pass entities to outer layers. Because you are passing Enterprise business logic.

Should I pass a DTO to my Repository only? Something that the repository can map and then save.

Thanks

Immutable entities and Domain Events

I want to know if it’s a good idea modeling the Domain this way:

  • Entities are immutable
  • When a method of the Entity (Command) is issued, it check the actual state to return the right Domain Event or throw an error if it’s the case
  • It doesn’t change any property of the actual instance
  • Then in the application layer the events are sent to the Repository to be stored

    public abstract class UserEvent {     public string userID { get; set; }     public ulong version { get; set; } } public class UserPasswordChangedEvent : UserEvent {     public string password { get; set; } }  public class User {     public string userID { get; set; }     public ulong version { get; set; }     public string password { get; set; }     public bool deleted { get; set; }      public UserEvent ChangePassword(string newPassword)     {         if(!isValidPassword(newPassword)) throw new SomeException("Invalid Password");         if(deleted) throw new SomeException("User deleted");          return new UserPasswordChangedEvent(){ userID = userID, version = version + 1, password = newPassword };     } } 
  • And the unit tests should be this way:

    public class UnitTest1         {             public void Test1(){                 User us = new User(){ userID = "User1", version = 1, password = "", deleted = true};                 UserEvent ev = us.ChangePassword("NuevaPass");                 Assert.Same(new UserPasswordChangedEvent(){ userID = "User1", version = 2, password = "NuevaPass"}, ev);      }  

    }

  • Is this a valid aproach?

  • What are the drawbacks?

  • Are these cosindered integration tests or unit tests?

Problem of making entities agree on some wavelength

I remember seeing this problem somewhere before, but don’t remember what it’s called and can’t find it again.

It was presented as two guys having $ n$ phones each that don’t ring when called. Each phone from one person is connected to one phone of the other person, in some random permutation. They can each test one phone every “round”, to check if they are using a connected pair of phones and thus able to communicate (this is in some way a consensus problem). They had to devise some strategy beforehand to be able to communicate (and minimize the amount of rounds necessary). Of course, the application behind this would be to make two entities connect on some same wavelength at the same time.

What is this problem called, also what are the best strategies?

Which creatures count as “entities from the shadowfell” for the purpose of a Shadow Magic Sorcerer’s origin?

The description of the sorcerer subclass “Shadow Magic” (XGtE, p. 50) starts off with the following paragraph (emphasis mine):

You are a creature of shadow, for your innate magic comes from the Shadowfell itself. You might trace your lineage to an entity from that place, or perhaps you were exposed to its fell energy and transformed by it.

Off the top of my head, I can only think of Shadar-Kai (MToF, p. 62). Other than that, I can’t think of suitable creatures – Darkmantles or Skull Lords among those not even humanoid, and it’s hard to imagine Meazels (MToF, p. 214) or Skulks (MToF, p. 227) having any offspring.

Are there any entities in the Shadowfell known from 5e or previous versions, aside from the Shadar-Kai, that are known to reproduce with other humanoids?
Or does “entity” include an immaculate conception from the Raven Queen? 😀

Is it better to have a single query that returns all related entities, or separate queries for each case?


Summary

When writing methods to query for related entities, is it better to have a single method for all related entities or separate methods for each combination?

Full Problem

I’m writing repository classes for a .NET MVC project where each repository is responsible for querying for a specific entity type. I’m using Dapper, so all of the queries are written by hand. The repositories all implement an IRepository<TEntity> interface, which has method TEntity FindById(id).

Fetching just the entity is obviously very straightforward, but I’m faced with a dilemma when it comes to fetching the entity’s children and grandchildren and so forth. Often times, for an entity to be usable, it needs some or all of its descendants. I initially wrote FindById to return the entity with all descendants, which satisfies all use cases, but is also wasteful in many where I only need several descendants.

I wrote out individual methods for fetching various combinations. FindByIdWithChildA or FindByIdWithChildBAndGrandChildC and such. The problem here is that the method names keep getting longer and longer, which makes them a pain to read, and also wastes a lot of space in code.

My next idea was to accept various enum flag values designating which descendants to return. This worked fine for the immediate children, but by the time I got to grandchildren and beyond I had so many possible combinations to implement, and many of them didn’t make sense or wouldn’t be used.

By the time I have all this boilerplate written out, it almost feels like I’m writing a bad ORM instead of repositories. This has certainly slowed down development dramatically, and it has taken focus away from actually implementing new features.

The obvious wrong solution is to not use SQL joins and have the repositories splice together entities and collections of entities using LINQ. Using LINQ with EntityFramework could be an option, but I don’t think that the solution is to switch to another library.

Should I just simplify and have the single method/query return everything? If not, what is the best way to concisely implement separate methods?

This answer indicated that a FindByIdWithChild type method is normal, but I can’t imagine that being good practice for complex queries.

Clarification

So my entities are Sport, Division, SkillLevel, and TeamType. Each Sport has a list of Divisions, SkillLevels, and TeamTypes. Each Division has a single TeamType and a list of SkillLevels.

Suppose I want a Division with its parent Sport, its TeamType, and all of its SkillLevels. Should I do:

  1. DivisionRepository.FindById(id) which returns all of these properties, ignoring any case where I want just a Division or a Division and Sport, Division and TeamType, etc.

  2. DivisionRepository.FindById(id, BitFlagQueryScope) which has a big mess of an implementation to resolve all the possible flags, some of which might not be needed.

  3. DivisionRepository.FindByIdWithSportAndTeamTypeAndSkillLevels(id) and have one of these methods for every combination I need.

In all three cases, I am making one trip to the database. It’s just a matter of how I structure my code.

Additional example, suppose I want a Sport with just its TeamTypes. Elsewhere I will need a Sport with its SkillLevels, etc. Same questions as above. I’m only making one database trip, but should I use different code for these different queries, or just grab everything and discard/not use the excess?

Additional Clarification

In case there’s something wrong with my design overall, here’s how I’m using the entities:

Action(string id) {     var sport = SportRepository.FindById(id); // This needs to either return everything associated with the entity or be changed to allow specification     var model = new SportDisplayModel(sport);     return View(model); } 

I have two models, $ Entity$ DisplayModel, and $ Entity$ EditModel, and I use them for every view.