Code Style

Project Structure

The repository is divided into four modules.

  • blocklylib-core: The central library, and all that is needed for running Blockly without a UI (for example, for code manipulation and generation).
  • blocklylib-vertical: This module contains the VerticalBlockViewFactory and the visual style for Blockly's default, vertically stacking blocks.
  • blocklytest: This module contains the unit tests and instrumentation tests for both blocklylib-core and blocklylib-vertical.
  • blocklydemo: This contains the Blockly Demo app with several activities that demonstrate the basics of using Blockly for Android.

Java Style

Blockly for Android uses the Android code style. Most of the style rules should be familiar to most Java developers:

  • Class names are capitalized and camel-case.
  • Constants are capitalized.
  • All other methods and variables are camel-case, beginning with a lower case letter.

In addition, member variables must begin with a lower case "m". For example:

public abstract class AbstractBlocklyActivity extends AppCompatActivity {
    private static final String TAG = "AbstractBlocklyActivity";

    public static final String DEFAULT_WORKSPACE_FILENAME = "workspace.xml";

    protected ActionBar mActionBar;
    protected DrawerLayout mDrawerLayout;

    protected WorkspaceHelper mWorkspaceHelper;
    protected BlockViewFactory mBlockViewFactory;
    protected WorkspaceFragment mWorkspaceFragment;
    protected ToolboxFragment mToolboxFragment;
    protected TrashFragment mTrashFragment;

For logging purposes, each class may have a private static final TAG string.

Log.i(TAG, "No blocks in workspace. Skipping run request.");