Sean
McCormack, maker of the Zanebug NUnit GUI, also has a code
generation tool called Codus.
Some of the sweet things about Codus is the auto generation
of data access objects, strongly typed collection classes, mock objects, nunit
tests, zanebug tests, as well as web services that match the generated data
access objects. There is built-in support for Access and SqlServer,
however in his DbType enumerator, I saw options for MySql, DB2, and Oracle, but
I didn’t see these as options in his front end application, so maybe he is
working on adding those dbs.
I really love the feature that is has where it makes a VS
solution file, and opens it up for you; so from clicking the ‘Generate’ button,
your next step is to fire up NUnit (or Zanebug) and run the brand new tests on
your brand new objects! Pretty cool stuff….
Using generics you could definitely trim the number of lines
of code needed, especially in the collection classes, without sacrificing any of
the advantages of being strongly typed. Here is one of my collection
classes, using generics, which contains around 30 lines of code, but it has all
the functionality of CollectionBase. It inherits from another custom class
cObjectCollection<T> that contains other custom implementation,
QuickSort(), Filter(), Serialize(), etc.. This is the ArtistCollection
class for our music management software.
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">using
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
System;
/>
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">using
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
System.Collections.Generic;
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">using
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
System.Configuration;
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">using
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
System.Text;
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">using
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
Ben;
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">namespace
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
Ben.Data
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">{
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="mso-spacerun: yes">
style="COLOR: blue">public
class
style="COLOR: teal">ArtistCollection :
style="COLOR: teal">cObjectCollection<
style="COLOR: teal">Artist>
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="mso-spacerun: yes"> {
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="mso-spacerun: yes">
public
style="COLOR: teal">ArtistCollection() :
style="COLOR: blue">base()
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="mso-spacerun: yes">
{
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="mso-spacerun: yes">
ConnectionString = Setting(
style="COLOR: maroon">“DSN”);
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="mso-spacerun: yes">
DatabaseType =
style="COLOR: teal">DbAgent.ParseDbType(Setting(
style="COLOR: maroon">“DbType”));
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="mso-spacerun: yes">
ConnectionType =
style="COLOR: teal">DbAgent.ParseConnectionType(Setting(
style="COLOR: maroon">“ConnectionType”));
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="mso-spacerun: yes">
IdField =
style="COLOR: maroon">“ArtistID”;
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="mso-spacerun: yes">
TableName =
style="COLOR: maroon">“Artist”;
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="mso-spacerun: yes">
ParentIdField =
style="COLOR: maroon">“GenreID”;
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="mso-spacerun: yes">
}
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="mso-spacerun: yes">
public
style="COLOR: teal">ArtistCollection(
int
genreId) :
this()
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="mso-spacerun: yes">
{
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="mso-spacerun: yes">
ParentId = genreId;
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="mso-spacerun: yes">
}
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
style="mso-spacerun: yes"> }
style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none">
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">}