Wiki Home

COM Codebook WNL


Namespace: VB
A Wednesday Night Lecture held on 2001/04/15 with Craig Berntson

COM Codebook is available for free at http://www.comcodebook.com.

[20:53] {CarlKarsten} Hi ya Craig

[21:02] {CarlKarsten} Allow me to introduce Craig Berntson who will be telling us about COM Codebook. So take it away, Craig.

[21:03] {CraigBerntson} Thanks

[21:03] {CraigBerntson} I don't intend to go into complete detail about setting up COM Codebook

[21:04] {CraigBerntson} there is a good sample app on the web site that goes into details

[21:04] {CraigBerntson} but when you first start looking at it, it seems really complicated

[21:04] {CraigBerntson} and it does take a bit to figure out

[21:05] {CraigBerntson} COM Codebook was developed by flash as a replacement for CodeBook

[21:05] {CraigBerntson} COM Codebook is designed to handle the middle and ui tiers of an n-tier application

[21:06] {CraigBerntson} it uses a number of vfp class libraries (based on the session class)

[21:06] {CraigBerntson} there are three levels of class hierarchy that you need to deal with

[21:06] {CraigBerntson} the c layer classes are the base layer. you shouldn't ever need to touch these as flash (now Go AmericaOffsite link to http://www.goamerica.net/) will update these

[21:07] {CraigBerntson} next is the i layer intermediate classes

[21:07] {CraigBerntson} these are intended to be enterprise/company level classes

[21:07] {CraigBerntson} for example, any changes that you want to make across all applications would go in here

[21:07] {CraigBerntson} finally is the a level application classes ... these are specific to your application

[21:08] {CraigBerntson} COM Codebook is truely n-tier in that the class hierarchies are divided into 4 functions

[21:08] {CraigBerntson} the first is the resource managers

[21:08] {CraigBerntson} this is the level the ui will interact with

[21:09] {CraigBerntson} the resource managers then call the other three functions are needed. they are

[21:09] {CraigBerntson} validators... that validate your data

[21:09] {CraigBerntson} processors.... do processing like generate reports, do intensive calculations, etc

[21:10] {CraigBerntson} and the data managers ... do the actual interaction to the data

[21:10] {CraigBerntson} all data access is via ado

[21:10] {CraigBerntson} there is one other class level that you can optionally use if your ui is done in VFP

[21:11] {CraigBerntson} it's called the resource manager proxy and is a custom class that you can drop on a form

[21:11] {CraigBerntson} it's primary job is to interact with the resource manager and covert the ado record sets to/from vfp cursors

[21:12] {CraigBerntson} if you bind your controls directly to ado or have some other ui like a web page, you don't need to resource manager proxy

[21:12] {CraigBerntson} COM Codebook has a configuration table that holds the parameters for the connection string to the data source

[21:13] {CraigBerntson} it's ready to go to connect to vfp, sql server, and oracle .. just put in your specific connection information

[21:14] {CraigBerntson} when you first setup a COM Codebook app, the first thing you will do is design your database

[21:14] {CraigBerntson} setup all the tables, etc that you will need

[21:14] {CraigBerntson} COM Codebook has a wizard that you'll then run

[21:14] {CraigBerntson} it will look at your data and generate the classes needed to query and update the database

[21:15] {CraigBerntson} by default, the code has insert, delete, and a generic query method for each table

[21:16] {CraigBerntson} the next thing you'll want to do is write the specific query code, for example, GetCustomerByName

[21:16] {CraigBerntson} or similar methods

[21:17] {CraigBerntson} you'll also add specific validation code

[21:17] {CraigBerntson} validation can be by field, record, or table (for example unique values)

[21:18] {CraigBerntson} there are specific naming rules that you'll need to follow for you validation methods... this is described in the documentation

[21:19] {CraigBerntson} you'll also need to add your processor code

[21:19] {CraigBerntson} once you get all that in there, you'll compile the four projects (resource managers, validators, processors, and data managers)

[21:19] {CraigBerntson} into dlls

[21:19] {CraigBerntson} and then test from the command window

[21:19] {CraigBerntson} one nice thing about COM Codebook is that it is MTS/COM+ aware

[21:19] {CarlKarsten} can you give an example of a nameing rule?

