Skip to content

Style guide naming conventions doesn't cover formats / protocolls #1439

Closed
@valenterry

Description

@valenterry

The Naming Conventions on the Style guide does not cover formats or protocols. It says:

Underscores in names (_) are not actually forbidden by the compiler, but are strongly discouraged as they have special meaning within the Scala syntax. (But see below for exceptions.)

What I mean by that are field names in classes that have the sole purpose of describing a format and are used to dervice/generate encoders and decoders and being seperate from the case class that is actually used within the rest of the code (using camelCase fields). These format-classes are usually used to separate domain classes from multiple possible formats or ways of serializations, especially when there is no control over the format. The naming conventions should cover this.

A concrete example using circe would be a something like:

case class UserData(
   user_id: Long,
   name: String,
   lastUpdatedTimestamp: Long
)
object UserData {
   implicit val userDataDecoder: Decoder[UserData] = io.circe.generic.semiauto.deriveDecoder
   def convert(data: UserData): domain.User = ???
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions