April-Varbook Practical Guide: Say Goodbye to Variable Naming Anxiety

a year ago

As programmers, haven't we all experienced this: writing code logic swiftly, only to get stuck for ages on variable naming? Think of userName - seems too simple; think of currentAuthenticatedUserIdentifier - feels too long...

Today I want to recommend an amazing tool - April-Varbook, a variable naming assistant specifically designed for Chinese programmers, combining the dual power of LLM and knowledge base.

Simply put, you describe your idea in Chinese, and it generates standardized English variable names for you.

https://appstore.lazycat.cloud/#/shop/detail/cloud.lazycat.app.varbook

Hands-on Experience

This application requires an API, so you need to complete this step first:

Visit Niutrans website https://niutrans.com/trans?type=text and register an account. After logging in, go to the left menu 【API Applications】. Under the 【Text API】 card, click the "Activate Service" button.

image.png After activation, you can see the API-KEY and APPID on the page (as shown by the red arrows in the image below).

image.png Click the copy button to get your API-KEY.

Open the application and paste your key.

image.png

The simplest way is to directly input Chinese descriptions:

Input: 用户名
Output: username, userName, user_name
Input: 当前登录的用户信息
Output: currentUserInfo, loggedInUser, activeUserData

image.png

Contextual Naming

The powerful aspect of this tool is its ability to provide appropriate suggestions based on different contexts:

Frontend Development:

Input: 按钮加载状态
Output: isButtonLoading, buttonLoadState, loadingButton

Backend Interfaces:

Input: 获取用户详细信息的方法
Output: getUserDetails(), fetchUserProfile(), retrieveUserInfo()

image.png Database Fields:

Input: 用户最后登录时间
Output: last_login_time, user_last_login, latest_login_timestamp

Directly click on the corresponding name to copy it to the clipboard.

image.png

Don't just input a single word; describe more context:

❌ Poor input: 状态 ✅ Better input: 用户账户的激活状态

The results differ significantly:

  • The first might give you: status, state, condition
  • The second will give you: accountStatus, isUserActive, userActivationState

Specifying Naming Conventions

If your team has specific naming conventions, you can mention them in the description:

Input: 用户ID(驼峰命名)
Output: userId, userIdentifier, userAccountId

Input: 用户ID(下划线命名)
Output: user_id, user_identifier, user_account_id

image.png

Summary

The April-Varbook tool genuinely addresses a pain point for Chinese programmers. By combining LLM and knowledge base, it not only understands your Chinese descriptions but also provides naming suggestions that comply with industry standards.

However, tools are just aids; true programming skills still rely on daily accumulation. While using this tool, also observe and learn good naming patterns to gradually develop your own naming intuition.

Finally, if your team also struggles with variable naming, why not give this tool a try.

Author
天天