CategoriesSyndicate This BlogBlog Administration |
Thursday, September 14. 2006Prague Devcon 2006 Day 2Prague Devcon 2006 Day 2 After the sessions yesterday I was really looking forward to the day's events especially from Craig who had not promised that today he would finally show some VFP code and boy did he show some code! The venue for the sessions was the same as the previous day but we found out that the air conditioning would not be working so it promised to be a "hot" experience and Craig certainly set off at about 120 degrees Farenheit! ![]() With VFP you can Run with the Pack but still stand out from the Crowd!
Session 1 - Craig Bernston Windows Component Services Part 1 For those of you who have never used COM or COM+ the basic idea is to place a "Server" application on a remote server and then to call the exposed methods in the server DLL from the client VFP application just as though they were local methods, hence, sending and receiving "data" to/from the remote application - wherever it is based. Just think client/server if you still can't figure it out .... but without the database! He pointed out how the DLL's fit into the application structure and outlined the basic testing sequence for any distributed application: 1. Build and Test the a small test DLL first Obviously the word "Transaction" appears in the above checklist and wrapping MTS transactions up is basically what Craig has been doing lots of development on recently DESPITE the fact that Microsoft (even the VFP team themselves) said it couldn't be done. Those of you who have done any COM will know that MTS was built on COM and not integrated into it whereas COM+ now has MTS embeded within its runtime and includes the calls to Intercept and control MTS transactions. Initially he developed a simple COM component to simply add two numbers together and return the result... COM in its simplest form, just as an example of how the technology works. This allowed the audience to get a look at how the COM component is controlled on the server in 2K3 using the Component Services administration utility. Basically, this allows you to administer the registration and control of any COM+ service running on the server - much like the old NT Services manager but considerably slicker! We than moved on to convert this simple component into a COM+ server which wrapped up an MTS component. The server was based on a Session base class which is the most lightweight class to use for this purpose. We then saw how retain valuse in a COM+ Server after a call from the client (the equivalent of Static vVariables) or to reset itself so that each call would initiate a complete reset of any local variables in the server. For those of you not used to static variables, they are a little like globals in that they retain value between usage sessions and only get initialised ONCE. Craig made use of the This used the GetObjectContext() method of the MTS Component which was new to me...so we are now in uncharted territory! Once the COM+ server was set up using Component Services we then set up authorisation to use various levels and functions of the server, a little like setting up Active Directory Permissions. I must admit that at first look this seemed somewhat messy and baffling as there were so many levels of security and access priviliges that you could easily slip up. Not remembering one of these security settings would stop your COM+ component from working correctly. Even Craig admitted that this was a "delicate" procedure fraught with potential pitfalls. The complexity of the code and setting up the COM+ is probably summed up by the fact that Craig said the session notes were in excess of 70 pages. After a couple of false starts because these very permissions hadn't been set up correctly we finally had a COM+ server wrapping up MTS which added and divided two numbers: ox=CreateObject("Complus.Math") Eureka!!! What a lot of work to do such a simple thing, but the concept was what mattered. His session from now on dealt with the possibility of passing transactions down the queue fron the UI all the way to a VFP driven server such as for use in distributed data transfer situations such as Salespeople entering sales orders which need to transfered to the head office. We all know how this can be achieved in the conventional manner but this is always synchronous - i.e if the server isn't there, the transactions don't get passed and when the server IS there we effectively involve ourselves with a full synchronour transaction which gets handshakes back and forth and confirmations of data receipt etc. Craig suggested that in certain circumstances we could look at asynchronous design/development where the passing of data from one "layer" (and I mean layer of code not the conventional n-tier layer) to another completely under "NON VFP" control. This lead us onto JIT or Just in Time Activation. The advantage in using JIT is that the component becomes Stateless and not loaded into memory until it is needed...great for those of us who look at CPU Utilisation. I won't go into any detail as I must admit I couldn't scribble down the code fast enough, but we then saw a JIT component writing out a value and using the Setcomplete() call on the MTS which commits a transaction from one level of the application to the next level. Once again the concept of "static values" become relevant as there is a call Setcomplete() for a transaction. Miss this Setcomplete() out and the values from the current call are followed through to the next call on the COM+ object. In effect Setcomplete() resets the object by calling the Init() routine again where all values are reinitialised. We then moved back to the aspect of Security - which was soon to become even MORE complicated in that we can use what is known as Declarative security which permits access to the COM+ components via Windows Security Groups. To use this security we do the following: 1. Create Windows Users/Groups Once again the complexity of setting up the security access to COM+ seemed never ending and Craig used his own notes extensively. You can go down to the level of assigning an individual user access rights to discrete methods in a COM+ component in order to give scope to the methods to outside users - and you thought Active Directory was complicated! Even though Craig made a couple of errors "en route" in setting up access to the COM+ and eventually abandoned the demo we all got the basic idea. I really feel for people when demo's go wrong (been ther done that...got the teeshirt) but on the other hand I think Craig was so so brave to even attempt to do this sort of demonstration live. The whole methodology should have a "Beware Potential Disaster" sticker attached as this is a potential minefield. If you intend on doing any work in this area be sure to download Craig's notes as and when they become available. Just as an aside, Craig did sort out the "typo error" which caused the initial malfunction in the demo later on in the session, to be greeted with a great round of applause from all!
Atomicity - must do an entire update or nothing at all
1. Allows multiple modes of access to various outside transactions Craig then introduced DTC (Distributed Transaction Coordinator) which is responsible for coordinating transactions that span multiple resource managers, such as databases, message queues, and file systems and is included in WIndows 2000 onwards as well as NT4 (I think!). (1) and (2) above use DTC using a 2 phase event: Phase 1: Ask the attatched DB can you commit> Just in case you are worried, all this functionality is nicely wrapped up in COM+, which lead us neatly into Transaction Voting. Transaction Voting (TV) is the method of setting the "Consistent Bit" to indicating if a transaction update is consistent and setting the "Done Bit" if the transaction is OK. So, if you have got this far you will know how intense this session was - and Craig was only just picking up steam! We discovered (or at least I did) that COM+ does in fact support Automatic Transactions and we then saw a small demonstration of a COM+ 3 tier system in which a VFP form created a cursor in the Load() method, text boxes were then bound to the cursor and a Save button on the form converted the data to XML which was then sent in turn to a Biz Object for Validation. The Bizobject then used the GetContextState() method in the COM+ Server and updated an external database (in this case the infamous "North Wind" sample data" in addition to an "Other" external datasource generated by Craig) with both sets of data having rollback capability. All of this transactional capability is controlled by what is called Transaction Voting - I leave it to the reader to investigate this subject further! To wrap up the session, Craig showed us how to load up the workstation by exporting the COM+ service using the Component Services Manager. It turned out that the "no go" status of the last demonstration was caused by not re-exporting the Workstation components which creates an MSI installation or a ".CAB" based installation (incidentally exportable via an ASP Page). Even though the final demonstration didn't update the two sets of data as it "short circuited". I think that Craig was now running on pure adrenalin but the proof of concept was there to see. COM+ runs on Windows 2K and Windows Communication Foundation (WCF), which the VFP team has promised to support using Sedna Updates, on Vista. However COM+ works now and is available to VFP9 users now so why not have a go!
After the supersonic last session I though that Craig may well have run out of steam, especially seeing as how the air conditioning in the conference centre was not working and the inside temperature had reached about 29 degrees. None of it though, we continued on and discussed getting VFP to run in DTC using what is called a CRM or Compensating Resource Manager). This is the bit that the VFP team said was impossible so we were obviously about to witness black magic! With CRM we simply write out to a log file any update transactions which have been made. We then call what is termed a compensator which is where all the magic happens. We extract the log record (which incidentally is an array) turn it back into a cursor, open up the DBF' to be updated and duly update the DBF with the transactional update - easy (NOT)!
1. Recorders - sit on the Terminal (client) and record the updates Once the Player is finished, the the "Update OK" message is passed back to the Recorder on the client and the update is deleted from the client. Remember there can be many sets of Recorders, Listeners and Players in series. There followed a small session on interface design and how to set up the stream of data. Consider a salesman out on the road who wishes to upload sales orders onto the main Server. The interface should be one way only in write mode, with the response being from each stage in the message transfer process either In this way we have a sort of lattice work where the message will only go one way and stop at a level unless it is cleared to proceed to the next level. All this happens without the client ever knowing, so if the connection to the server is down the message will progress down the "Queue" as a "Queued Component" as far as it can until it reaches the server. OK, an SOP example is maybe not the best description but another more relevant use is if a COM+ Server is used to distribute or "Publish" information in a similar way to an RSS feed i.e distributing data in the opposite direction. Under these circumstances a Server doesn't need to know where or to whom the information is going or even if it actually arrived. All it need to do is allow end users to subscribe to the service as a "Subscriber" and the data is broadcast out even if the end users are connected or not, which obviously frees up resources on the server. This seemed a little like the old concept of using FEP's (Front End Processors) when I started in IT in the early 70's but brought up to date using software instead of hardware! Craig once again reiterated that COM+ is here now and it incidentally uses RPC (in case you weren't aware) whereas WCF (See earlier sessions) is not yet supported in VFP even though the VFP team have promised support within a future release of Sedna. The advantage of WCF? Well it should be easier (not difficult!) to drive and will allow communication over the Internet. I think this will really allow some great ideas to flourish in the VFP Community. Finally, debugging COM+ applications is not the easiest thing to do and Craig's method was the old standby of writing lines out to a text file to indicate breakpoints and content. Now that REALLY takes me back a few years. Having only debugged COM components I know that inadequate debug facilities are probably the biggest development "waste of time" so the added complexity of COM+ can only increase this unfortunately. Maybe a case for a COM Debugger YAG? To round everything off, we discussed the benefits of using COM+ in a ASP page as opposed to COM. Well for those not aware COM+ won't potentially kill IIS if it dies as opposed to COM which usually kills any IIS server if it dies. After this session we all paused to take breath and headed out for a well deserved cup of coffee and a sticky bun. Well done Craig! Session 3 - Yair Alan Griver 1. LinQ All of thesee phases germinated from a desire and design to integrate XML into C#. The idea is to make data, Objects and XML look and interact together in the same way. The technology will be going into C#3.0 as well as VB9.0 as well as available as a retrofit option to the current VS2005 C# and VB versions. Incidentally the LINQ Preview CTP is available on the Microsoft Site. I thought that this session would be the one where we were bludgeoned into adopting .NET, but it wasn't this way at all. In a sense, I was relieved that in VFP we have always been able to treat data in the same way as other objects from day one. Apart from Passing Cursors Between Data Sessions!!!!!! YAG TAKE NOTE PLEASE!!! Linq Query over Objects was something that I would like to see in VFP and was in fact in Clipper. Well this will be possible iusing LinQ which will still maintain strong typeing as aArray will become an array of integers as opposed to : Dimension aArray:={1,2,3,4,"Hello"} where aArray will become an array of "variant Objects".
http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,8f61649c-c076-4420-b949-07ae7b32ac54.aspx where he examines adapting the concept of LINQ but in VFP. Maybe someone will pick up on this proof of concept work and run with it. The session was interesting and really brough to light how much the features available NOW and taken for granted by all of us in VFP are beginning to be adopted in the next generation of C# and VB.
We saw ways of making your VFP Forms behave persistently with respect to saving their position and colour etc into either ini files, the registry or even the Config.fpw file. If you look at the way that VFP holds static information it is held in Binary format and there is a small class in Resourcefile.prg which will decrypt and Encrypt this information - all for free. Next, attention turned to OOP Shortcut menu's or popups. We all know that the menu designer generates fixed code that is just not flexible in many situations. Well, look at the ContextMenu class in Toolbox\Foxmenu.prg and you will find a complete set of classes to generate oops menus with methods such as addmenu() etc etc. Well worth a look. Next, displaying video files or animated GIF's when your application is involved in a long process, You know, books flying accross the message dialogue etc etc. Well look in Foxref\Foxref.vcx at the cAnimation class - just don;t forget to distribute mscomctl2.ocx with your application! As for Progress dialogues, you have access to a complete set in Foxtoolbox\Foxtoolbox.vcx as opposed to the poor imitation in Foxref\Foxref.vcx which most people seem to find first. However, once again be careful to distribute MSComctl.ocx with your application as well as FindComp.Gif
GetAvailableServers() Once again all these are available for free so don't re-invent the wheel and look at some coding from some really good developers to boot. Stuck for an Outtlook type control which expands/contracts sections, then have you ever looked at the toolbox tool in VFP? That looks similar and with a little modification can be made to look like a really professional control where "major/Minor" sections are drilled down into. Find this in Toolbox\FoxToolbox.vcx Finally Doug touched on Creating Builders, which to me was probably the best bit of the session as I have always shyed away from them. There is actually a framework to build a builder within VFP which takes all the hard work out of the coding needed to even understand how a builder works. Many times I've had to code the same settings on an control object that I've visually designed but needs to be bigger/smaller. Doug generated a simple control of a textbox followed by a button to the right of the textbox in about 5 minutes. When you increased the size of the textbox, the button stayed alligned to the right hand side of it exactly 5 pixels away without any extra object editing. I'll investigate this further when I get back as it was so easy and so so productive.
1. Adding Hyperlinks onto a Report Doug demonstrated using hyperlinks on a report to simulate a Table of COntents (TOC). I must admit I had thought of this myself some months ago but soon discovered that the VFP Preview window is in fact Modal which means that it can't trap events when the hyperlinks are clicked. However, if the output from the report is piped into HTML and the final report opened up in a browser, then the hyperlinks will function - why didn't I think of this DOH! The actual hyperlink was held in the field properties dialoge under "User data" in a form that will be instantly noticeable to those of you who ever used GenScrnX i.e: The BeforeReport() method picks up these URL's to use at display time and links accordingly if the hyperlink is pressed. 2. Drill Down on Reports 3. Firing off VFP Dialogue 4. Rendering to a cursor.
In response to a question regarding whether there would be a VFP Express release the answer was a categorical "NO" and when pressed YAG cited limited resources to test a "degraded product" which is fair I guess. He also stated that they would want to release a "current technology" version of VFP so I guess a freeware release of VFP3, 5 or 7 is out of the question. A Pity that as it would maybe get a wave of new younger devalopers onto the VFP trail.
Well I thoroughly enjoyed the conference and even got to see a little more of Prague this year. Igor and his team did a wonderful job organising the conference and I'll certainly be booking my ticket for next year as long as it doesn't conflict with FoxForward, which I really really wanted to go to this year...but not to be. It was great to meet up with old friends as well as make some new ones. VFP looks to be in a better shape than it has been for many many years and I for one am not worried about its continued success. Just one request though....Please Please Mr Gates, give VFP SOME sort of advertising budget! With that I'm signing off and getting some sleep. If you've got this far, thanks for reading...if not, then I probably don't blame you! Final Postscript: Also, thanks must go to to Doug and Craig. They sure earnt their pint(s) of Prague Beer! Thanks fo staying with me to the end. Dave Trackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
Another great post! thanks for taking the time to report this event for us!
|
