|
Frequently Asked Questions about ObjectSight... Q. Is ObjectSight just a code
generator? No. ObjectSight has a code (class) generator to ease and speed up the process of defining the pre-requisite class definition based upon a database table. ObjectSight includes the Tools Manager program for creating and maintaining grid layouts, NextId sequences, and System/User Preferences for your applications. And of course, ObjectSight also includes the base classes for your Business Objects that provide all of the database persisentence, and visual controls to bind object properties to. Q. Is TosDataSet a descendant of
TdataSet? No. TosDataSet is derived from a TstringList. This is because a TdataSet is essentially a collection of records with fields, whereas, a TosDataSet is a collection of Objects. Each object can be interpreted as a record, but of course it also includes intelligence about itself and built in relationships to other objects. Q. What is the purpose
ObjectSight Tools Manager? The ObjectSight Tools Manager is required if you plan to use the supplied object bound grid control (TosDbTopGrid), sequences or the built in user and system preferences table (osUserPrefs). The Tools Manager is essentially an ObjectSight application that uses supplied Business Objects to manage grid layouts, NextId sequences and system/user preferences. Grid layouts are maintained in several database tables to allow for easy runtime customization by both an administrator as well as end-users. ; the tools manager allows you to create these layouts from Business Objects defined within the Class Generator. The sequences are for NextID generation within an Insert operation. The system and user preferences are an excellent technique for easily defining and using system and user preferences within your applications. Q. Can ObjectSight be used in
Web Server applications (ie. CGI and ISAPI)? Absolutely. Instead of dropping numerous Tquery components in the webmodule, you drop Business Object datasets which provide much more intelligence and flexibility. ObjectSight even has a TosHTMLGridProducer to generate HTML tables based upon a defined grid layout. Q. Can ObjectSight business objects be combined
with standard Delphi Applications? Yes they can. Because the TosDatabase component directly descends from the TDatabase BDE component, you can associate standard TQuery components and Business Object components with the TosDatabase component. All you need to do is replace the TDatabase component with the TosDatabase component. Q. Does ObjectSight come with
source code? Source code is available and is sold separately from the licensed system. Q. Does ObjectSight provide any
sample Applications? Yes. There is a sample application with a sample Interbase database that provides a very effective demonstration of the capabilities and features of ObjectSight. The folder ObjectSight/Samples includes all source files for the “dmo” Business Objects and the Delphi project. Make sure your Interbase server is running prior to starting the application. Q. Does the Class Generator
support reverse engineering? The Class Generator supports reverse engineering of ObjectSight Business Objects. You cannot reverse engineer other Delphi code. The class and method import options within the Class Generator are there to allow code that has been added within the Delphi IDE to be reversed back into the class definition within the Class Generator. Q. How do the Business Objects
get defined within the Delphi IDE? Once you are satisfied with the level of customization of your new Business Object within the Class Generator, you need to export or merge the class definition into pascal files. The pascal files are prefixed (by the supplied generation script) with “cu_” for class unit, “dd_” for data definition and “ru_’ for register unit. A design time component library (package) needs to be created within the Delphi IDE using the New… menu option, and then the three generated files added to this package prior to compiling. Since the Class Generator does not have a syntax checker, it is possible that your Business Object(s) may have some coding errors. Once these are fixed, a component wrapper for each of the Business Object(s) defined will be placed on the named Delphi IDE palette. Q. Does ObjectSight support any
CASE tools? No, not at this time. It is something we are looking at, and considering integrating with an existing CASE tool in the market place. So many to choose from? Q. Will the Class Generator create
database tables or scripts? No. There is no mechanism for creating database tables within the Class Generator. It only performs import of table meta data. Q. Can relationships to other
Business Objects be defined? Yes. These are commonly referred to as Child Classes as they are created as needed within the Business Object as a single object or as a dataset of objects (ie. Sales for a Customer). These relationships are easily defined within the Class Generator, and result in the following type of code… Example 1 : Sales dataset for a Customer Business Objectfunction TdmoCustomer.GetSales
: TdmoSalesDataSet; Begin if (FSales = Nil) then FSales := TdmoSalesOrderDataSet.Create(Self); if (CustomerId > 0) and (not FSales.Cached) then begin FSales.Filters.Clear;
FSales.AddIntFilter(loAnd, ncsaleCustomerId, opEq, CustomerId, True); FSales.Load; end; Result := FSales; end; Example
2 : Customer Type for a Customer Business Object (using TosInfoCache) function
TdmoCustomer.GetCustomerType : TdmoCustomerType; var aList : TosDataSet; begin Result := Nil; if (Length(CustomerTypeCd) = 0) then exit; aList := CachedList('TdmoCustomerTypeDataSetcmp'); if (aList <> Nil) and (aList.FindByString(nccsttCustomerTypeCd, CustomerTypeCd))
then Result := TdmoCustomerType(aList.Current) else raise EShowError.Create('Unable to locate CustomerTypeCd in
Cache!'); end; Q. How are database transactions
supported? Database transactions are supported and provide complete flexibility. A simple Business Object with no relationships does not need any custom transaction control as only a single INSERT, UPDATE or DELETE operation is performed within the Save method. More complex business objects such as the TdmoCustomer needs to commit changes to the customer table as well as other tables such as contacts and sales. The Class Generator will automatically take care of this by generating the following Save method. The Transaction Id is random and only the Business Object that started the transaction (with the proper TXN ID) will be able to commit or rollback the transaction. In this case the Customer is being saved and then numerous contacts being inserted, updated or deleted within one database transaction. procedure
TdmoCustomer.Save; var iTxnId : Integer; begin Database.dbStart(iTxnId);
// Starts transaction and returns a random Txn ID try inherited Save; if FContacts <> Nil then begin FContacts.SetFieldValue(nccontCustomerId,
IntToStr(CustomerId)); FContacts.Save; end; Database.dbCommit(iTxnId); except on E:Exception do begin Database.dbRollback; raise EShowError.Create(' Error saving TdmoCustomer...'#10#13
+ E.Message); end; end; end; Q. Can I mass produce Business
Objects for an entire database? Yes. The Class Generator has a dialog window that allows you to select one, some or all tables of a database to generate a single Business Object class definition for each table in the selected list. Typically after this you will still need to customize each generated Business Object. The benefit with this feature is that you can immediately start defining relationships between classes. Q. Does the Class Generator support any customization of the Business Object OR is this only performed within the Delphi IDE? Yes. The Class Generator actually uses ObjectSight technology to store all information about the Business Object in a database. It ships with an Interbase database, and the BDE alias osClassGen is used to access it. Customization within the Class Generator of a Business Object includes adding computed fields, defining relationships to other objects, and adding custom methods. New methods will automatically be added for computed fields and child classes. These generated methods can also be modified to reflect the desired behaviours. Q. What is a computed field in a
Business Object? A computed field is a field that is not directly associated with a column in the database. Typical computed fields are defined to reflect information in child classes such as NumberOfContacts, TotalSales or SalesLastYear. Q. Can a computed field be
modifiable? Computed fields are typically read only and default that way within the Class Generator, but they can be configured to be modifiable. The Set method for a computed field could then be adjusted to perform other operations such as change the value of another data bound field. An example would be setting the DataType property of a business object where the DataType is of type TfieldType (i.e. ftInteger or ftDateTime), and then setting the appropriate value of the DataTypeInt field which is an integer value stored in the database table. Q. What is the GetProperty and
SetProperty methods for? The GetProperty and SetProperty functions are automatically added whenever computed fields are present OR any data bound field has a GET or SET method defined. This is required as any fields bound to visual control such as a TosEdit or TosDbTopGrid are read and written to via the FieldByName(fldname).AsString which means the field value is pulled and populated without ever going thru GET or SET methods. You will typically want your GET and SET methods with their custom code to be executed even if you do not have the code Object.Property := Value specified anywhere. The GetProperty and SetProperty is a series of if..then..elseif statements to ensure the appropriate object methods are invoked when a field is changed. Q. Is there a way to reference
the parent of a Business Object? Yes. Objects have several types of parents possible. An individual Business Object may be one within a set of objects, it may be within another business object or it may be completely independent and owned by a Tform. The properties OwnerDataSet and Owner can be used to interpret who and what the parent is. The following code sample demonstrates how the TdmoContact object attempts to locate the Customer which it belongs to – it tries three different approaches (1 – Owner, 2 – Information Cache, and finally creates a new object and populates from the database (slowest)). function
TdmoContact.GetCustomer : TdmoCustomer; var aList : TosDataSet; begin // Perhaps this contact is an entry within a contactdataset of a // Customer object... if (OwnerDataSet is TdmoContactDataSet) and (TdmoContactDataSet(OwnerDataSet).Owner is TdmoCustomer) then begin Result := (TdmoContactDataSet(OwnerDataSet).Owner as
TdmoCustomer); exit; end; // Now look in the cache... aList := CachedList('TdmoCustomerDataSetcmp'); if (aList <> Nil) and (aList.FindByString(nccustCustomerId, IntToStr(CustomerId)))
then begin Result := TdmoCustomer(aList.Current); exit; end; // It was not - so we must fetch the customer data and create a
customer object... if FCustomer = Nil then FCustomer := TdmoCustomer.Create(Self); if (FCustomer.CustomerId <> Self.CustomerId) and (CustomerId > 0) then begin FCustomer.Filters.Clear; FCustomer.AddIntFilter(loAnd, nccustCustomerId, opEq,
CustomerId, True); FCustomer.FailOnFetch := True; FCustomer.Fetch; end; Result := FCustomer; end; Q. What is the Information Cache? The Information Cache is the TosInfoCache component that is typically added to your projects data module. It provides a single reference point for up to 20 other Business Object datasets. The CachedList method is provided for all Business Objects within a TosDbRecord to lookup a specific dataset class, and then locate a specific object using the dataset find methods (i.e. FindByString). The purpose of the TosInfoCache is to eliminate the need to access the database within your Business Objects for “commonly” and “frequently” required reference tables such as CustomerTypes or CustomerStates. The following code logic to lookup the customer state object so that the state name can be provided instead of the status code is quite typical in many applications. CurrentState is a computed field that provides the name of the customer state instead of the code value. The performance benefits of this approach are very substantial if you consider the effect of loading hundreds of customers in a grid and fetching the CustomerState object for every object in the list. Note that the FindByString method which looks for the specific entry will ensure the dataset is loaded as long as the AutoLoad property is set to true. function
TdmoCustomer.GetCustomerState : TdmoCustomerState; var aList : TosDataSet; begin Result := Nil; if (Length(CustomerStatusCd) = 0) then exit; aList := CachedList('TdmoCustomerStateDataSetcmp'); if (aList <> Nil) and (aList.FindByString(nccstaCustomerStateCd, CustomerStatusCd))
then Result := TdmoCustomerState(aList.Current) else raise EShowError.Create('Unable to locate CustomerStatusCd in
Cache!'); end; function
TdmoCustomer.GetCurrentState : String; begin Result := ''; if CustomerState <> Nil then Result := CustomerState.CustomerStateName; end; Q. Is there a way to
incrementally cache information as it is requested/needed? Yes. Setting the IncrementalCache property of a Business Object DataSet component to True and then referencing that dataset within a TosInfoCache will ensure that the entire dataset is not loaded when referenced within a CachedList/FindByString series of calls. Instead, the FindByString will attempt to locate the object in memory, and only if not located will it then attempt to Append the record from the database. This is an excellent technique to not automatically load large cached datasets such as a user or contact list. Instead, the user or contact is cached as the FindByString attempts to locate it. Q. What databases are supported
by ObjectSight? ObjectSight will typically support any database that the BDE or ADO can connect to. Only the databases listed within the DatabaseDriver property of the TosDatabase component are actually compatible and tested though (Oracle 7/8, SQL Server 6,7,2000, Interbase 5.6, 6.0, MS Access, SQL Anywhere). Every database has a different SQL dialect such as datetime formats, and other minor nuances that are specific to that database. The DatabaseDriver is used to adjust for these nuances. Q. Does ObjectSight only support the BDE or can other data access components be used? ObjectSight can support the following modes of database access... Q. How does ObjectSight determine the type of SQL operators to perform when saving to the database? Every Business Object descends from a TosDbRecord class ultimately. The TosDbRecord class has a RecordState property that determines the database state of the Business Object. This RecordState is interpreted during the Save method to determine whether the record in the database should be Inserted, Deleted or Updated. Q. When does the RecordState property of TosDbRecord (i.e. rsFetched, rsUpdate, rsInsert, rsDelete) change? The RecordState is set at various times during the lifetime of a Business Object. The New method will set it to be rsInsert in readiness to Insert a record when saved. Once saved successfully (via the database commit operation), the RecordState will change to rsFetched. As soon as a databound field is modified, the RecordState will then change to rsUpdate. Once saved successfully again, the RecordState will change back to rsFetched. If the Business Object is marked for deletion via the MarkForDelete method, the RecordState will change to rsDelete. If the Object is then saved, the record will be deleted and then destroyed. Q. How does ObjectSight perform queries? Queries are performed using the TSQLFilterList and TSQLFilter objects that are always available to Business Objects and Business Object Datasets. The TSQLFilterList will support any complex query including sub queries, AND’ing logic, and OR’ing logic. The Add[DataType]Filter methods such as AddIntFilter allow for the specification of filters on the TosDataset Load or Append operation and on the TosDbRecord Fetch operation. The filters are converted to SQL WHERE clauses during Load, Append and Fetch operations. The following complex query uses two date filters and a subquery using the AddFreeFilter method to load requests that are DUE today lsViewRequests.AddDateFilter(loAnd,
ncreqtDueOn, opGE, Date, True); lsViewRequests.AddDateFilter(loAnd,
ncreqtDueOn, opLT, Date + 1, True); lsViewRequests.AddFreeFilter(loAnd,
ncreqtRequestStatusCd, opIn, '(SELECT rs.request_status_cd from request_states
rs WHERE rs.request_type_cd = reqt.request_type_cd AND rs.request_status_cd =
reqt.request_status_cd AND rs.stage not in (4,5))', True);
Q. Is there a way to view the
SQL code that is being generated by ObjectSight? Yes. Besides the method trace, there is also a built in SQL trace that will trace all SQL commands sent to the server (SELECTs, UPDATEs, INSERTs, DELETEs, COMMITs and ROLLBACKs). In addition, if there is any error with the SQL code during execution, a file called SQLDump.Txt is generated and populated with the offending SQL code and the names and values of any parameters used within the query. A single Tquery component is defined in the TosDatabase component to execute all SQL generated by the Business Objects. This Tquery can be referenced by the property WorkerQuery of the TosDatabase component to interpret the SQL code. Be aware that the SQL property is flushed as each Business Object needs the Tquery to perform SQL operations on the database. To access the trace at runtime, implement some code to open the trace window using the TosDatabase.OpenTraceWindow method. Traces will be saved to txt files when the database disconnects. Q. Does ObjectSight support design-time binding of Business Object fields (properties) to visual controls such as TEdit? Yes. ObjectSight also provides a complete list of visual controls that are derived from the basic Delphi controls such as TEdit and TcomboBox to support data binding. They are identical in behaviour to the typical Tdb controls such as TdbEdit. The source code for the modifications to enable these controls to bind with properties of a Business Object is provided. This allows you to setup your own visual controls to bind to ObjectSight Business Objects. Q. What are the enhanced
features of TosDbTopGrid over TtsTopGrid? The TosDbTopGrid is a derived grid from the TopGrid component. ObjectSight also supports and sells the TopGrid component, following a recent take over from the original developer TopSupport. We have enhanced the grid to provide numerous popular features including, record grouping with headers and footers, subtotaling on footers, automatic sorting with a heading click, built in reporting, runtime user customization of the grid layout, and exporting to CSV files. Q. How are grid layouts managed
within ObjectSight? Grid layouts for the TosDbTopGrid are managed by the Tools Manager. A Business Object may have numerous fields and properties that you want to display and allow the end-user to select and display. The ViewName and ViewUserId properties of the TosDbTopGrid drive what grid layout to use and for what user; ViewUserId of –1 means that the default application layout should be used. When the user uses the runtime grid editor, or the popup field selector or just resizes a column, a copy of the layout will be created for and maintained for that user. The user will then have their own personal layout each time they enter the application. The Tools Manager allows the developer to configure the base grid layout (UserId = 0) which defines all of the available columns within the Business Object which the end-user can select from. In addition, the developer may also define that the grid cannot be customized by the end-user. Q. Are there any Business
Objects shipped with ObjectSight? Yes. ObjectSight ships several Business Objects that can be used in your applications. There are Business Objects for the grids and the associated grid columns, for the sequences table and for the osUserPrefs table. The TosUserPref and TosUserPrefDataset are powerful business objects that allow you to define system and user preferences for your applications. They provide easy Read and Write methods for you to access a system default setting, and then when a user modifies the preference, a user preference is automatically configured and used in future starts of the application. Business Objects to directly access the Class Generator database are also provided. Q. How do I configure the necessary database tables within my own database to have ObjectSight Business Objects function? This can be done using typical Delphi tools, or more easily using the osTablesCreate.exe program that is provided. The following tables are required in your target database to properly use all of the features within ObjectSight. osGrids, osGridColumns, osGridSettings - TosDbTopGrid tables to store grid layouts and user settings osSequences - Stores sequences for the built in NextId method to pull from (optional) osUserPrefs - Stores system and user preferences for your applications (optional) Q. Does ObjectSight support
N-tier development? ObjectSight supports ASTA technologies ASTA middle tier server technology. No changes in code development or your Business Objects will be required (from the 2-tier mode) to start using N-Tier with ASTA. You simply change the TosDatabase ConnectMode property to cmASTA, link to the TastaClientSocket and go!! Q. Does ObjectSight have any mechanisms or components to generate HTML? Yes, ObjectSight has a new component called a TosHTMLGridProducer that can generate an HTML table for a bound dataset using a pre-defined grid layout within the osGrids table. This powerful component is used within CGI and ISAPI applications to easily format and present Business Object Datasets within Internet Browsers with one line of code. Q. Is there any way to use a different NextId mechanism to produce Id values during Insert operations? The TosDbRecord.GetNextId method is declared as dynamic and can be overridden by your own GetNextId method of a new base technical class such as TmyDbRecord. Q. How is garbage collection
performed? Garbage collection is very important in Object Oriented programming. When a Business Object is destroyed it is critical that all references to that object by other objects be cleared, as well as all child objects owned by it. This is similar to when a TFORM is destroyed, it is important that all the visual controls on the form also be destroyed. ObjectSight supports powerful garbage collection that eliminates almost the entire need for the programmer to even be concerned. For example, when a TdmoCustomer is destroyed, ObjectSight will automatically destroy every TdmoContact and TdmoSale stored within the child datasets. In additon, if the TdmoContact or TdmoSale had any children, those in turn would also be destroyed. Q. Can a Business Object link
back to more than one database table? Yes. ObjectSight Business Objects are typically generated to access a single database table, but in more complex circumstances such as Business Objects descending from other Business Objects – more than one database table may be referenced during a save operation. For example, a TdmoContact is based on the contacts table and is derived from TdmoPerson which links to the persons table. Thus, fetching a contact requires a join between the persons and the contacts table. This join can be defined as either INNER or OUTER JOIN. Save operations will then take into consideration that multiple INSERT, UPDATE or DELETE operations must be performed. Q. Can Business Objects support inheritance? Yes. There is no limit as to how many levels of inheritance are possible. Each successive inheritance will require additional settings within the data definition of the tableclass (dd_ file) to specify the join conditions between the tables of the various Business Objects. | ||||||||||||