The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

HTML generation library

Hello, I'm designing an HTML generation library to be used as support for other projects. Just simple stuff. Well at the moment I'm working on the Forms functions and here's a question.

I'm keeping the elements as a list, and everything is an element (examples: <input type=text>, <input type=password>, <textarea>, <input type=submit>).

But now my question is... how useful is it to have more than two buttons (submit and reset) on a form? This isn't very common, and it would simplify the design if those were kept separated from the other elements.

If the Form class contains just the array with all elements

* We want to show everything - just loop and render each

* We just want to render the buttons - we need to loop, check if its a button and if it its, render it.

So the Form class would become

Class Form {

And we just access the buttons individually if needed. This is why I'm wondering how common it is to have more than those two buttons for the same form.

Because if eventually its more common than I think, maybe it's ok to use something like

Class Form {

Now if we need the buttons we have them separated from the other stuff. We can loop a (smaller) array and can check for "name" or "type" if we just want a specific button.


Friday, August 03, 2007
I once built something more like this:

abstractClass htmlTag
  private String tag = "";
  private Map<String, String> attributes = ...
  private List<htmlTag> childTags ...
  public String toHtml()
      open tag...
      iterate children ...
      close tag

Then anything can contain anything. Some combinations might not be valid HTML, but it's up to the builder to follow the rules.

Does that have any appeal?
Stan James
Friday, August 03, 2007
Is there any particular reason, you would like to separate buttons and other elements?

A complex form can have many buttons (Save, Cancel, Reload, Next, Previous, ...)...
Jan Hančič Send private email
Tuesday, August 07, 2007
Hello, I want the user to have more direct control over the buttons than having to loop through an array which is mostly non buttons.

Tuesday, August 07, 2007

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz