Protocol Naming Convention

Hi,


We have some 'ViewModel' (Protocol) + Its main implementation in the app + Its Mock.


In your opinion, what would be Correct way to name:

1/ ViewModel / MyProjectViewModel / MockViewModel

2/ ViewModelProtocol / ViewModel / ViewModelProtocolMock

3/ ViewModelType / ViewModel / ViewModelTypeMock


I have already found Swift rules, with 'ing' / 'able', but it is not very suitable for our case.


Thanks in advance for your inputs

What's the question? swift.org says 'should'*, not must, so when an example is atypical, such as yours, if your question is 'is it ok?', my suggestion is it is on you to test, being prepared for atypical behavior in your own code/apps.


*

  • Protocols that describe what something is should read as nouns (e.g.
    Collection
    ).
  • Protocols that describe a capability should be named using the suffixes
    able
    ,
    ible
    , or
    ing
    (e.g.
    Equatable
    ,
    ProgressReporting
    ).

I'm pondering this question in relation to a Protocol associated with CloudKit. I want a name for a protocol - like Coadable - is used for JSON to/from Objects. My desired protocol NAME will ensure that the Object implements the ability to be Instantated from a CKRecord and has a readable property that is a CKRecord.

I'm pondering sticking with the Cloud metaphore...

// Other options for a Protocol name: Precipitable, Materializable, dematerialize, evaporable, Sublimation
// capabile of being  instantiated by CloudKit (from cloud to actual) & Sublimation (solid > gas phase change)
protocol CKPrecipitable {
    init?(record: CKRecord)
    var record: CKRecord { get }
}

What's you opinion?

Protocol Naming Convention
 
 
Q