Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A suggestion about the field name #4

Open
jeff1992 opened this issue Jan 10, 2017 · 2 comments
Open

A suggestion about the field name #4

jeff1992 opened this issue Jan 10, 2017 · 2 comments

Comments

@jeff1992
Copy link

` public abstract class EntityBase
{
public Guid Id { get; set; }

    public DateTime CreatedTime { get; set; }
    public DateTime? LastUpdatedTime { get; set; }

    public bool IsNew => this.Id  == Guid.Empty;

    public void NewId()
    {
        this.Id = Guid.NewGuid();
    }

    protected EntityBase()
    {
        CreatedTime = DateTime.Now;
    }
}`

CreatedTime>CreatedAt
LastUpdatedTime>UpdatedAt

If user needed, named like this:
CreatedBy
UpdatedBy

@leotsai
Copy link
Owner

leotsai commented Jan 10, 2017

Thanks for the suggestion. My consideration of using "Time" suffix is to indicate this field stores the Time part of the DateTime type. If one field only stores the Date part, I would name it to CreatedDate. So, if you want to use "at", I'd still prefer to add "Time" to the end, i.e. CreatedAtTime.

For another instance, if you have one "interval" field, I'd name it to "IntervalSeconds" or "IntervalMinutes" or "IntervalHours", which makes it extreme clear to the other developers, without code comments.

@jeff1992
Copy link
Author

In addition, I have some obsession in coding. And usually, it takes me several minutes to think out a field or property name when more than one way could be taken, e.g. "Last" should be cut in "LastUpdatedTime" for "UpdatedTime" is clear enough to developers and "LastUpdatedTime" is more like a Chinese naming way. And also, “CreatedAtTime” is complicated since "At" usually followed with a datetime. These come from what I found in a source opened PHP project and finally fixed my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants