File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes To IDE or not to IDE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "To IDE or not to IDE" Watch "To IDE or not to IDE" New topic

To IDE or not to IDE

Shlomo Hillel

Joined: May 20, 2006
Posts: 14
I'm thinking of using an IDE for the gui construction.
I use a null layout and put the components where I want them. Then I
switch to a gridbag layout and get the source code generated.
JBuilder produces code that is clearly generated from an IDE.
However, Sun studio 8 produces code, with few refactoring, can be mistaken for a programmer written rather than computer generated.
For example, see below.

Can I use this approach? It makes life much easier than designing by hand.

Please let me know.


Generated code:

java.awt.GridBagConstraints gridBagConstraints;

jLabel1 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();

getContentPane().setLayout(new java.awt.GridBagLayout());

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.ipadx = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(40, 50, 0, 0);
getContentPane().add(jLabel1, gridBagConstraints);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.gridheight = 2;
gridBagConstraints.ipadx = 104;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(40, 26, 0, 81);
getContentPane().add(jTextField1, gridBagConstraints);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.ipadx = 18;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(70, 36, 69, 0);
getContentPane().add(jButton1, gridBagConstraints);

Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11607

Hi Shlomo,

One of the reasons for the assignment is to learn the APIs and what they are doing. Using code generators will not help you learn, and you will not be able to debug the code that is written.

The 38 lines you displayed above look very generated to me. I could rewrite them as the following 23 lines:Try it out - you should see that I have the same screen as you, while removing nearly 40% of your code! However I only did that to prove a point - in reality I would have to add two lines to make this usable in any way (but then, your code is not usable as it stands either ).

More importantly though, is that by using the IDE to generate the code, you may not ever learn what is truly necessary and what is a waste of resources. A clasic case of this is the creation of a new GridBagConstraint for each item in your example - this is a waste of resources because the GridBagLayout clones the GridBagConstraint instance when you call add(). So you are throwing away the old instance for no reason, then setting values in the new instance that were already set in the old instance! How would you ever learn this if you are just using the generated code?

Even with the code as it currently stands is questionable in my opinion. There are a lot of magic numbers in there, many of which do not appear to be human generated. I would expect the numbers themselves to be saner, and to have them as constants in the class. So, lets try again ... something that I dont think is so generated:Hmmm, down to 20 lines, and definately not looking generated now. But also not looking anything like your original code. Note that my padding is much smaller than yours, but you can still see how it might work.

Regards, Andrew
[ June 16, 2006: Message edited by: Andrew Monkhouse ]

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Shlomo Hillel

Joined: May 20, 2006
Posts: 14
Thanks Andrew for your reply.
I care less for learning how to make a dialog box with controls.
As long as I get the result I want why should I care??
Java is inefficient as it is! Who cares about few bytes here and a couple of cycles there? BTW, I noticed the constraint thing and it was on my agenda for disguising the code.

I still would like to know if anyone think that my submission WILL/MIGHT be rejected because it might've been generated?

Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
If you're so negative about Java why are you interested in this certification at all?
You'd be better off spending your time on something else, say Perl or C++ certification.

If your work is obviously generated it WILL be rejected. Read the assignment requirements, it mentions as much.

What I did was use JBuilder to create a prototype, then essentially rewrite that by hand to do what I wanted it to.
Some of the code is clearly inspired by the way JBuilder does things, but it's also clearly not created by it.

Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
My assigment says very clearly that I MUST submit only code created by myself. I guess yours, likewise, says something like this

There is nothing wrong in using an IDE, as long as you write all the code.

Now if you want to know if it is a good idea to try to deceive Sun reviewer by means of using a GUI generator to simplify your life, my adivise is: do not do it.

The idea of the assigment is that you prove that you have the skills to write an application using the JDK alone, writing your own code. Hence, code generators are not allowed.

For me, this represent a challenge, whether in real life I use a GUI designer or not.

Good luck, comrade!
[ June 16, 2006: Message edited by: Edwin Dalorzo ]
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
Literally, the assignment says"
You are permitted to use any IDE tool you choose, but you must not submit any code that is not your own work.

I read that to mean that any code generated by software or hardware, as well as code created by other people (of whatever species or race, so your codemonkey cannot write code for you) is not allowed for submission.
Anton Golovin
Ranch Hand

Joined: Jul 02, 2004
Posts: 476
Shlomo, Java is a good language. It is not as fast as C++, maybe, but it is mostly meant for large, persistent systems that require one loadup and then run for as much time as possible.

Building enterprise applications in Java is much easier than in C++ because Java is network-centric to a greater extent.

Otherwise, I think C++ is a more powerful language myself. However, Java has become pretty good.

Anton Golovin ( SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
John Deal

Joined: Sep 07, 2006
Posts: 20
I am about to start my project and was wondering about the IDE issue. I am used to using Eclipse which does not produce "design" code but if you use it to create a class will produce code like:

class Blablabla {


Not much but the main benefit is the debugger which is very useful. Would this be considered not my own code?


SCJP 1.4, SCJD 1.5
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
No. Besides, there's no way to detect that as it's identical to what a human would write.
But any real code generators (like GUI designers and things like tools that generate java code from database tables and stuff) is definitely NOT allowed.
John Deal

Joined: Sep 07, 2006
Posts: 20
That is what I thought but you never know. Thanks!
I agree. Here's the link:
subject: To IDE or not to IDE