Cotin naming convention for boolean return methods

How do I know what a naming convention is for logical return methods? In some cases, using "is", "has", "should", "can" at the beginning of the method sounds normal. but I'm not sure. Is there a better way to name such methods? for example: a function that checks the validation of a map. Should I call it ValidCard or cardValidation or another name? (I did not find it here: https://kotlinlang.org/docs/reference/coding-conventions.html )

+4
source share
2 answers

Kotlin naming stile assumes that you are using Java naming conventions to the extent possible. I suggest you use this answer to the same question about Java.

UPDATE: they released coding conventions http://kotlinlang.org/docs/reference/coding-conventions.html

+2
source

Something about the naming convention for properties in Kotlin, I know this is not for methods. But it is connected:

From the book Kotlin in action (Dmitry Dzhemerov and Svetlana Isakova) - section 2.2.1 Properties :

In Kotlin, properties are a first-class language feature that completely replaces fields and access methods.

Listing 2.5. Declaring a mutable property in a class:

class Person {
    val name: String,      // read only property: generates a field and a trivial getter
    var isMarried: Boolean // writable property: a field, getter and a setter
}

Kotlins Java getter, GetName. : , is, getter , set. , Java, isMarried().

+10

Source: https://habr.com/ru/post/1674446/


All Articles