<?xml version='1.0' encoding='utf-8' ?>

<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>Java developers</title>
  <link>https://java-dev.dreamwidth.org/</link>
  <description>Java developers - Dreamwidth Studios</description>
  <lastBuildDate>Mon, 15 Mar 2021 17:49:08 GMT</lastBuildDate>
  <generator>LiveJournal / Dreamwidth Studios</generator>
  <lj:journal>java_dev</lj:journal>
  <lj:journaltype>community</lj:journaltype>
  <image>
    <url>https://v2.dreamwidth.org/188589/307169</url>
    <title>Java developers</title>
    <link>https://java-dev.dreamwidth.org/</link>
    <width>70</width>
    <height>50</height>
  </image>

<item>
  <guid isPermaLink='true'>https://java-dev.dreamwidth.org/2642.html</guid>
  <pubDate>Mon, 15 Mar 2021 17:49:08 GMT</pubDate>
  <title>Try-with-reources</title>
  <link>https://java-dev.dreamwidth.org/2642.html</link>
  <description>Posted by: &lt;span lj:user=&apos;jbanana&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/&apos;&gt;&lt;b&gt;jbanana&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You&apos;ve been able to can auto-close a closable thing for ages now. &lt;pre&gt;try(Reader r = new FileReader(/*blah*/)){
   r.whatever();
}
// r is automatically closed&lt;/pre&gt; But today I found that it works for something you already opened! &lt;pre&gt;Reader r = new FileReader(/*blah*/);
try(r){
   r.whatever();
}
// r is automatically closed&lt;/pre&gt; This came up because I had a list of files and I wanted to close each one after handling it. So I couldn&apos;t create it in the header of the try block.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=java_dev&amp;ditemid=2642&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://java-dev.dreamwidth.org/2642.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>jbanana</lj:poster>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://java-dev.dreamwidth.org/2336.html</guid>
  <pubDate>Tue, 19 Jan 2021 12:33:15 GMT</pubDate>
  <title>Multiple returns</title>
  <link>https://java-dev.dreamwidth.org/2336.html</link>
  <description>Posted by: &lt;span lj:user=&apos;jbanana&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/&apos;&gt;&lt;b&gt;jbanana&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In some languages you can write a method that returns two things, and then say something like &lt;pre&gt;a, b = getCatAndDog()&lt;/pre&gt; That&apos;s not allowed in Java. Why not? You could do something like...&lt;pre&gt;class Pair&amp;lt;T,U&amp;gt;{/*boilerplate to handle two things*/}