[21:19] {CraigBerntson} if you run the components in com+ or MTS, it detects this

[21:20] {CraigBerntson} naming rule...

[21:20] {CraigBerntson} let's say you have a field called ssn for social security number

[21:20] {CraigBerntson} the validation method would be called vldSSN

[21:21] {CraigBerntson} when you save a record, COM Codebook will automatically look for that method

[21:21] {CarlKarsten} ok, similar to prop_assign methods

[21:21] {CarlKarsten} nifty

[21:22] {CraigBerntson} another thing you should be aware of is that COM Codebook wants to generate it's own integer primary keys for each table

[21:22] {CraigBerntson} I've easily overridden this with my own method to use GUIDs generated by SQL Server

[21:22] {DenisChasse} Why?

[21:23] {CraigBerntson} Denis...it's sometimes easier to generate the key and put it in the record before saving rather than try to grab it from SQL Server

[21:23] {DenisChasse} I meant why does COM Codebook want to generate it?

[21:23] {CraigBerntson} also, integers are faster and smaller than guids

[21:23] {DenisChasse} ok ths

[21:23] {DenisChasse} thx

[21:24] {CraigBerntson} there is also a message table for handling any messages that need to be sent back to the UI

[21:24] {CraigBerntson} for example, if a validation should fail

[21:24] {CraigBerntson} by saving the messages in a table, they are easy to change or for foreign language support

[21:24] {PabloRoca} them the localization should be done only there?

[21:25] {PabloRoca} ok

[21:25] {CraigBerntson} not totally, Pablo .. remember that we aren't talking about UI elements here

[21:25] {PabloRoca} understood

[21:25] {CraigBerntson} in the event validation fails, the error message gets passed back to the UI to be displayed

[21:26] {CraigBerntson} that's pretty much it

[21:26] {CraigBerntson} it's much simpler than when you first look at it

[21:27] {CarlKarsten} thats COM Codebook?

[21:27] {CraigBerntson} I'm planning to do all new development using COM Codebook

[21:27] {CraigBerntson} yup...that's it Carl

[21:27] {MarkusVoellmy} Craig, how stable is it running right now?

[21:27] {RandyJean} Q&A now?

[21:27] {CraigBerntson} I also have an existing app that I hope to rewrite in COM Codebook

[21:28] {CarlKarsten} I think it is Q&A time, right Craig?

[21:28] {CraigBerntson} it's pretty stable ... they've fixed several bugs since it was released last fall and you get all the source code

[21:28] {CraigBerntson} and it's free

[21:28] {CraigBerntson} there is a support form on the COM Codebook web site

[21:28] {CraigBerntson} but it's only checked periodically

[21:28] {MarkusVoellmy} Yup, I dl'd it just at the beginning, but it was not very good then, that's why I asked ;)

[21:28] {RandyJean} Are there any case studies available? Would like to see on VFPSuccess Stories Wiki topic

[21:29] {BarbaraPeisch} When you generate GUIDs a la SQL Server, how does your backend respect those GUIDs, instead of wanting to assign an ID to new records?

[21:29] {CraigBerntson} Randy, Flash was showing off a web site they did using it.. there is information on the COM Codebook site

[21:29] {RandyJean} Is YAG still actively involved as an architect?

[21:29] {CraigBerntson} Barbara, I let the backend generate the guids via a stored procedure

[21:30] {Ilmar} If I need two ways to query customers, e.g. by ID and by Name, how do I use the wizard? Can I just create two Resource Mgr methods and have it create the others?

[21:30] {CraigBerntson} Randy: I believe so

[21:30] {CraigBerntson} Ilmar: the wizard will generate the primary key query...then you just add methods for name and anything else you want

[21:31] {BarbaraPeisch} Ilmar, are you asking your questions in a private window? I didn't see you ask anything.

[21:31] {DenisChasse} I'm currently using a commercial framework. Why would I want to replace it with COM Codebook?

[21:31] {CraigBerntson} you'll need methods in the resource manager (for the UI to call) and in the data manager to actually query the data

[21:31] {Ilmar} And will I need to do so by hand both for the Resource Mgr and the Data Mgr, or is there a way to get the wizard to generate the DM methods from the RM methods?

[21:32] {DanW} So, the methods as in Ilmar's question need to span the whole process?

