开发者

What do I name classes whose only purpose is to act as a structure?

For example, take my Actor class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace FreeIMDB
{
    class Actor
    {
        public string Name { get; set; }
        public Image Portrait { get; set; }
        public DateTime DateOfBirth { get; set; }
        public List<string> ActingRoles { get; set; }
        public List<string> WritingRoles { get; set; }
        public List<string> ProducingRoles { get; set; }
        public List<string> DirectingRoles { get; set; }
    }
}

This class will only be used to stuff information into it, and allow other developers to get their values.

What are these types of classes officially called开发者_高级运维? What is the correct nomenclature?


DTO - Data Transfer Objects. ActorDTO in your example.
EDIT: It is called POCO (Plain old CLR objects) or POJO in case of java, I guess.

ref: http://en.wikipedia.org/wiki/Data_Transfer_Object


'Entities'

Usually used to represent a saved state of an object. Mostly used in context to databases or data structures.

Although, it's generally looked-down upon to include it in the name itself (at a prefix or suffix).

Common practice is to name a entity with a singular-form name, and collections of entities with the plural form. Even if it isn't grammatically correct.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