Sample

Schnappinger/diarymanagement/TBA.Messages.ResponseMessage

Human rating uses the original dataset scale.

Human3.17
Lines182

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett0.0190–1; higher is more readable
71.9Δ 39.6
Scalabrino0.9080–1; higher is more readable
91.8Δ 59.4
Dorn0.1920–1; higher is more readable
40.6Δ 8.3
Mi0.7310–1; higher is more readable
87.5Δ 55.1
LLOC42Logical lines; fewer is more readable
42.1Δ 9.7
DeepSeek V4 Pro14.330–20; mean of three runs
32.3Δ 0.0
GPT-6.1 Sol160–20; mean of three runs
38.9Δ 6.6
BTTF0.4580–1; higher is more readable
40.6Δ 8.3
Human3.171–4; original rating
32.3

Views

Source code

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package TBA.Messages; import TBA.Exceptions.MessagesException; /** * This class is the root of all response messages between the client and * the server. It handles the 'Response Header' section of the message only. *<p> * @author Dan McGrath * * @version $Rev:: 247 $ $Date:: 2009-10-23 #$ */ public class ResponseMessage extends Messages { private int errorCode = -1; private String errorMessage = null; private final int errorCodeLen = 1; /** * Constructor does nothing */ public ResponseMessage() { } /** * The Get() Method adds the 'Response Header' to the beginning of the message * passed into it. It then passes it on to Messages to process the * 'Message Header' *<p> * @param childMessage The message to send, not including the 'Message Header' *<p> * @return The actual message string you can send *<p> * @throws MessagesException *<p> * @see #Set(java.lang.String) */ @Override public String Get(String childMessage) throws MessagesException { String message = null; if(errorCode == -1) { throw new MessagesException("Error/Success code not set"); } if(errorCode > 0) { childMessage = errorMessage + '|'; } if(childMessage == null) { childMessage = ""; } message = String.format("%0" + Integer.toString(errorCodeLen) + "x", errorCode) + childMessage; super.SetMessageType('R'); return super.Get(message); } /** * The Set() Method takes a Message and strips out the 'Response Header' * information, returning the rest of the message back so that it can then * be processed. *<p> * @param message The message as recieved. *<p> * @return The message without the 'Response Header' *<p> * @throws MessagesException *<p> * @see #Get(java.lang.String) */ @Override public String Set(String message) throws MessagesException { message = super.Set(message); if(message.length() < 1) { throw new MessagesException("The Response Header is incomplete"); } try { errorCode = Integer.parseInt(message.substring(0,errorCodeLen), 16); message = message.substring(errorCodeLen, message.length()); } catch (NumberFormatException ex) { throw new MessagesException("The Error Code is invalid"); } if(errorCode > 0) { int delimPos = message.indexOf("|"); errorMessage = message.substring(0,delimPos); message = message.substring(delimPos + 1, message.length()); } return message; } /** * This method returns the 'Error Code' field. You must have called either * Set() or SetErrorCode() first. *<p> * @return The Error Code: * 0 = Success * >0 = A Failure *<p> * @see #SetErrorCode(int) */ public int GetErrorCode() { return errorCode; } /** * This method allows you to set the Error Code field. *<p> * @param Code The 'Error Code' to set *<p> * @throws MessagesException *<p> * @see #GetErrorCode() */ public void SetErrorCode(int Code) throws MessagesException { if(Code < 0 || Code > 15) { errorCode = -1; throw new MessagesException("The Error Code is out of range"); } else { errorCode = Code; } } /** * This method returns the 'Error Message' field. You must have called either * Set() or SetErrorMessage() first. *<p> * @return The Error Message: *<p> * @see #SetErrorMessage(java.lang.String) */ public String GetErrorMessage() { return errorMessage; } /** * This method allows you to set the 'Error Message' field. Note, this field * will only be sent if the Error Code field is > 0. *<p> * @param Message The Error Message to set *<p> * @throws MessagesException *<p> * @see #GetErrorMessage() */ public void SetErrorMessage(String Message) throws MessagesException { if(Message == null) { errorMessage = null; throw new MessagesException("The Error Message is null"); } else { errorMessage = Message; } } }

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.2389.133−78.841
Source linesThe number of non-empty source lines.182+72.8
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.515−6.773

Intercept 8.87 + feature contributions = -3.944 (log-odds).
Score = sigmoid(-3.944) = 0.019.

Score0.908

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.180−5.337
Indentation frequencyHow rapidly indentation changes from line to line.113+3.171
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.113−2.172
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.180.784+2.117
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.100.978+0.825
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.100.94−0.61
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.046+0.5