[21:32] {CraigBerntson} no, you'll need to do to do it by hand ... but you can copy the query method for the ID and change one or two lines of code ... it's very, very easy

[21:32] {PabloRoca} And the Minimum requisites for COM Codebook ?

[21:32] {Ilmar} ok, thanks

[21:32] {CraigBerntson} DanW ... from the UI, you only call the resource manager ... no other classes

[21:33] {CraigBerntson} Pablo: it's just all VFP code... so the same requirements as VFP

[21:33] {DanW} I follow thanks

[21:33] {PabloRoca} I gived a quick look and my impression was that COM Codebook is only suitable for web-based apps?

[21:33] {RandyJean} Denis - I haven't used COM Codebook, but I would say it's more capable of doing truly distributed apps

[21:33] {RandyJean} It's like .NET lite { g }

[21:34] {CarlKarsten} or its like .Net shipping

[21:34] {PabloRoca} they say (If I can remember). "you must have a web server, ... "

[21:34] {CraigBerntson} Pablo: you can use it for any type of app ... it's very generic ... it forces you to keep the biz logic separate from the UI

[21:34] {RandyJean} CK - yes!

[21:34] {CraigBerntson} lol CK ... I guess you can look at it that way

[21:34] {CraigBerntson} Randy: yes.. you can do distributed apps very easily with it

[21:34] {Ilmar} Have you noticed any significant performance hit due to the layered approach?

[21:34] {RandyJean} Are there XML/SOAP examples?

[21:35] {DenisChasse} If it's so good why is it free?

[21:35] {DanW} Has anyone used in a load balanced enviroment where there may be several COM servers?

[21:35] {CraigBerntson} no, I haven't Ilmar ... flash did LOTS of research into it before writing it

[21:35] {CraigBerntson} ohh.. Randy... that reminds me ... there are also methods to get back XML instead of ADO

[21:35] {RandyJean} Denis - Because YAG is very generous {g}

[21:35] {CraigBerntson} but no soap examples

[21:36] {DenisChasse} Randy - Open Source in the Windows environment :-)

[21:36] {CraigBerntson} Denis: because flash believes in giving back to the community ... remember that CodeBook was always free, so why not COM Codebook

[21:36] {RandyJean} This aint your daddy's CodeBook, however {g}

[21:36] {Ilmar} Is anyone using it in combination with Strahl's Web Connect?

[21:37] {CarlKarsten} Also, if it is 'adopted' and gets a following, it has more developers reviewing it and submitting enhancements. Much like the Open Source idea.

[21:37] {DanW} My question exactly

[21:37] {CraigBerntson} Randy: I'm currently working on a CodeBook app that I want to move to COM Codebook ... I have a very hard time with CodeBook

[21:37] {CraigBerntson} Ilmar: not that I'm aware of, but you could post the question on the support forum at www.COMCodeBook.com

[21:38] {RandyJean} Because of the interoperability in .NET with COM+, a lot of components could be leveraged by .NET, too.

[21:38] {Ilmar} Haven't seen any mention of it lately, though there was some talk of that on the Alpha forum

[21:38] {CraigBerntson} there are some docs that indicate that it will have .NET support

[21:39] {RandyJean} I did a lot of CodeBook 2.x work. Loved it. Been sold on using a framework ever since for all development.

[21:39] {RandyJean} Why re-invent the wheel?

[21:39] {CraigBerntson} Randy: I'm going to reengineer my UI and support classes to use COM Codebook once I get more time (hahaha)

[21:40] {CarlKarsten} Any hint or plans for user based security?

[21:40] {RandyJean} Never used any of the Visual CodeBook flavors, except the stuff that was the basis for VFE 5.0

[21:40] {CraigBerntson} Carl: no... security using MTS/COM+ can be used

[21:41] {RandyJean} CodeBook 3.0 looked very daunting. I needed those wizards and builders {g}

[21:41] {DenisChasse} Can COM Codebook be used if we don't have MTS/COM+?

[21:41] {CraigBerntson} Randy: that stuff is way over complicated .. COM Codebook is very easy

[21:41] {CarlKarsten} how about adding fields/tables afterwards?

[21:41] {JohnKoziol} CodeBook 3.0 s*cked

