Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just saw a demonstration of Zen Coding. I think it's a great investment on productivity, however my work is 99% backend data processing via Java.

So far I only know templates in Eclipse like sysout and foreach (then hit CTRL+SPACE in MS).

Is there more Zen Coding for Java?

share|improve this question

closed as off-topic by MichaelT, Scant Roger, Ixrec, GlenH7, Bart van Ingen Schenau Jan 11 at 18:43

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to find or recommend tools, libraries, programming languages, resources (including books, blogs, tutorials, and examples), or projects to undertake are off-topic on Programmers as they attract opinionated answers that won't have lasting value to others. You may be able to get help in The Whiteboard, our chat room." – MichaelT, Scant Roger, Ixrec, GlenH7, Bart van Ingen Schenau
If this question can be reworded to fit the rules in the help center, please edit the question.

    
you can add templates to eclipse, though it can be a pain for some non trivial stuff – ratchet freak Jun 11 '13 at 19:36
    
@JonBecher Please don't use backticks for emphasis, they are only meant for inline code. – Yannis Jun 11 '13 at 20:04

I may be wrong, but "Zen Coding" is meant to be more useful for languages where you have a high level of nested elements in a structure (LISP, anyone?!).

As a simple case of HTML, you may have an example as follows:

<div id="page">
    <div class="logo"></div>
    <ul id="navigation">
            <li><a href=""></a></li>
            <li><a href=""></a></li>
            <li><a href=""></a></li>
            <li><a href=""></a></li>
            <li><a href=""></a></li>
    </ul>

Using the concept of Zen Coding, this can be shortened to something as follows:

div#page>div.logo+ul#navigation>li*5>a

This allows you to type much less code, but have it automatically expand your string of text into an editable code block, so that you don't need to go through the process of additional brackets, tags, etc., in order to get the expected output.

In the case of Java, for example, your code should be much less nested, and more "flat", using classes, methods, etc., in order to achieve the same result. Example, if you have a block of Java code that looks like this:

public static void main() {
    private int x = 1;
    while (x < 10) {
        if (x < 5) {
            for (int i = 0; i < 100; i++) {
                switch(i) {
                    case 1:  //Do Stuff here
                    case 2:  //Do more stuff
                    default: //Do more complex nested stuff here
                }
            }
        }
        x++;
    }
}

You should look at restructuring the above code into a much more managable, less nested block of code, rather than trying to shorten up the typing of the code by attempting to do some shorthand like:

public/static/void/main>while(x<10)>if(X<5)>for(new(i[0..100]))>switch[1/2/Default]
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.