On the Naming of Methods: A 4-block function

Thinnakrit
2 min readFeb 14, 2023

--

Naming things creates a shared understanding for the entire team, leading to fast development and minimal errors. It can also aid in the quick resolution of various problems. For more details, see the paper at https://arxiv.org/pdf/2102.13555.pdf.

A 4-block function is a function name split into 4 parts: Handling, Verb, Identifying, and Result.

1. Handling

The function’s location is specified to define the area of function usage, helping to recognize what parts of the function can be used. There are 3 forms: _handle, handle, and on.

2. Verb

Function actions, such as Search, Get, Update, Delete, etc.

3. Identifying

The purpose of the function is identified, including where it does it, such as Data, Transaction, etc.

4. Result (Optional)

The data format obtained after the function is executed is specified, such as List, Detail, etc.

Handling + Verb + Identifying + Result (Optional)

Example

handleDownloadFileList
onSearchPlace
_handleGetTransactionDetail

Handling

_handle: The _handle defines a function to be executed within a specific scope and not outside that scope.

handle: The handle defines functions that work within a specific scope and can be used outside that scope if written as such.

on: on defines and identifies the function’s origin, indicating it is inherited from other scopes.

Example

Handling Example

explain

_handleGetNumber — can only be used inside the TestHandle, not outside the TestHandle. handleCalNumber — can be used internally or externally. If it must be used externally, change handle to on (onCalNumber).

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Thinnakrit
Thinnakrit

Written by Thinnakrit

Software Engineer with over 10 years of experience in the Banking Industry and E-Commerce, Technical expertise in developing high-quality software solutions

No responses yet

Write a response