[21:41] {RandyJean} I d/l COM Codebook about 5 months ago (right after it was released)

[21:41] {CraigBerntson} Randy: I agree ... I'm currently supporting a CodeBook app originally written by flash and I hate all the layers of classes

[21:42] {RandyJean} Glanced at it and it looked good, but haven't had a chance to sink my teeth into it.

[21:42] {CraigBerntson} Denis: yes, you can .. it will detect MTS/COM+ and use it...otherwise, it doesn't care

[21:42] {CraigBerntson} Randy: DL it again .. there have been updates ... and a sample app that will help you learn it

[21:43] {RandyJean} Cool, I will!

[21:43] {Ilmar} Besides the proxy managers and loaders, is there any other thing that the UI _needs_ to have? i.e. could one use one's own UI classes and just add these? It seems basically a middle layer framework.

[21:43] {CraigBerntson} Carl: adding fields and tables .. you can't run the wizard again , but adding that code by hand would be easy to do... mostly cut and paste

[21:43] {DenisChasse} Because if I get back with Carl's question. If I don't have mts/com+ it complicates things for user based security. I' saying this because the frameqowk I'm using right now gives me user based security

[21:43] {CraigBerntson} Ilmar: yes .. I use my own UI stuff and just do a CREATEOBJECT() to the resource manager

[21:44] {CraigBerntson} Denis: there isn't any security because that would require a UI element

[21:44] {CarlKarsten} I can see an advantage to letting COM+ do the security: it is already there.

[21:45] {CraigBerntson} Yup, that's right Carl

[21:45] {CarlKarsten} you have the windows user and groups management, and COM+ works with that

[21:46] {CraigBerntson} if you don't know about COM+, I have a series of articles on it coming up in Fox Talk over the next few months and will talk about it in my presentation at devcon in sandiego

[21:46] {DenisChasse} Nice. I'll keep those Fox Talk issues coming in

[21:46] {RandyJean} That reminds me, I need to renew {g}

[21:47] {CarlKarsten} Craig - how about a simple example of a VFP form, one textbox, and how the data gets to it from the back end?

[21:48] {CraigBerntson} hmm.. I could put that together Carl, but not for a couple of weeks.. I'm going to Connecticut saturday morning and won't be back for about 10 days

[21:48] {CarlKarsten} not code, just psudo method calls

[21:48] {CarlKarsten} I just meant an off the cuff description

[21:48] {CraigBerntson} ahh.. ok

[21:49] {CarlKarsten} forms init calls....

[21:49] {CraigBerntson} well, let's do this the "right" way

[21:49] {CraigBerntson} you have a text box for a query value

[21:49] {CraigBerntson} enter the value, click the query button

[21:49] {CraigBerntson} the click event would do a CREATEOBJECT("ResourceManager")

[21:50] {CraigBerntson} then pass the Text Box.Value to the rm.query()

[21:50] {CraigBerntson} rm.query would then pass the value to the datamanager.query()

[21:50] {CraigBerntson} which fetches the value from the table

[21:50] {CraigBerntson} and returns and ado record set to the rm

[21:50] {CraigBerntson} the rm returns the record set to the form

[21:51] {CraigBerntson} which has fields bound to the rs

[21:51] {CraigBerntson} and displays the record

[21:51] {CraigBerntson} when you save, it does pretty much the same thing

[21:51] {CraigBerntson} the save button does a createobject("resourcemanager")

[21:51] {CraigBerntson} then passes the rs to the rm.save()

[21:52] {CraigBerntson} the rm.save() does a createobject("validator") and passes the rs to the proper validation method

[21:52] {CraigBerntson} if the rs fails validation, a message is sent back to the ui

[21:53] {CraigBerntson} if it passes, the rm does a createobject("datamanager") and passes the recordset to it's save method

[21:53] {BarbaraPeisch} Would you really CREATEOBJECT("resourcemanager") each time you query or save? It seems you should just do that once.

[21:53] {RandyJean} It's stateless, remember?

[21:53] {CraigBerntson} Barbara: this is supposed to be stateless... if you create the rm once, then it won't be stateless

[21:54] {CraigBerntson} however... nothing says you can't create it just once

[21:54] {BarbaraPeisch} Oh, of course...keep forgetting this works on the web too.

