© All rights reserved. U.S International Tech Support Language Objects Dr. Kevin King, Chief Information Officer Brian Hipple, Quality Assurance Supervisor BASIS International Ltd.
© All rights reserved. U.S International Tech Support Overview ► Object-oriented Business BASIC ► TechCon2006 workbench ► Retrofitting legacy code into Objects ► Event Objects ► Type checking ► Memory management ► Autorun
© All rights reserved. U.S International Tech Support Why Use Objects? ► Objects closely model the real world Customer object models an actual customer Inventory object models an inventory item ► Self-contained Each object carries both methods and its internal state Building blocks for constructing larger applications ► Controlled access Interaction is through defined methods Internal data is hidden Internal implementation can evolve over time
© All rights reserved. U.S International Tech Support Object-Oriented Languages ► Java ► C++ ► C# ► Visual Basic BBx
© All rights reserved. U.S International Tech Support Introduction to Object-Oriented Programming (a Primer) ► Reusability ► Compartmentalization ► Encapsulation ► Readability ► Scoping
© All rights reserved. U.S International Tech Support New Custom Object Keywords ► CLASS – Marks the beginning of a class definition ► CLASSEND – Marks the end of a class definition ► Access Modifiers PUBLIC – Accessible from all PRIVATE – Accessible only within the given class PROTECTED – Accessible within the given class and derived classes STATIC – Makes field values and methods persist across all instances of a class within an interpreter. An instance of the object is not required to utilize. ► FIELD – Class member or data variable, can be another class
© All rights reserved. U.S International Tech Support Red Class class public Red field public BBjString RedString method public void RedMethod() print "RedMethod!" methodend classend
© All rights reserved. U.S International Tech Support Blue Class Class public Blue extends Red field public BBjString RedString field public BBjString BlueString method public void RedMethod() method public void BlueMethod() print "BlueMethod!" methodend classend
© All rights reserved. U.S International Tech Support Black Interface interface public Black method public void BlackString() print "BlackString!" methodend interfaceend
© All rights reserved. U.S International Tech Support Green Class Class public Green extends Blue implements Black field public BBjString RedString field public BBjString BlueString field public BBjString GreenString method public void RedMethod() method public void BlueMethod() method public void BlackMethod() method public void GreenMethod() print "GreenMethod!" methodend classend
© All rights reserved. U.S International Tech Support Code Completion Vignette
© All rights reserved. U.S International Tech Support Techcon06 Workbench Demonstration
© All rights reserved. U.S International Tech Support Object-Oriented Workbench ► Points to ponder ► Steps to success ► Reasons and rationale ► Benevolent benefits ► Accurate architecture ► Features and functions ► Pinning performance
© All rights reserved. U.S International Tech Support Object-Oriented Workbench Points to Ponder ► Object-oriented vs. procedural ► Relate functionality and data ► Base classes – reusable code ► Extended classes – reduce code ► Interface classes – flexible code ► Time Value Readability Usability Maintainability
© All rights reserved. U.S International Tech Support Object-Oriented Workbench Steps to Success ► Create MDI host ► Create Toolbar, AppTree, SourceViewer ► Create extendable infrastructure BBj and 6.0 Visual PRO/5 Third party ► Document and publish classes
© All rights reserved. U.S International Tech Support Object-Oriented Workbench Reasons and Rationale ► Structurally similar to human thinking ► Similar to Java, C++,.NET, Visual Basic, etc. ► Gives developers code-completion ► Reduced overall bugs ► Reduced coding time ► Reduced debugging time ► Reduced documentation time
© All rights reserved. U.S International Tech Support Object-Oriented Workbench Benevolent Benefits ► Provided written and tested extendable classes ► Provided common code interface ► Provided common look and feel ► Provided common features and functions ► Provided access to BACKGROUND processing
© All rights reserved. U.S International Tech Support Object-Oriented Workbench Accurate Architecture
Object-Oriented Workbench
© All rights reserved. U.S International Tech Support Object-Oriented Workbench Features and Functions ► MDI ► Virtual desktop ► Toolbar ► Tree ► Source view ► Application monitor
© All rights reserved. U.S International Tech Support Object-Oriented Workbench Production & Pinning Performance ► Single parsing of class definition ► Never checked for Changes Deletions File reference changes ► Unpin options Programmatic BBjAPI->BBjAdmin->BBjAdminEnvironment->unpinAllPrograms() Manual Enterprise Manager ► See the speed…
© All rights reserved. U.S International Tech Support Enhanced Performance of Pinned and CALLed Programs in BBj 6.00 Demonstration
© All rights reserved. U.S International Tech Support Benefits of Custom Objects ► Code reusability ► Code readability ► Data encapsulation ► Variable scoping ► Code-completion ► Modern programming architecture ► Intuitive programming ► Simplified debugging
© All rights reserved. U.S International Tech Support Retrofitting Legacy Code Into Objects ► CUI READ RECORD from console channel No event loop ► GUIBuilder READ RECORD from SYSGUI channel Receives all events per event mask ► BBjAPI PROCESS_EVENTS Receives only events registered for Event Objects
© All rights reserved. U.S International Tech Support CUI – READ RECORD Demonstration
© All rights reserved. U.S International Tech Support CUI – READ RECORD Source Code
© All rights reserved. U.S International Tech Support GUIBuilder – READ RECORD Demonstration
© All rights reserved. U.S International Tech Support GUIBuilder – READ RECORD Source Code
© All rights reserved. U.S International Tech Support BBjAPI ProcessEvents Objects Demonstration
© All rights reserved. U.S International Tech Support BBjAPI ProcessEvents Objects Source Code
© All rights reserved. U.S International Tech Support Event Objects ► Object-oriented which contain event information ► Provide methods to access event information ► Created Automatically when event occurs Programmatically BBjAPI::postCustomEvent, BBjAPI::postPriorityCustomEvent ► Accessed BBjAPI::getLastEvent() As a parameter to object based event handler
© All rights reserved. U.S International Tech Support Event Objects Source Code
© All rights reserved. U.S International Tech Support Type Checking Features ► Option for bbjcpl to enable type checker ► Can specify prefix via the command line or from a config file ► Verbs facilitate IDE code completion ► Optionally warns about unsafe uses of undeclared expressions to allow incremental code improvement ► bbjcpl options integrated into IDE compiler configuration
© All rights reserved. U.S International Tech Support Type Checking ► Compile-time Command line – bbjcpl Options -t Enables type checking -W Enables warnings about undeclared variables -P Specifies a prefix for files containing Custom objects -c Specifies a config file which contains prefix information BASIS IDE Tools->Options->BBj Compiler Settings ► Runtime !ERROR=26 Mismatch ► Opt in strategy
© All rights reserved. U.S International Tech Support Type Checking Types ► BBjNumber Numeric expressions Assignment compatible to boolean, Boolean, java.lang.Integer, BBjInt ► BBjInt Integer expressions Assignment compatible to Java integer numeric types, boolean ► BBjString String expressions Assignment compatible to java.lang.String and byte[] $ suffix
© All rights reserved. U.S International Tech Support Type Checking Types ► Objects ! Suffix BBjAPI Obtained by calling a BBjAPI() method mdi! = BBjAPI().getMDI() Java Obtained by instantiating a Java object or method call states! = new java.util.HashMap() Custom Obtained by instantiating a Custom object or method call workbenchMDI! = new WorkbenchMDI()
© All rights reserved. U.S International Tech Support Type Checking DECLARE Verb ► Provides a contract between the developer and BBj ► Contract specifies that declared variable will never contain anything other than the declared type ► Example DECLARE java.util.HashMap a! a! = new java.util.HashMap() a!.put("dog", new java.lang.Integer(5))
© All rights reserved. U.S International Tech Support Type Checking CAST Function ► Changes the declared type of an expression to a specified type ► Use sparingly ► Failure invokes error branch ► Example DECLARE java.util.HashMap a! a! = new java.util.HashMap() a!.put( " dog ", new java.lang.Integer(5)) a!.put( " cat ", new java.lang.Integer(6))... b = CAST(BBjNumber, a!.get( " dog " ))
© All rights reserved. U.S International Tech Support Type Checking Benefits ► Detects potential runtime errors at compile time ► Improves code robustness ► Encourages good programming practices
© All rights reserved. U.S International Tech Support Type Checking Command Line Demonstration
© All rights reserved. U.S International Tech Support Type Checking BASIS IDE Demonstration
© All rights reserved. U.S International Tech Support Autorun ► BACKGROUND replacement ► Auto starting daemon/service ► Programs run when BBjServices starts ► Configuration options Name of program config.bbx file Initial working directory User Set default values for all options ► Licensing infinite number of programs for one licensed user
© All rights reserved. U.S International Tech Support Autorun ► Background processing Server process Listener processes Worker process Socket server Print server ► AppMonitor built into the workbench – Demo ► Basic sample writing out the starting of BBjServices - Demo
© All rights reserved. U.S International Tech Support Autorun Source Code
© All rights reserved. U.S International Tech Support Autorun in Enterprise Manager Demonstration
© All rights reserved. U.S International Tech Support Autorun AppMonitor Demonstration
© All rights reserved. U.S International Tech Support Memory Management ► Caching algorithm modified Programs Resources ► Performance improvements ► Fault tolerant
© All rights reserved. U.S International Tech Support Summary ► Object-oriented Business BASIC ► TechCon2006 workbench ► Retrofitting legacy code into Objects ► Event Objects ► Type checking ► Memory management ► Autorun