Search This Blog

2010-02-24

Name Convention for Object Oriented Apps

Some time ago I came across with a question about naming conventions for different parts of the software: UI, Service, Entities, etc. I decided to share some of the conventions I have been using.


Naming Convention: ( Most used ):

Entities: As it is part of the domain package, no prefixes or suffixes here: Ex: Car, Client, etc.

Repository: Usually a suffix Repository. Ex: ClientRepository, CarRepository, etc.

ValueObject: Value objects are part of the domain so it follows entity´s convention. Ex: Money, Address, etc.

DTO: Usually a suffix DTO. Ex: ClientRegistrationDTO, CarRentDTO, AddressDTO, etc.

Service: Usually a suffix Service. Ex: ClientRegistrationService, CarRentService, etc.

Namespace Convention: (My Suggestion)

Entities, ValueObjects, Repositories Interfaces, Domain Services (Domain Layer)
..Domain.
Ex: Acme.Finantial.Domain.Debt,
      Acme.HR.Domain.CheckOvertimeService,
      Acme.Core.Domain.IPersonRepository    

Application Services 
..Service.
Ex: Acme.Sales.Service.ClientRegistrationService

Presentation Layer
..Presentation.
Ex: Acme.HR.Presentation.IClientRegistrationView, Acme.HR.Presentation.WebClientRegistration

Persistence Layer
..Persistence.
Ex: Acme.Core.Persistence.PersonRepositoryImpl (<--- implementation in NH, for example)
Post a Comment