14
\$\begingroup\$

In this Wolves, Goats and Cabbages in Java question (here is a link to the pre-edited version), Java code is presented to solve the problem.

The code requires pre-processing by a third-party tool in order to function.

The third-party tool adds a number of 'template' or 'boilerplate' methods that make the code complete. In Java terms, these are things like getters, setters, toString(), equals(), and hashCode().

Without pre-processing the code, it is:

  • full of errors, and will not compile.
  • comprehensively broken in 'standard' IDE's like Eclipse, IntelliJ, Netbeans, etc.

In order to pre-process the code, you need to download the pre-processor, as well as plugins for the various IDEs so that they are modified to accommodate these pre-processor annotations.

These downloads are from a non-official site, and are not part of any standard tool-chain.

For example, from the question we have the interface Action, and the class ActionImpl:

import java.util.Collection;

public interface Action<T> {

    Action<T> previous();

    T data();

    Collection<Action<T>> children();

    void children(Collection<Action<T>> children);

}

and

@Accessors(fluent = true, chain = false)
@Data()
@EqualsAndHashCode(of = "data")
@ToString(of = {"data"})
public class ActionImpl<T> implements Action<T> {

    private final Action<T> previous;
    private final T data;
    private Collection<Action<T>> children;

}

In Java terms, the ActionImpl class is missing four methods:

  • previous()
  • data()
  • children()
  • children(Collection<Action<T>>)

Additionally, there are compile/IDE errors for all the @Annotations which do not exist.

This makes the class fail to compile, and, essentially, there is nothing to review ;-)

Question:

Is it working code, or is it off-topic?

\$\endgroup\$
17
\$\begingroup\$

What is code but instructions to a compiler?

Would we allow an obscure language that no one here has a compiler to? I would hope the answer is yes. You might not be able to answer it but another person might.

I can currently think of more than one example that we would accept but requires an extension/plugin. is one that I personally use. It requires "pre-"processing" of a sort and compiles to . Unless I have missed some important clue I don't personally see a difference here.

I would suggest that the normal language tag alone in this case is incorrect. Further tagging it with the extension/pre-processor/whatever tag.

I'd vote for On topic.

\$\endgroup\$
16
\$\begingroup\$

I agree with @JamesKhoury.

The GNU GPL defines "source code" as "the preferred form of the work for making modifications to it". For the author of the question, that means the version of the code with the meta-programming annotations.

It does not make sense to review the post-processed form of the code, because we would then be critiquing auto-generated code, which isn't something that the author has full control over. (As an extreme analogy, consider CoffeeScript. You wouldn't compile it into JavaScript, then review the JavaScript.)

We gladly accept code that requires the various CSS preprocessors. We would also accept Perl code written using Moose — a similarly transformative third-party library for meta-programming. The objection, I believe, is not to the fact that the code requires a preprocessor, but that this particular preprocessor is (currently) obscure. Although it is a third-party dependency, it's not a particularly onerous one: the preprocessor is MIT-licensed, and all you have to do is include it in your classpath when compiling. In that sense, it is not any more of an inconvenience compared to other dependencies such as Apache Commons or Joda Time.

As for that particular question, I believe that replacing the original code with the post-processed code was an invalid edit.

If you don't like the Lombok preprocessor, you could create a tag so that you can choose to ignore such questions in the future. Now that the question has been replaced with post-processed code, though, taking that option would make a further mess of things.

\$\endgroup\$
  • \$\begingroup\$ As an opposing point, the statement "...all you have to do is include it in your classpath when compiling..." is woefully understating the issue. You need to 'install' the preprocessor as an extension to Eclipse (whatever IDE you use), and you need to run pre-processing steps before you can 'just compile it'. \$\endgroup\$ – rolfl Mar 13 '14 at 3:05
  • \$\begingroup\$ Put a different way, you need to reconfigure your development environment to review the code. This includes your IDE, and your compile tool-chain. That is in addition to adding a jar to the classpath for the code you are going to review.... unless you are already familiar with the pre-processor, and you don't need to compile/test the code to review it. \$\endgroup\$ – rolfl Mar 13 '14 at 3:09
  • \$\begingroup\$ Lombok claims, On javac: Include lombok.jar on the classpath as you compile. That's all there is to it! If your IDE introduces complications to that simple process, that's your own problem, and you're free to choose a different question to review. The code in the question is still valid. \$\endgroup\$ – 200_success Mar 13 '14 at 3:35
  • 2
    \$\begingroup\$ Reviewing Python code doesn't require installing Python. If you're familiar with the language you can review it regardless. If you're not familiar with the language the python tag helps exclude such questions. I think a lombok tag is the way to go, so only people who are already comfortable reviewing lombok code will consider such questions. \$\endgroup\$ – trichoplax Mar 16 '14 at 0:45
11
\$\begingroup\$

It is on-topic, however I would remove the tag.

At least for all the questions I ruthlessly remove the tag, it is not JavaScript! Tags should reflect the language of the code, not the language that is about to be generated.

\$\endgroup\$
  • 1
    \$\begingroup\$ But this question is still recognizably Java. It just uses a few third-party annotations, that's all. \$\endgroup\$ – 200_success Mar 14 '14 at 6:57
  • \$\begingroup\$ @200_success It is not Java if it does not compile without the preprocessor, I would agree with you if the code compiled but missed some features because of annotations not being interpreted. \$\endgroup\$ – konijn Mar 14 '14 at 12:34
  • \$\begingroup\$ I agree with removal of the Java tag. Objective-C is just C with a really stronk pre-processor. The first thing that happens to any Objective-C source code is that it's pre-processed into C source code, but you don't see Objective-C questions being tagged C... Xcode will even generate the C-version of the code it's about to be compiled, I believe. \$\endgroup\$ – nhgrif Jul 28 '14 at 22:05
4
\$\begingroup\$

It's been almost two days and still can't find out how the code is working(?). It might be that I'm not very familiar with Java8. Still I would say the question is on-topic. Why?

To quote palacsint

See also: Effective Java, 2nd edition, Item 47: Know and use the libraries (The author mentions only the JDK's built-in libraries but I think the reasoning could be true for other libraries too.)

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .