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">}
breichelt said,
Wrote on January 29, 2005 @ 10:30 am
Anonymous said,
Wrote on January 29, 2005 @ 3:17 pm
I just downloaded this and ran it on an app I’ve been working on rewriting. All the o/r stuff is blackboxed and I can get a full dataset in two lines of VBnet code. Sweet!
Anonymous said,
Wrote on January 30, 2005 @ 3:30 pm
Ben,
Thanks for the kind comments! As you mentioned, I’m working on adding support for some of the other databases. I initally planned on doing it in the 1.3 release, but due to feedback, I’m going to try and push at least Oracle up to 1.2.
The next release (1.1) will support stored procedures and creation of an NAnt build file, along with several enhancements. I’m hoping to get the beta out within the next two weeks.
Please let me know if you have any feature requests or bugs that you run into! (smccormack <at> adapdev.com)
Sean
breichelt said,
Wrote on February 5, 2005 @ 5:20 am
Interesting finds this morning (and yesterday)
Anonymous said,
Wrote on February 5, 2005 @ 10:03 pm
good job!