Search code examples
oopcoding-stylenamingclean-architecture

How to name classes and structures related to the same entity | Suffixes



Share your experience, please, what do you do when you want to set the names of class and structure the same noun? Or am I doing something wrong in my logic?
Thank you!

enter image description here


Solution

  • There is no need to move properties to another struct Car as it is tightly coupled to class Car and it has high cohesion

    So, in my view, it would be better if you put code together in one class:

    public  class Car
    {
        public string Brand;
        public int YearIssue;
        public int MaxSpeed;
    
        public void Go() { }
    
        public void Stop() { }
    }
    

    If you are using C#, then you can read more about struct and class here.

    UPDATE:

    If you want to separate responsibilities between data model and how data should be represented to user, so it is better to call them like CarModel and CarViewModel. CarModel should be mapped to your stored data in some source and CarViewModel should be shown at the user interface. Read more here about model and viewModel