Pair&amp;lt;Cat,Dog&amp;gt; x = getCatAndDog();
Cat a = x.getLeft();
Dog b = x.getRight();&lt;/pre&gt; Ouch, and what if you want more than two?&lt;br /&gt;&lt;br /&gt;I have done it with &lt;code&gt;Object[]&lt;/code&gt; but that&apos;s pretty hacky, and I&apos;ve seen people return a map of names to values, but both of those are type unsafe (you&apos;d have to cast the return values).&lt;br /&gt;&lt;br /&gt;There&apos;s a syntax for multiple declarations... &lt;pre&gt;int a, b;&lt;/pre&gt; ... so that could be extended to allow multiple types: &lt;pre&gt;Cat, Dog a, b = getCatDog();&lt;/pre&gt; or with the new type inference: &lt;pre&gt;var a, b = getCatAndDog();&lt;/pre&gt; Now I&apos;m wondering how to make that proposal...&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Edit:&lt;/b&gt; The process seems to be to sign up at &lt;a href=&quot;https://www.jcp.org/&quot;&gt;jcp.org&lt;/a&gt; and submit a JSR. Bit daunting.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=java_dev&amp;ditemid=2336&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://java-dev.dreamwidth.org/2336.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>jbanana</lj:poster>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://java-dev.dreamwidth.org/2176.html</guid>
  <pubDate>Thu, 01 Oct 2020 20:14:11 GMT</pubDate>
  <title>Iteration</title>
  <link>https://java-dev.dreamwidth.org/2176.html</link>
  <description>Posted by: &lt;span lj:user=&apos;jbanana&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/&apos;&gt;&lt;b&gt;jbanana&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;small&gt;(&lt;a href=&quot;https://jbanana.dreamwidth.org/123225.html&quot;&gt;Cross-posted from my own account&lt;/a&gt; - I put it there because I forgot this community existed!)&lt;/small&gt;&lt;br /&gt;&lt;br /&gt;There are &lt;em&gt;so many&lt;/em&gt; ways to iterate in Java. &lt;tt&gt;8~(&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;Suppose that we have &lt;pre&gt;class Thing{...}
interface Processor{void process(Thing thing);}&lt;/pre&gt; We want to process each thing. How do we complete this method? &lt;pre&gt;void processAllThings(List&amp;lt;Thing&amp;gt; things, Processor p){
    // ???
}&lt;/pre&gt;&lt;ol&gt;&lt;li&gt;old skool C-style: &lt;pre&gt;for ( int i = 0; i &amp;lt; things.size(); i++ )
    p.process( things.get( i ) );&lt;/pre&gt; Bonus variant 1: &lt;pre&gt;for ( int i = 0; ; ) {
    if ( i &amp;gt;= things.size() )
        break;
    p.process( things.get( i++ ) ); // careful where you put the ++
}&lt;/pre&gt; Bonus(?!) variant 2: &lt;pre&gt;for ( int i = 0; ; ) {
    try {
        p.process( things.get( i++ ) );
    } catch ( IndexOutOfBoundsException x ) { // spot the bug
        break;
    }
}&lt;/pre&gt; Bonus(?!) variant 3: &lt;pre&gt;for ( int i = 0; ; ) {
    Thing thing = null;
    try {
        thing = things.get( i++ );
    } catch ( IndexOutOfBoundsException x ) {
        break;
    }
    p.process( thing );
}&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;You can use &lt;code&gt;while&lt;/code&gt; (but who does that?)&lt;pre&gt;int i = 0
while ( i &amp;lt; things.size() )
    p.process( things.get( i++ ) );&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;You can use &lt;code&gt;do... while&lt;/code&gt; (but who does that?)&lt;pre&gt;int i = 0
do
    p.process( things.get( i ) );
while ( ++i &amp;lt; things.size() ); // careful where you put the ++&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Still left over from before 1.2:&lt;pre&gt;Vector v = new Vector(things);
for ( Enumeration e = v.elements(); e.hasNextElement();  )
    p.process( (Thing)e.nextElement() );&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Still left over from before 1.5:&lt;pre&gt;for ( Iterator&lt;thing&gt; i = things.iterator(); i.hasNext();  )
    p.process( i.next() );&lt;/thing&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Still left over from before 1.8:&lt;pre&gt;for ( Thing thing : things )
    p.process ( thing );&lt;/pre&gt;Bonus variant for newer Java versions:&lt;pre&gt;for ( var thing : things )
    p.process ( thing );&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Arrived in 1.8:&lt;pre&gt;things.forEach(
    p::process
);&lt;/pre&gt;Bonus variant 1:&lt;pre&gt;things.forEach(
    thing -&amp;gt; p.process(thing);
);&lt;/pre&gt;Bonus variant 2:&lt;pre&gt;things.forEach(
    new Consumer&lt;thing&gt;(){
        @Override public void accept(Thing thing){
            p.process(thing);
        }
    }
);&lt;/thing&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Can&apos;t be bothered with the lambda variants this time.&lt;pre&gt;things.stream()
    .forEach(
        p::process
    );&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;Phew! Hmm - I probably missed some...&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=java_dev&amp;ditemid=2176&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://java-dev.dreamwidth.org/2176.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>jbanana</lj:poster>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://java-dev.dreamwidth.org/1979.html</guid>
  <pubDate>Sun, 09 Jun 2013 15:56:45 GMT</pubDate>
  <title>Looking for developer feedback</title>
  <link>https://java-dev.dreamwidth.org/1979.html</link>
  <description>Posted by: &lt;span lj:user=&apos;jbanana&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/&apos;&gt;&lt;b&gt;jbanana&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I have &lt;a href=&quot;http://compositor.sourceforge.net/&quot;&gt;a development framework for Swing apps called Compositor&lt;/a&gt;. Although I wrote it for my own benefit, I&apos;d be interested in feedback from other developers. Would anyone like to have a go with it and tell me how they get on?&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=java_dev&amp;ditemid=1979&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://java-dev.dreamwidth.org/1979.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>jbanana</lj:poster>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://java-dev.dreamwidth.org/1672.html</guid>
  <pubDate>Wed, 25 Jan 2012 10:50:52 GMT</pubDate>
  <title>A shot in the dark...</title>
  <link>https://java-dev.dreamwidth.org/1672.html</link>
  <description>Posted by: &lt;span lj:user=&apos;lea_hazel&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://lea-hazel.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://lea-hazel.dreamwidth.org/&apos;&gt;&lt;b&gt;lea_hazel&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I realize this community hasn&apos;t been updated in almost a year, and that it only has a few members. However, I&apos;m going to risk it and attempt a shot in the dark. &lt;br /&gt;&lt;br /&gt;I was a Java developer a few years ago and I haven&apos;t touched it in a while. I never had an IDE installed on my home computer, since I&apos;ve never needed one. Now I&apos;m suddenly feeling a strange craving to mess around and code something, for my own amusement. Can anyone recommend a lightweight, freeware IDE that I can use? I&apos;ve been thinking of maybe installing IntelliJ.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=java_dev&amp;ditemid=1672&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://java-dev.dreamwidth.org/1672.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>lea_hazel</lj:poster>
  <lj:reply-count>3</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://java-dev.dreamwidth.org/1371.html</guid>
  <pubDate>Mon, 07 Mar 2011 09:36:13 GMT</pubDate>
  <title>Mac compile error</title>
  <link>https://java-dev.dreamwidth.org/1371.html</link>
  <description>Posted by: &lt;span lj:user=&apos;jbanana&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/&apos;&gt;&lt;b&gt;jbanana&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style=&quot;overflow: auto&quot;&gt;     [java] 2011-03-07 08:57:04.693 java[399] CFLog (0): CFMessagePort: bootstrap_register(): failed 1103 (0x44f), port = 0xf803, name = &apos;java.ServiceProvider&apos;
     [java] See /usr/include/servers/bootstrap_defs.h for the error codes.
     [java] 2011-03-07 08:57:04.694 java[399] CFLog (99): CFMessagePortCreateLocal(): failed to name Mach port (java.ServiceProvider)&lt;/pre&gt; Sometimes I get that in build output on my Mac. The file it says I should see doesn&apos;t help. &lt;a href=&quot;http://netbeans-org.1045718.n5.nabble.com/CFLOG-errors-seek-HELP-td2903944.html&quot;&gt;It turns out&lt;/a&gt; that it means &quot;You are compiling while another Java process is running&quot;.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=java_dev&amp;ditemid=1371&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://java-dev.dreamwidth.org/1371.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>jbanana</lj:poster>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://java-dev.dreamwidth.org/1047.html</guid>
  <pubDate>Mon, 28 Feb 2011 16:14:31 GMT</pubDate>
  <title>Barf!</title>
  <link>https://java-dev.dreamwidth.org/1047.html</link>
  <description>Posted by: &lt;span lj:user=&apos;jbanana&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/&apos;&gt;&lt;b&gt;jbanana&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I&apos;ve been using Groovy. It&apos;s a pleasant scripting language that runs in a JVM, and has a Java-ish syntax. There are a number of differences to Java. One is it&apos;s relaxed attitude to typing, which I noticed when returning to something I wrote a while ago.

&lt;pre style=&quot;color: #000000; background: white; padding: 3px; overflow: auto&quot;&gt;
&lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; ( someCondition ) {
    &lt;span style=&quot;color: #008000&quot;&gt;// do stuff...&lt;/span&gt;
} &lt;span style=&quot;color: #0000ff&quot;&gt;else if &lt;/span&gt;( anotherCondition ) {
    &lt;span style=&quot;color: #008000&quot;&gt;// do other stuff...&lt;/span&gt;
} &lt;span style=&quot;color: #0000ff&quot;&gt;else&lt;/span&gt; {
    barf
}
&lt;/pre&gt;

