2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Apex文字数削減のためのプラクティス

Posted at

Apex文字数削減のためのプラクティス

  • 定数定義クラスは必要最小限にする。

    • 同じ意味の定数を再定義しない。

    • 定数定義クラスはアプリケーション単位で用意することを考える。

  • 不要なタブ・スペース・改行は削除する。

    • インデントはタブで行う。

    • 行末の空白は削除する。

※変数名と"="の間のスペース

public static final Integer VAR001[SPC][SPC]= 0;

public static final Integer VAR002[SPC][SPC]= 1;

public static final Integer VAR003[SPC][SPC]= 2;

※不必要なタブ

    catch (Exception e){

[TAB][TAB][TAB]

        throw e;

    }

[TAB][TAB]

    return resultValue;

※行末の空白文字

public static final Integer VAR001= 0;[SPC][SPC][SPC][SPC][SPC]

  • 階層構造の下位エレメントに大量にアクセスする場合は、上位階層を一時変数に格納し、アクセスを行うことで、文字数を削減できる。
ioDat.work.IDE_KyotsuHokenShurui__c = ...

ioDat.work.IDE_KyotsuHokenKikan__c = ...

ioDat.work.....

ioDat.work.....

ioDat.work.....

ioDat.work を一時変数に代入することで、'ioDat.'の重複を除去できる

  • オブジェクト名やクラス名に不必要に長い名称を使用しない。
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?