Skip to main content

Reinventing the wheel?

9 replies [Last post]
stratovarius
Offline
Joined: 2007-05-30
Points: 0

The question is, why code the graphic interface manually? (and not use gui builders, like the one that comes with netbeans or eclipse for example)

I see many people doing it. Wich are the advantages? Isn't it like reinventing the wheel?
Im sure there is an explanation, that i can't see because im new to java.

Can anyone tell me why?

Thanks.

Message was edited by: stratovarius

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
joshy
Offline
Joined: 2003-07-02
Points: 0

The reason no GUI builder does code reverse engineering is because it is impossible to do correctly. Sure, you can parse back in the code that you generated, and you can handle a few changes by the programmer; but it's very easy for the programmer to type in something that is impossible to reverse engineer. And then what do you do? Generating a declarative representation (whether in another file or in the same file as uneditable java code) is the right solution. Here's an example of something impossible to reverse engineer:

tool generates:

...
JPanel panel = new JPanel();
JButton b1 = new JButton("b1");
panel.add(b1);
...

Then the programmer modifies it to:
...
JPanel panel = new JPanel();
for(int i=0; i<100; i++) {
JButton b1 = new JButton("b1");
panel.add(b1);
}
...

How does the tool parse that and pull it back into a visual representation? And what if instead of a simple loop it depended on data that's not availble until runtime? It's an impossible problem to solve. Using a declarative format for the layout is a much better solution.

jwenting
Offline
Joined: 2003-12-02
Points: 0

> The reason no GUI builder does code reverse
> engineering is because it is impossible to do
> correctly. Sure, you can parse back in the code that

JBuilder does (or did, not sure about the latest version).
IntelliJ does.
Delphi does (OK, not Java).

> you generated, and you can handle a few changes by
> the programmer; but it's very easy for the programmer
> to type in something that is impossible to reverse
> engineer. And then what do you do? Generating a

Tell him. Either you loose 2 way development or you give him a hint as to why you don't understand him.

> How does the tool parse that and pull it back into a
> visual representation? And what if instead of a
> simple loop it depended on data that's not availble
> until runtime? It's an impossible problem to solve.
> Using a declarative format for the layout is a much
> better solution.

And why should your IDE prevent you from handcoding that if you need it?
Any IDE that doesn't give me the option to override its defaults is one that hinders my productivity instead of assisting me.

dansiviter
Offline
Joined: 2005-09-26
Points: 0

Just to throw a spanner in the works, no one has mentioned Abeille:

https://abeille.dev.java.net/

It's a cracking tool for creating layouts based on the jGoodies FormLayout. We've used this commercially for 3 years at work to generate the layout code which we then import and then cleanup the code. This cleanup in necessary to improve the readability of the code to, aid maintainability and remove the rubbish that the GUI (rarely) puts in. It's a hybrid approach to layout design.

I believe anyone who uses a GUI builder, should also be proficient in writing the GUI manually. Walk before you can run so to speak.

pdiwadkar
Offline
Joined: 2007-06-14
Points: 0

As others discussed,except NetBeans many IDEs I too found uncomfortable.

tarbo
Offline
Joined: 2006-12-18
Points: 0

Typically, most if not all of my added components are custom components with custom behaviour. Not that they require special handling--that'd be stupid, eh?--but many of them either use a more dynamic layout or have none at all (e.g. popups).

Manual coding allows for more flexibility. Need another component somewhere? If you worked more-or-less cleanly, this shouldn't be a problem, and your other components will go along nicely. Need to hide a component? Just pop it out.

That and I'm terrible at visual design and am more than happy to use a layout manager to do it for me. Using a visual design tool would be to my detriment.

But mostly, it's a matter of personal style. Some people use FrontPage or DreamWeaver, some people handcode their (X)HTML. Some people buy a car and leave it that way, others go aftermarket. It depends on what you want and what you need.

djviking
Offline
Joined: 2007-03-21
Points: 0

Many GUI builders are really crappy, but some are actually good. NetBeans has a very good one, but I do not like not to be able to change the code it generates, manually by hand.

The "old" JBuilder had a similar good GUI builder and with that one I could change the code it generated without destroying the GUI design(It reacted to the code change I did). The "new" JBuilder (2007) is based on Eclipse, and as I have seen the wounderful GUI builder is gone. Eclipse own GUI builder is far from mature yet.

jwenting
Offline
Joined: 2003-12-02
Points: 0

IntelliJ also has a pretty decent one. What I don't like though is that it stores the screen layouts you create in a separate file which is only merged with the code you write (for things like actionlisteners) during compilation or when you explicitly export the design to Java source (for an external build process).
Makes it a lot harder to work in teams with disparate tools as well as to use external build tools like ANT or Maven (Netbeans I think does something similar).

jwenting
Offline
Joined: 2003-12-02
Points: 0

> The question is, why code the graphic interface
> manually? (and not use gui builders, like the one
> that comes with netbeans or eclipse for example)
>
Because most (all??? Can't tell, there must be some I've not tried) GUI builders produce results that are pretty much useless.
Monolithic monstrosities, impossible to maintain, often poorly performant and not working properly.

> I see many people doing it. Wich are the advantages?
> Isn't it like reinventing the wheel?

No, unless the wheels that come out of the factory were all triangular but you knew they should be round to work.

stratovarius
Offline
Joined: 2007-05-30
Points: 0

Thanks for the reply.

Maybe my question is dumb, but it would be nice to have some more opinions.