[21:54] {CarlKarsten} how do you bind VFP controls to something that isn't there at design time?

[21:55] {CraigBerntson} Carl: you bind them in query button or new button

[21:55] {RandyJean} Carl, this is a facetious question, isn't it?

[21:55] {CraigBerntson} where ever you need them

[21:55] {BudWheeler} how is performance, seems like there is lots of overhead with all the CREATEOBJECT()s?

[21:55] {CraigBerntson} Bud: it's fast ... keep in mind, stateless

[21:56] {CarlKarsten} Bud - even my slow p400 does 400,000,000 things per second

[21:56] {CarlKarsten} hopefully it can create an object in a few thousand cycles

[21:56] {CraigBerntson} Bud: that's one advantage of running this in MTS/COM+ .. the object may be in memory.. you just need to hook up to it

[21:56] {BudWheeler} oh yes

[21:57] {CraigBerntson} remember that MTS will run on Win9x and NT

[21:57] {AndrewCoates} Hi Folks

[21:57] {CraigBerntson} and every copy of Win 2 K has COM+ built in

[21:58] {DenisChasse} Thanks for that presentation Craig

[21:58] {CraigBerntson} If you have questions, post them on the COM Codebook forum or email me

[21:59] {RandyJean} Thanks Craig. Good lecture. Good luck on the re-engineering

[21:59] {CarlKarsten} Whew

[21:59] {CraigBerntson} thanks

[22:01] {CraigBerntson} thanks for attending

[22:01] {CarlKarsten} Craig - so you have to iterate through your VFP controls after the data comes back?

[22:02] {MarkusVoellmy} Carl how do you mean iterate? You get a cursor back

[22:03] {RandyJean} to bind to get the values in/out of the cursor - the fields are dynamically bound somehow

[22:04] {RandyJean} Carl, VFE uses a field collection when not directly binding, doesn't it?

[22:04] {DenisChasse} Good night everyone

[22:05] {RandyJean} Then it does a setfields/getfields type of thing when reading/writing, I think.

[22:05] {MarkusVoellmy} The grid is populated with the results like this:

THISFORM.grdSearch.RECORDSOURCE = ""
	IF USED("ccSearchccConsultant")
		USE IN ccsearchccConsultant
	ENDIF
THISFORM.IResourceSearchCriteriaGrid1.GetBySearchCriteria("ccSearch", "ccConsultant")
THISFORM.grdSearch.RECORDSOURCE = "ccSearchccConsultant"
THISFORM.REFRESH()

[22:05] {RandyJean} I should know this but my brain is mush right now.

[22:07] {RandyJean} So, all data goes through ADO. Interesting. Still uses cursors? dunno.

[22:07] {MarkusVoellmy} So yes Carl, it looks as if you have to set the DataSource properties

[22:08] {Ilmar} It does allow you to use cursors.. that's what the proxy's job on the UI is, to convert the ADO recordset to a cursor

[22:08] {DanW} Should make it easier to use other interface classes other then CodeBook

[22:08] {RandyJean} No, I'm all wrong. Value_access/assign of the field obejcts do the heavy lifting in VFE. What am I thinking.

[22:08] {CarlKarsten} thats right

[22:09] {CarlKarsten} the field object get created when the cursor is instantiated, I think...

[22:09] {RandyJean} Ah, OK, I get it know. Gotta like those cursors, that's why I use VFP {g}

[22:10] {CarlKarsten} For those of you still here, thanks for coming

[22:10] {Ilmar} Thanks for hosting this

[22:10] {CarlKarsten} is there any topic that someone would like to see covered?

[22:11] {DanW} Thanks and Good night

[22:11] {MarkusVoellmy} hum your MSDE WNL ? ;)

[22:11] {CarlKarsten} I have been saving that as my wild card for when there is a gap I can't fill ;)

[22:11] {MarkusVoellmy} cool

[22:12] {MarkusVoellmy} but you could expand it now with an introduction to COM Codebook

[22:12] {PabloRoca} Yes, I would like more in depth-series from COM Codebook

[22:13] {CarlKarsten} well... I was thinking of VFE / MSDE


Contributors: Craig Berntson, Carl Karsten, Cindy Winegarden
Wednesday Night Lectures, Category Wednesday Night Lectures