Site Sponsors:
UML Primer Updated 
Just a quick note to let everyone know that I just updated the UML Primer on YouTube. I wanted to increase the volume so as to re-use the video in a class we are teaching next week for the U.S. Army.

[ add comment ] ( 2081 views )   |  permalink  |  related link
Faster Field Support using Enumeration & Arrays 
The humble 'enum' has come a long way. --Indeed, when I first taught the 'enumeration concept' (i.e why use numbers, when you can use names) a few decades ago, I was using C/C++.

Today both .Net and Java have their humble 'enum' equivalent:

enum codes {
one, two, three
}

--Easy enough to understand.

Object Members


What is interesting to note however is that, unlike C/C++, any 'enum' in either Java or .Net is not merely about mnemonic substitution. Rather, the enum keyword in both technologies creates a fully-qualified Object:


public String get(codes which) {
return vals.get(which.ordinal());
}

public String set(codes which, String sWho) {
return vals.set(which.ordinal(), sWho);
}


Like any Object, any instance of 'enum' in .Net and Java has member functions. Amongst other things, by default the members of an 'enum' allow us to translate between a set of zero-based integers, as well as any enumerated token.

Enumerated Rarefactions


Since by default the enum uses a zero-based ordinal (read i-n-t-e-g-e-r ;), the use of any enumerated set of tokens readily transfers over to a zero-based array usage. The piratical :) application of this default numbering series is that any set of arbitrary enumerators can be used to quickly create a class, with just as many value-storage opportunities:

class ClientSettings {
ArrayList<String> vals = new ArrayList<String>();

public enum codes {
// We could also use enums like name, address, phone (etc)
one, two, three
}

public ClientSettings() {
codes[] set = codes.values();
for (codes code : set) {
vals.add(code.name());
}
}

public String get(codes which) {
return vals.get(which.ordinal());
}

public String set(codes which, String sWho) {
return vals.set(which.ordinal(), sWho);
}

public static void main(String[] args) {
ClientSettings ref = new ClientSettings();
if (ref.get(codes.two).equals(codes.two.name()) == false) {
System.out.println("Error - Conceptual failure #1.");
}
String sTest = "Enumerated arrays are so easy, they are scary.";
ref.set(codes.two, sTest);
if (ref.get(codes.two).equals(sTest) == false) {
System.out.println("Error - Conceptual failure #2.");
}
}

In short, no mater if we have 2 or 200 values. -Whenever we want to quickly create a class to support the storing of one or all of them, all we have to do is to update a single 'enum'. --The rest is as good (or evil ;) as is the enumerated set of tokens we choose to represent our data_stored therein.

Enjoy,

-Rn

(p.s: The above is a Java demonstration. The proof of concept is in main().)

[ add comment ] ( 2650 views )   |  permalink
Colorized JSR Listing 
We went looking for a list of active Java Specification Requests (JSRs) today. Specifically, we wanted to see which ones were okay, listed alongside of which ones were not.

We did not find what we needed, so we decided create a colorized listing of active and 'retired' JSRs for ourselves.

Submitted for your approval is perhaps the longest list we ever posted to any Wiki - let alone ours:

http://www.soft9000.com/service/noj.php?n=Java.JSR

Enjoy,

-Rn



[ add comment ] ( 732 views )   |  permalink  |  related link

<<First <Back | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | Next> Last>>