tags:

views:

1618

answers:

12

My company software has a lot of forms, till now we wrote the code by hand (MVC way).

We consider start using GUI builder.

There are few problems with using a Builder.

  1. Parts of the code are not readable.
  2. Parts of the code are not editable.
  3. It will be harder to edit the code later.
  4. We will have to continue using the builder in the futre, even if we want to replשce builder or write by hand, and no one can assure that the tool will be available and supported in the future.

I want to learn from others experience:

  • Do you recommend using tool or should we continue write code by hand?
  • Wich builder is better?
  • How does he deal with the problems? (Is there any other problems?)
+5  A: 

By using a good builder the development will be a lot faster.

The anxiety you have of not being able to modify the code may be due to you have a lot of logic in the view where it does not belong. Actually this change may help you to move logic from the view which is good precisely for the ability to change the visual elements with out breaking the code.

As per the "unreadable" you should consider use a better GUI generator. I've heard only positive things about NetBeans, and I have used IntelliJ GUI builder whose code is pretty clean.

On both the source code is readable and editable, but only for minor tweaks. For major ones, well use the GUI builder.

I think for a small number of forms, there is no problem in proceeding by hand, but since you have "many of them" as you just said, using this tools will be most beneficial.

OscarRyz
+8  A: 

For just a few forms I recommend using a Builder. It will get the done way faster. However, if you have a lot of forms that you need to maintain for some time, I recommend against a builder. For this case the time you spend in reading the code and maintenance is much larger than the initial design time. So, while the builder saves you some time at the initial phase, it makes code reading and maintenance more difficult. More over, it makes code re-use, even in the form of copy and paste from one form to another, more difficult.

I don't know if you are referring to web or desktop applications, but in general I haven't found a Java Gui builder that produces elegant output. Netbeans Swing generated code for example is a mess. Perhaps, if a nice builder were available I would change my mind. I had no problem using Visual Studio's form designer - it produces nice code that you can read and understand.

For desktop applications have a look at MiGLayout. It's a layout manager, not a builder, for Swing and SWT that will make your life easier.

kgiannakakis
I agree, netbean swing code give me headaces
Midday
+1  A: 

I personally am a fan of separating the GUI layout from the code (otherwise you end up with the problems you just mentioned). It also seems to be the trend: Microsoft has their XAML, you keep hearing about different view engines for MVC, etc.

Why not go with XML-based GUI design? You could try out something like JFormDesigner which can handle both XML and code-generated layouts.

Filip
+2  A: 

We do it by hand, but with a library helping us with the layout (JGoodies Forms) and so on. Further we use a set of predefined components we plug into our UI (Jide). Works out well for us.

boutta
+3  A: 

This is my experience:

I never liked the code the GUI builder generated. At least, it's not like in the VB world that everyone (well, almost) will use the same IDE for building apps. In Java, people use several IDEs, and some use VIM and Notepad too. And all IDEs don't generate the same kind of code. And another problem is, they don't usually understand the code generated by other IDEs. So to answer your 1st question, I don't recommend.

Your next question: Which builder is better? The last time I used, Netbeans was better than most of them I tried.

If you must use a GUI builder because you need to develop applications faster, then make sure all of your team members are using the same builder. It's better to get their opinion on this, otherwise their eyes are gonna get hurt by the IDE generated source code.

Let us know your decision!

artknish
Well, the thing about the VB/C# GUI editor in Visual Studio is that when you drag a control around, all it's doing is setting the left, top, width, and height properties. Java GUI editors tend to use LayoutManagers instead (I'm looking at you NetBeans). P.S. You can actually see what code the VS Form editor outputs by looking in the designer file for a form.
R. Bemrose
+1  A: 

I've been doing both recently - I'm using Netbeans, and was initially frustrated by the lack of control of generated code. I then discovered that you can add custom code from the GUI builder, which overcame most of the issues. However, I became more frustrated by the layout manager in NetBeans, and found this was hurting my productivity more than anything. I've switched to using MiGLayout and doing most of the coding by hand now. Having said that, NetBeans overall is pretty good, and perhaps I should have spent more time learning the GroupLayout.

If you are doing team development, make sure you are all using the same tool if relying on a GUI builder.

Miles D
+2  A: 

I've used many GUI designers over the years (for different languages): Delphi, Visual Studio, JBuilder, Netbeans.

The quality of code they produce and the volume is important. Delphi was fantastic, it produced small amounts of code relative to the form size and the code was easily understandable and the two-way tools allowed you to change generated code with confidence. This was helped by a simply understood GUI library. VS produces reams of code and you do get scared to change it.

Java is partly let down by the language, no delegates or closures and so event based code can quickly become a sprawl.

I would knock up simple stuff with Netbeans Matisse and - once confident - hand code them. The complex stuff is worth planning out and hand coding so that you get your model defined well.

It helps if you build a library of your own GUI components that you can re-use. This is relevant to all languages with GUI libs.

Fortyrunner
+2  A: 

For systems with a lot of simple forms, I've tended to go the XML route -

  • define XML files for the information and any work flow for each form
  • create XSLT to generate Java/XHTML/whatever code to run the forms on desktop PC/mobile/web
  • also create XSLT to generate source code data objects etc.

You can use XForms and implementations thereof, but usually I've been working in places where buying in solutions takes longer than building your own simple XSLT. It generally takes a week to get everything up and running if there aren't too many specialised widgets in the forms. If you make your own code generators, you have full control. If you find you want to switch all your forms from scrolling up/down to be presented in columns, then there is just one place you have to change, rather than changing each form's implementation. (though you could make a framework to abstract form information from presentation in Java, it's not well suited to such declarative programming)

Pete Kirkham
Doing it directly in java with a fluent interface is a much better idea. Even if it is not as good at it as, e.g smalltalk, it is much easier to extract user interface abstractions in code and eliminate duplication
Stephan Eggermont
+1  A: 

If you have not too complex forms to build, then you could take a look at DesignGridLayout, it is Swing LayoutManager with a fluent API that makes it very easy to write code for your form and easy to read this code (and maintain, I mean modify if needed) and visualize the form through the code.

With DesignGridLayout, one row of components in your form is one line of code. No XML, full compile-time safety. No hard-coded spacing values, alignment... DesignGridLayout handles it all for you.

Short learning curve and as quick to layout a form as a GUI designer!

From the time I have discovered it about 2 years ago, I have used it exclusively (I always have been allergic to GUI designers because of the terrible generated code). That was the reason why I took over the project 8 months ago, because I wanted to give it full potential.

jfpoilpret
+1  A: 

http://swixml.org/

l_39217_l
A: 

I've used Netbeans in the past to build GUI code and used Eclipse to write the program logic. Just include the GUI code as a separate LINKED source folder.

Chris Nava
+1  A: 

I would stay away from gui builders. In my experience(matisse) you end up spending just as much time writing gui's with the builder by hand, if not more. Due to trying to read the generated code, and clean it up, when making changes. Also if you write the gui's by hand you will have to understand the code in order to write the gui, and this will help overtime to become more proficient, and you will get faster at writing gui's, and you will be faster and hand writing them. Over time you can also develop a component library for gui functionality you find yourself writing multiple times. I would stay away from builders. A good developer will beat an average developer with a builder any time.

broschb