• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

To IDE or not to IDE

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

S

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());

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Name:");
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);

jButton1.setText("Push");
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);

pack();
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Shlomo Hillel
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?


S
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

Thanks!
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is what I thought but you never know. Thanks!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic