Menu

WikiProgrammingTips

chesteric31

Metrics/Snippets/External links.

Metrics

JDepend

  • AC: Abstract Classes number
  • CC: Concrete Classes number
    => more that are big, more the entities are independent
  • CA = Afferent Couplings (descending) => more big => WRONG => needs to be fragment
  • CE = Efferent Couplings (ascending) => more less => OK
  • A = Abstraction
    ~0 = concrete package
    ~1 = abstract package
    ~.5 = wrong package structure
  • I = Instability
    ~0 = stable package
    ~1 = unstable package
  • D = distance => ~1 = WRONG
  • V = volatility => ~0 = kernel code
  • A good package is CE ~0, A = 1 and I = 0.

Snippets

Custom combobox renderer

private class ComboBoxRenderer extends JLabel implements ListCellRenderer {
  public ComboBoxRenderer() {
    setOpaque(true);
    setEnabled(true); 
  }

  public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    if (isSelected) {
      setBackground(list.getSelectionBackground());
      setForeground(list.getSelectionForeground());
    } else {
      setBackground(list.getBackground());
      setForeground(list.getForeground());
    }

    if (value != null) {
      setText(value.toString());
      setFont(getFont().deriveFont(Font.PLAIN));
    }
    return this;
  }
}

Using of Preferences Java API

public static void main(final String[] args) throws BackingStoreException {

        Preferences systemRoot = Preferences.userRoot();
        Preferences preferences = systemRoot.node("com/mycompany/settings");

        preferences.put("foo", "bar");
        preferences.put("baz", "lolz");
        preferences.flush();
        System.out.println("-------------------------------");

        String[] keys = preferences.keys();
        for (String key : keys) {
            System.out.println(key);
        }

        System.out.println("-------------------------------");

        keys = systemRoot.keys();
        for (String key : keys) {
            System.out.println(key);
        }
    }

MySQL

Root password configuration

mysqladmin.exe -u root -p -h localhost password "password"

XJC uses

./xjc ~/Dev/workspace-jsams/JSAMS/reports/estimate.xsd -b ~/Dev/workspace-jsams/JSAMS/src/main/resources/bindings.xml -classpath ~/Dev/workspace-jsams/JSAMS/target/classes/be/jsams/server/model/utils/xml/JsamsDateAdapter.class


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.