WTF is &lt;code&gt;barf&lt;/code&gt;? It looks like I was roughing out the code, and intending to come back to throw some exception if neither condition is true. In Java, the compiler would have complained about &lt;code&gt;barf&lt;/code&gt;. But in the relaxed world of Groovy, the code works. After a little testing, I find that executing &lt;code&gt;barf&lt;/code&gt; produces &lt;code&gt;groovy.lang.MissingPropertyException: No such property: barf&lt;/code&gt; which is pretty much what I wanted!&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=java_dev&amp;ditemid=1047&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://java-dev.dreamwidth.org/1047.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>jbanana</lj:poster>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://java-dev.dreamwidth.org/886.html</guid>
  <pubDate>Tue, 04 Jan 2011 15:10:05 GMT</pubDate>
  <title>Logging</title>
  <link>https://java-dev.dreamwidth.org/886.html</link>
  <description>Posted by: &lt;span lj:user=&apos;jbanana&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/&apos;&gt;&lt;b&gt;jbanana&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I love logging. In many ways it&apos;s more useful than a debugger. Long ago I wrote a simple logger, and I still use it, or nowadays Java has a built-in logger, and in my experience it&apos;s fine.&lt;br /&gt;&lt;br /&gt;But I hate Log4J. There&apos;s one straightforward reason: by default, Log4j does &lt;em&gt;nothing useful&lt;/em&gt;. I couldn&apos;t count the times I&apos;ve seen &quot;Please initialize the Log4J system correctly&quot; as if it were my fault. It&apos;s a logger doesn&apos;t log!&lt;br /&gt;&lt;br /&gt;Another reason is that to specify a daily rolling log file (which is almost &lt;em&gt;always&lt;/em&gt; what you want) requires 5 (or more) lines of configuration.&lt;br /&gt;&lt;br /&gt;So here&apos;s a rule for writing any software. Do the simplest useful thing by default, and make the most likely use cases as simple as possible. Log4J fails on both counts.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=java_dev&amp;ditemid=886&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://java-dev.dreamwidth.org/886.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>jbanana</lj:poster>
  <lj:reply-count>1</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://java-dev.dreamwidth.org/517.html</guid>
  <pubDate>Thu, 21 May 2009 16:51:03 GMT</pubDate>
  <title>Anti-pattern</title>
  <link>https://java-dev.dreamwidth.org/517.html</link>
  <description>Posted by: &lt;span lj:user=&apos;jbanana&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/&apos;&gt;&lt;b&gt;jbanana&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I&apos;m working on a project which involves a lot of JSP in an &quot;interesting&quot; CMS. We have a consultant helping us with the &quot;interesting&quot; bits. Today he gave us a JSP containing the following (some details elided to protect the guilty): &lt;pre&gt;String sql = &quot;SELECT * FROM tree WHERE id in (
	SELECT parent FROM tree WHERE id=&quot; + parent + &quot;)&quot;;
