Lists groups design

From Emergent

Jump to: navigation, search

Contents

How to use Lists/Groups

  • DO NOT USE LISTS/GROUPS FOR PRIMARY USER OBJECTS (e.g., something that the user will interact with that has members and methods to be used in programs, etc) -- List/Group should only be used as a container, for containing things. Here are the reasons:
    • all the list members & methods obscure the relevant stuff from the user
    • the semantics are mixed and sometimes confusing
    • the gui renders lists/groups as browser things; they don't show up in edit dialogs; their members are hidden. this is consistent with their primary usage as containers.
  • Where possible, use a List instead of a Group: Groups were often over-used before, and they add a fair amount of complexity and make it more difficult to do things like synchronize across different structures, etc, because they have a more complex hierarchical structure. Really think hard before using a group. They are perfect for netstru and various other structural cases, but e.g., the columns of a datatable are much better as a list; grouping here can be achieved through the use of tags or other markers that indicate related fields (e.g., that might want to share an axis).

New Names for List/Group/Array Functions (no overloading)

Overloading of various functions was removed, with the arg type now explicitly part of the name. This was partially implemented before but in a rather haphazard way. Overloading is bad for css and also can introduce hard-to-find errors.

New Naming Scheme

  • xxxIdx -- arg is an index into the list
  • xxxName -- arg is the name of an object
  • xxxEl -- arg is a pointer to an object
  • xxxType -- arg is typedef*

Affected Functions

  • Remove -> RemoveIdx, RemoveName, RemoveEl
  • Find -> FindName, FindEl, FindType -- also, for everything except FindEl, it now *always* returns an El and the idx& is the 2nd arg -- there were two versions of this (the other returning an idx only).
  • Replace -> ReplaceIdx, ReplaceName, ReplaceEl, ReplaceType
  • Move -> MoveIdx, MoveEl

EnforceSize -> SetSize

EnforceSize is a bit elaborate; SetSize is simpler and to the point.

Personal tools