Search code examples
.netnaming-conventionsn-tier-architecture

Is there a naming convention for custom repository response objects?


Probably some of you already met this problem. Sometimes you may want to execute a LINQ query which is returning custom data. That data is being encapsulated into a transfer object, but I'm a little confuse about the naming of these objects. We can't name it DTO cause those are used to transfer data from the service layer. In this case is there a particular naming convention?


Solution

  • There is not an industry-wide standard where "industry" means the software development community.

    Anecdotally, I've seen some common naming conventions:

    • Append Dto to the name of the entity -- what you suggested. There is no reason you can't do this for data coming back from the database as well (after all the .NET object holding DB data is still a data transfer object). You could, of course, run into naming conflicts with the service layer if not cleanly separated.
    • Append Data.
    • Append Entity for entities in the database, or Value if the data represents a value object.
    • Prepend Db.

    For your case you most likely need to avoid naming conflicts, which means appending Data or prepending Db would be good choices.