Site Sponsors:
Publishing VB.NET Training on YouTube 
"Designed for the total beginner, this VB.NET Boot Camp is the first segment of a multi-part presentation. In this first session, we will discover how to write Visual Basic .NET (VB.NET) Programs from the console - other tools not required!

(video)

Targeted to help new software developers get started writing their own software, this first session also includes a light overview of the software development and testing process."

Enjoy,

-Rn




[ view entry ] ( 1902 views )   |  permalink  |  related link
C++ - The Novel 
I was reminded the other day that not everyone has decades of C/C++ experience behind them.

For the benefit of those who tend to think that mastering an API (let alone OO!) is beyond them, I have a book to go along with my C/C++ Project.

Without further elaboration (you know who you are!) here is The Joy of C++.


[ view entry ] ( 2136 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().)

[ view entry ] ( 3174 views )   |  permalink

<<First <Back | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Next> Last>>