Sample

Schnappinger/diarymanagement/TBA.Messages.QueryMessage

Human rating uses the original dataset scale.

Human3.98
Lines124

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett0.9920–1; higher is more readable
90.6Δ 3.2
Scalabrino0.9080–1; higher is more readable
91.1Δ 3.6
Dorn0.4190–1; higher is more readable
56.8Δ 30.7
Mi0.7380–1; higher is more readable
89.8Δ 2.3
LLOC26Logical lines; fewer is more readable
52.3Δ 35.1
DeepSeek V4 Pro15.330–20; mean of three runs
41.3Δ 46.2
GPT-6.1 Sol16.670–20; mean of three runs
48.0Δ 39.4
BTTF0.6010–1; higher is more readable
57.4Δ 30.0
Human3.981–4; original rating
87.5

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 query messages between the client and * the server. It handles the 'query Header' section of the message only. *<p> * @author Dan McGrath * * @version $Rev:: 247 $ $Date:: 2009-10-23 #$ */ public class QueryMessage extends Messages { private String queryType = null; private final int queryTypeLen = 8; /** * Constructor does nothing */ public QueryMessage() { } /** * The Get() Method adds the 'Query 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 protected String Get(String childMessage) throws MessagesException { String message = null; if(queryType == null) { throw new MessagesException("Query Type not set"); } message = String.format("%1$-" + Integer.toString(queryTypeLen) + "s", queryType); if(childMessage == null) { childMessage = ""; } super.SetMessageType('Q'); return super.Get(message + childMessage); } /** * The Set() Method takes a Message and strips out the 'Query Header' * information, returning the rest of the message back so that it can then * be processed. *<p>s * @param message The message as recieved. *<p> * @return The message without the 'Query 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() < queryTypeLen) { throw new MessagesException("The Query Header is incomplete"); } queryType = message.substring(0, queryTypeLen).trim(); message = message.substring(queryTypeLen, message.length()); return message; } /** * This method returns the 'Query Type' field. You must have called either * Set() or SetQueryType() first. *<p> * @return The Query Type *<p> * @see #SetQueryType(java.lang.String) */ public String GetQueryType() { return queryType; } /** * This method allows you to set the Query Type field. *<p> * @param Type The Query to set *<p> * @throws MessagesException *<p> * @see #GetQueryType() */ public void SetQueryType(String Type) throws MessagesException { if(Type == null) { queryType = null; throw new MessagesException("The Query Type is null"); } else { queryType = Type; } } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Source linesThe number of non-empty source lines.124+49.6
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.1417.446−46.776
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.607−6.91

Intercept 8.87 + feature contributions = 4.784 (log-odds).
Score = sigmoid(4.784) = 0.992.

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.123−3.319
Indentation frequencyHow rapidly indentation changes from line to line.73+1.788
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.122.764+1.306
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.73−1.254
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.87.274+0.604
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.042+0.538
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.87.935−0.059

Intercept 0.07 + feature contributions = -0.326 (log-odds).
Score = sigmoid(-0.326) = 0.419.

Score0.738
Score26
Run 1

The code demonstrates moderate readability with clear documentation and logical organization. The class has a single responsibility (handling query headers), methods are well-documented, and the naming conventions follow Java standards. However, several issues reduce readability: method names violate Java conventions (Get/Set should be get/set), the code is unnecessarily verbose with redundant else branches and null checks, and the overall length could be reduced. The nesting is minimal and action granularity is acceptable. The templated comment at the top ('To change this template...') indicates leftover boilerplate. Empty constructor documentation adds noise. The reading flow is generally natural but disrupted by excessive comments that state the obvious. Overall, the code is functional and maintainable but would benefit from modern Java conventions and reduced verbosity.

Run 2

The code is generally well-structured with clear separation of methods and good documentation. It uses minimal nesting, mostly guard clauses for validation. Intent is clear through descriptive method names like Get/Set for message serialization/deserialization. Code length is appropriate, though some methods could be slightly more concise. Action granularity is good—one logical action per line. Reading flow is natural with consistent naming conventions. Minor deductions: the SetQueryType method's if-else could be simplified to a single guard clause for consistency with Get(), and the default template comment at the top adds noise. The queryTypeLen as int rather than constant is a slight style issue. Overall, highly readable code.

Run 3

The code is fairly readable: it has clear class structure, flat nesting, and descriptive method names like Get, Set, GetQueryType, and SetQueryType. JavaDoc comments explain intent well. Each method performs a focused action, and lines are generally short and purposeful. However, readability suffers from inconsistent naming conventions (Get/Set methods for message processing are vague), mixed responsibilities (null handling in SetQueryType is awkward), and the leftover auto-generated template comment at the top is distracting. Some logic, like the string formatting in Get, could be clearer. Overall, it is maintainable but would benefit from more explicit method names and cleaner boundary checks.

Run 1

Code Structure: Methods are logically separated into header serialization, parsing, and field access. Nesting: Shallow conditionals and early exceptions keep complexity low, although SetQueryType has an unnecessary else. Clarity of intent: Descriptive fields, exception messages, and documentation explain the purpose, but generic Get/Set names and unconventional Java capitalization reduce clarity. Code length: Implementation is short, but verbose Javadoc, template comments, redundant null initialization, and explicit conversions add clutter. Action granularity: Statements generally perform one action per line, making operations easy to follow. Reading flow: Consistent formatting and straightforward validation-to-processing sequences support natural reading; repeated comments, reassignment of message, and superclass dependencies introduce minor friction.

Run 2

Code Structure: Methods are logically separated into header serialization, parsing, and query-type access. Nesting: Shallow conditionals and early exceptions keep control flow simple, though the final else is unnecessary. Clarity of intent: Descriptive fields, exception messages, and documentation explain the purpose, but generic Get/Set names and nonstandard capitalization reduce immediate clarity. Code length: Implementation is compact, while verbose Javadoc, template comments, redundant initialization, and unnecessary substring arguments add clutter. Action granularity: Statements generally perform one action per line, making operations easy to follow. Reading flow: Consistent formatting and sequential validation and processing support natural reading, although repeated documentation markup and reassignment of input parameters slightly interrupt it.

Run 3

Code Structure: Well-organized class with distinct methods for serialization, parsing, and field access. Nesting: Shallow conditionals and early exceptions keep control flow simple; the final else is unnecessary. Clarity of intent: Documentation and descriptive fields explain the query-header purpose, although generic Get/Set names, unconventional capitalization, and the parameter Type reduce clarity. Code length: Methods are concise, but verbose Javadocs, template comments, redundant initialization, and unnecessary substring arguments add clutter. Action granularity: Statements generally perform one action per line, making operations easy to follow. Reading flow: Serialization and parsing proceed in a logical sequence with consistent formatting, though repeated documentation markup and minor typos interrupt reading.