當涉及utils和其他幫助類時,我有問題正確地命名我的類和服務。命名空間和類名稱準則
你會如何構建如下:
EventService.cs
EventServiceUtils.cs
EventServiceValidators.cs
EventServiceCoordinator.cs
等等
我有同樣的需求作爲上述服務的多個服務。 一個想到的就是這一切的分成合適的命名空間,使得它看起來是這樣的:
Services.EventService.EventService.cs //(the actual service)
Services.EventService.Validators.DateValidator.cs
Services.EventService.Validators.ParticipantValidator.cs
Services.EventService.Coordinators.ParticipantCoordinator.cs
Services.EventService.ExtensionMethods.Extensions.cs
等。每個命名空間當然是一個單獨的文件夾。 但是這並不是100%,因爲在其他服務中可能會有更多的DateValidator,這很容易導致不需要的引用。
而且Services.EventService.EventService.cs也在命名空間中包含類名,這也是不好的。您可以使用Services.Event.EventService.cs,但當然已經有一個具有該名稱的實體。
這是域模型。