Intercept 0.07 + feature contributions = -1.436 (log-odds).
Score = sigmoid(-1.436) = 0.192.

Score0.731
Score42
Run 1

The code demonstrates a reasonable structure with clear class responsibilities and method separation, earning it moderate points for organization. It is relatively flat with minimal nesting, though the try-catch and conditional blocks add some minor depth. Variable names like 'errorCode' and 'errorMessage' clarify intent, but the logic around message construction and parsing in Set() is somewhat ambiguous (e.g., the delimiter logic and error handling). The code length is appropriate given the protocol complexity, but repetitive null checks and verbose comments slightly inflate it. Action granularity is mostly one action per line, but some lines combine operations and formatting. The reading flow is natural in most methods, but Set() jumps between parsing, error handling, and delimiter logic, making it harder to follow. Overall, the code is readable but could benefit from clearer parsing logic and reduced verbosity.

Run 2

The code is generally well-structured with clear separation of methods and Javadoc comments explaining each method's purpose. Naming conventions are followed, and each method performs a single logical action. However, readability is hampered by inconsistent formatting (inconsistent brace styles), lengthy method comments that add clutter, and a few awkward constructions like `String.format("%0" + Integer.toString(errorCodeLen) + "x", errorCode)`. The class is relatively flat with minimal nesting, though some logic could be extracted into helper methods. Variable names like `Code` and `Message` violate Java naming conventions. Error handling with exceptions is clear, but the use of `errorCode` as an integer with magic values (`-1`, `>0`) could be more explicit. Overall, readable but not exemplary.

Run 3

The code has clear documentation and generally follows single-action-per-line principles, but it suffers from readability issues. The structure is logical but there are logic flaws that obscure intent: in Get(), if errorCode > 0 and errorMessage is null, it concatenates 'null|' into the message; in Set(), when errorCode > 0, it calls indexOf("|") and substring without checking if the delimiter exists, risking StringIndexOutOfBoundsException. Nesting is moderate but acceptable. Methods are concise, though Set() and Get() mix parsing, validation, and message assembly. The default constructor is unnecessary and includes boilerplate template comments. Error codes are limited to 1 hex digit (0–15) but this is unclear without reading documentation. Naming is mostly clear, but 'Get' and 'Set' are vague for their complex behavior. Reading flow is hindered by scattered exception handling and ambiguous state assumptions (e.g., errorMessage defaults to null). Overall, readable enough for a small, documented class, but logic flaws and naming ambiguities reduce clarity.

Run 1

Code Structure: Methods are logically separated into header serialization, parsing, and field access, with consistent formatting. Nesting: Mostly flat conditionals and a simple try/catch make control flow easy to follow; redundant else branches could be removed. Clarity of intent: Descriptive fields and documentation explain the protocol, but generic Get/Set names, unconventional capitalization, and magic values reduce precision. Code length: Implementation is reasonably concise, though repetitive Javadoc, template comments, unnecessary initialization, and verbose substring calls add clutter. Action granularity: Statements generally perform one action per line; the formatting expression is somewhat dense. Reading flow: Validation precedes processing, and methods follow a predictable order. Reassigning input parameters and relying on implicit state and delimiter assumptions introduce some mental overhead.

Run 2

Code Structure: Well-organized class with separate serialization, parsing, and accessor methods. Nesting: Shallow conditionals and a straightforward try/catch make control flow easy to follow. Clarity of intent: Documentation explains the protocol and fields, but generic Get/Set names, unconventional capitalization, and magic values obscure some meaning. Code length: Methods are concise, although excessive Javadoc boilerplate, redundant initializations, and unnecessary else branches add clutter. Action granularity: Statements generally perform one action per line; formatting and concatenation combine several operations in one expression but remain manageable. Reading flow: Consistent indentation and sequential validation support natural reading, while parameter reassignment and reliance on superclass behavior require extra attention.

Run 3

Code Structure: Well-organized class with distinct serialization, parsing, and accessor methods. Nesting: Shallow conditionals and a straightforward try/catch keep control flow easy to follow. Clarity of intent: Descriptive fields and documentation explain the response format, but generic Get/Set names, unconventional capitalization, and implicit sentinel and delimiter conventions reduce clarity. Code length: Implementation is reasonably concise, though verbose Javadoc, obsolete template comments, redundant initialization, and unnecessary else blocks add clutter. Action granularity: Statements generally perform one action per line; formatting and substring expressions are manageable. Reading flow: Consistent layout and sequential validation support natural reading, although parameter reassignment and inherited message-processing calls require tracking state and consulting the superclass.