Sample

Schnappinger/aoi/artofillusion.procedural.NumberModule

Human rating uses the original dataset scale.

Human2.82
Lines116

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
39.8Δ 21.3
Scalabrino0.7710–1; higher is more readable
55.5Δ 37.0
Dorn0.2240–1; higher is more readable
42.6Δ 24.1
Mi0.5530–1; higher is more readable
43.6Δ 25.1
LLOC36Logical lines; fewer is more readable
46.0Δ 27.6
DeepSeek V4 Pro160–20; mean of three runs
47.4Δ 28.9
GPT-6.1 Sol170–20; mean of three runs
55.3Δ 36.8
BTTF0.4890–1; higher is more readable
43.9Δ 25.4
Human2.821–4; original rating
18.5

Views

Source code

/* Copyright (C) 2000-2011 by Peter Eastman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ package artofillusion.procedural; import artofillusion.*; import artofillusion.math.*; import artofillusion.ui.*; import buoy.event.*; import buoy.widget.*; import java.awt.*; import java.io.*; /** This is a Module which outputs a number. */ public class NumberModule extends Module { private double value; public NumberModule(Point position) { super("0.0", new IOPort [] {}, new IOPort [] { new IOPort(IOPort.NUMBER, IOPort.OUTPUT, IOPort.RIGHT, new String [] {"Value"})}, position); } public NumberModule(Point position, double v) { super(Double.toString(v), new IOPort [] {}, new IOPort [] { new IOPort(IOPort.NUMBER, IOPort.OUTPUT, IOPort.RIGHT, new String [] {"Value"})}, position); value = v; } /** Get the value. */ public double getValue() { return value; } /** Set the value. */ public void setValue(double v) { value = v; } /** Allow the user to set a new value. */ public boolean edit(final ProcedureEditor editor, Scene theScene) { final ValueField field = new ValueField(value, ValueField.NONE); field.addEventLink(ValueChangedEvent.class, new Object() { void processEvent() { value = field.getValue(); editor.updatePreview(); } }); ComponentsDialog dlg = new ComponentsDialog(editor.getParentFrame(), Translate.text("selectValue"), new Widget [] {field}, new String [] {null}); if (!dlg.clickedOk()) return false; value = field.getValue(); name = Double.toString(value); layout(); return true; } /** This module simply outputs the value. */ public double getAverageValue(int which, double blur) { return value; } public void getValueGradient(Vec3 grad, double blur) { grad.set(0.0, 0.0, 0.0); } /* Create a duplicate of this module. */ public Module duplicate() { NumberModule mod = new NumberModule(new Point(bounds.x, bounds.y)); mod.value = value; mod.name = ""+value; return mod; } /* Write out the parameters. */ public void writeToStream(DataOutputStream out, Scene theScene) throws IOException { out.writeDouble(value); } /* Read in the parameters. */ public void readFromStream(DataInputStream in, Scene theScene) throws IOException { value = in.readDouble(); name = ""+value; layout(); } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.3162.41−104.36
Source linesThe number of non-empty source lines.116+46.4
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.895−7.342

Intercept 8.87 + feature contributions = -56.432 (log-odds).
Score = sigmoid(-56.432) = 0.

Score0.771

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.117−3.106
Indentation frequencyHow rapidly indentation changes from line to line.108+2.998
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.108−2.057
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.125.949−1.67
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.125.991+1.228
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.115.811+1.209
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.088+0.085

Intercept 0.07 + feature contributions = -1.242 (log-odds).
Score = sigmoid(-1.242) = 0.224.

Score0.553
Score36
Run 1

The code is well-structured, with clear class and method organization. Nesting is minimal, and each method serves a single, obvious purpose, which aids clarity. The action granularity is appropriate—most lines perform one logical action. Naming is descriptive, and comments are concise but informative. However, there are minor readability issues: inconsistent brace style (some opening braces on the same line, others on a new line), slight inconsistency in string concatenation (Double.toString() vs ''+value), and a somewhat long constructor call that could be formatted more consistently. Overall, the code is easy to follow and maintain, but those small inconsistencies prevent a higher score.

Run 2

The code is well-structured and readable. It is organized into logical methods (constructor, getter/setter, edit, duplicate, serialization) with clear, descriptive names. Nesting is minimal—only a small anonymous inner class for event handling and a single conditional. Intent is generally clear: the class represents a numeric module and its behavior is straightforward. Code length is concise; each method is short and focused. However, the second constructor is slightly dense due to the inline array creation and the super() call is formatted in a way that reduces readability. Action granularity is mostly one action per line, though the constructor could be broken up. Reading flow is natural, with methods ordered logically. The use of comments is helpful, though some could be more descriptive. Overall, it is highly readable with only minor formatting concerns.

Run 3

The code is generally readable with a clear purpose and straightforward structure. Each method is short and performs a single logical action, and nesting is minimal. The reading flow is natural, following a logical top-to-bottom order. However, several aspects reduce readability: inconsistent brace placement and spacing, especially in constructors, makes some lines unnecessarily long and hard to parse. Comments are sparse and some are redundant or missing context. The 'empty IOPort array' repeated inline creates clutter, and magic strings like "Value" or "0.0" are not constants. Action granularity is mostly good, but constructor calls combine multiple parameters on one line, reducing clarity. Overall, it is understandable but could benefit from formatting consistency and minor refactoring.

Run 1

Code Structure: Well organized into constructors, accessors, editing, output, duplication, and serialization methods, with clear separation of responsibilities. Nesting: Mostly flat; the anonymous event handler adds only modest nesting. Clarity of intent: Descriptive method names and brief comments make the module's purpose clear, though abbreviated names such as v, mod, and dlg and implicit inherited state require some context. Code length: Compact overall, but constructors repeat port setup and several comments merely restate method names. Action granularity: Statements generally perform one action per line; lengthy constructor and dialog expressions are harder to scan. Reading flow: Method ordering and consistent indentation support natural reading, while wildcard imports, uneven line wrapping, and inconsistent numeric string conversion slightly reduce readability.

Run 2

Code Structure: Well organized into constructors, accessors, editing, output, duplication, and serialization methods, with clear separation of responsibilities. Nesting: Mostly flat; the anonymous event handler adds only modest nesting, and the early return simplifies dialog handling. Clarity of intent: Descriptive method names and brief comments make the constant-number module's purpose clear, although names such as v and mod are less descriptive, and live value changes before dialog confirmation require closer inspection. Code length: Short, focused methods keep the class concise, though constructors repeat port initialization and some comments merely restate method names. Action granularity: Statements generally perform one action per line. Reading flow: Consistent formatting and logical method ordering support easy reading; long constructor/dialog expressions, wildcard imports, and inconsistent numeric string conversion slightly reduce readability.

Run 3

Code Structure: Well organized into small methods for initialization, access, editing, duplication, and serialization; constructor setup is duplicated. Nesting: Mostly flat, with modest nesting in the anonymous event handler and a clear early return. Clarity of intent: Descriptive method names and brief comments make the constant-number module's purpose clear, though names such as v and mod are less expressive and inherited state requires context. Code length: Appropriately concise overall, with some redundant comments and repeated initialization. Action granularity: Statements generally perform one action per line; constructor and dialog expressions are somewhat dense. Reading flow: Methods follow a natural progression and formatting is largely consistent, but long argument lists, wildcard imports, and inconsistent number-to-string conversion slightly interrupt readability.