parents = cms.SQL ( sql );&lt;/pre&gt; I&apos;d like to propose this for the canonical example of what *not* to do.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Edit:&lt;/b&gt; Many people dislike JSPs. They don&apos;t bother me, but they do allow you to do anything at all, not just rendering. In this particular case, the JSP has to know about the database table structure [sigh], and it should (but probably doesn&apos;t) sanitise the &lt;code&gt;parent&lt;/code&gt; parameter [sigh], and it has to have a database connection wrapper object [sigh].&lt;br /&gt;&lt;br /&gt;I&apos;m even a little miffed about pointless local variable &lt;code&gt;sql&lt;/code&gt;, but I&apos;ll let that one go. Oh, and KEYWORDS in UPPER case annoys me too, but some people think it&apos;s more readable.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=java_dev&amp;ditemid=517&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://java-dev.dreamwidth.org/517.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>jbanana</lj:poster>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://java-dev.dreamwidth.org/441.html</guid>
  <pubDate>Wed, 06 May 2009 22:30:52 GMT</pubDate>
  <title>Hello.</title>
  <link>https://java-dev.dreamwidth.org/441.html</link>
  <description>Posted by: &lt;span lj:user=&apos;jbanana&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://jbanana.dreamwidth.org/&apos;&gt;&lt;b&gt;jbanana&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is a community for anyone writing Java code.&lt;br /&gt;&lt;br /&gt;After enjoying the java_dev community on LJ so much, I thought there should be a DW place for people who write Java. This is it.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=java_dev&amp;ditemid=441&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://java-dev.dreamwidth.org/441.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>jbanana</lj:poster>
  <lj:reply-count>0</lj:reply-count>
</item>
</channel>
</rss>
