Download presentation
Presentation is loading. Please wait.
Published byAshlyn Hubbard Modified over 9 years ago
1
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.comsales@basis.comwww.basis.com Language Interpreter Dr. Kevin King, Chief Information Officer Brian Hipple, Quality Assurance Supervisor BASIS International Ltd.
2
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 2 Overview ► BBj vs. PRO/5 CUI development ► Compatibility and interoperability ► 64-bit support ► Microsoft Windows Vista ► Cool features ► Object-oriented programming - details ► Type-checking - details
3
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 3 Enhanced CUI Development in BBj ► Custom objects ► Encryption ► Autorun ► Programmatic access to data dictionary ► Stronger syntax checking ► BBjNamespace – shared memory ► Development tool ► DBMS
4
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 4 Compatibility and Interoperability (BBx Generations) ► Mixing and Matching PRO/5 and BBj using PRO/5 Data Server PRO/5 and BBj using BBj DBMS PRO/5 and BBj using same programs ► Considerations Pinning File locking
5
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 5 64-bit vs. 32-bit ► Buzzword compliant ► Prevalent CPU architecture ► Performance considerations Code base Emulation Arithmetic Encryption
6
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 6
7
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 7 64-bit BBj ► Solaris SPARC ► Solaris Intel/AMD ► AIX POWER ► Linux POWER ► Linux Intel/AMD ► HP-UX ► DEC Alpha ► Windows Intel/AMD
8
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 8
9
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 9 64-bit PRO/5 ► Solaris SPARC ► Solaris Intel/AMD ► AIX POWER ► Linux POWER ► Linux Intel/AMD ► HP-UX ► DEC Alpha
10
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 10 MS Windows Vista Demonstration
11
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 11 Symbolic Labels Demonstration
12
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 12 Command Line Search Demonstration
13
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 13 Command Line History Demonstration
14
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 14 Denum Demonstration
15
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 15 'FMTTEXT' ► BBj 6.0 implements the Visual PRO/5 SYSPRINT mnemonic 'FMTTEXT' Offers useful method for printing forms like purchase orders and invoices Enhances 'FMTTEXT' with detailed control of font attributes including style, size, color, bold, underline, and scaling Provides alternative to BBjForm introduced in BBj 4.0
16
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 16 'FMTTEXT' Code Sample Place formatted text on the page within the region 4¾" from the left edge and 3/8" from the top, with a width of 3½" and a height of 3/8" X=4.75,Y=0.375,W=3.5,H=0.375 A=DEC($1020$); REM ' Alignment rules F$='FONT'("Times New Roman Bold 24") T$=F$+"Purchase Requisition" PRINT (SYSPRINT)'FMTTEXT'(X,Y,W,H,A,T$)
17
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 17 'FMTTEXT' Demonstration
18
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.comsales@basis.comwww.basis.com Object-Oriented Programming Introduction
19
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 19 Introduction to Object-Oriented Programming ► Reusability ► Compartmentalization ► Readability ► Scoping
20
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Why Use Objects? ► Objects closely model the real world A customer object models an actual customer An 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 be evolved over time
21
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 21 A Simple BBj Class ► BBj custom class is a block of code bracketed by the keywords class and classend class public Sample classend ► Class visibility public (visible outside the current program) private (not visible) ► Class names are case-sensitive
22
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 22 A Simple BBj Class ► Class definition class public Sample classend ► Object instantiation of that class mySample! = new Sample() PRINT mySample!
23
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com External Classes ► Class definitions may reside in any file ► Refer to class as ::filename::Classname() rem ' SampleClass.bbj class public Sample classend rem ' Application.bbj Sample!= new ::SampleClass.bbj::Sample()
24
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com The USE Verb ► Tells BBj where to find an external class Include (C++) Import (Java) ► Example reference to external classes rem ' SampleClass.bbj class public Sample classend rem ' Application.bbj use ::SampleClass.bbj::Sample Sample! = new Sample()
25
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 25 The USE Verb ► Tells BBj where to find a Java class ► No need to keep typing the complete name use java.util.ArrayList List! = new ArrayList() ► use statements resolved on program load
26
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Fields ► Fields store Object state information class public Sample field public BBjNumber Value = 1 classend mySample! = new Sample()
27
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Fields ► What does this mean? field public BBjNumber Value = 1
28
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Fields ► What does this mean? field public BBjNumber Value = 1 ► Definition starts with the field keyword ► Must begin on a new line ► Syntax error if outside a class definition
29
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Fields ► What does this mean? field public BBjNumber Value = 1 ► Protection levels available Public - field is visible to everyone Private - field is visible only within the class itself ► Data Hiding is a key object-oriented concept
30
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 30 Fields ► What does this mean? field public BBjNumber Value = 1 ► Data type can be any BBj or Java class ► Special predefined types BBjNumber: Numeric variable (N) BBjString: String variable (S$) BBjInt: Integer variable (I%)
31
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 31 Fields ► What does this mean? field public BBjNumber Value = 1 ► Field name is Value ► Follows BBx/BBj variable naming rules ► Field names are case-sensitive
32
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 32 Fields ► What does this mean? field public BBjNumber Value = 1 ► Optional initialization value ► Default initialization values BBjString = "" BBjNumber and BBjInt = 0 All other objects = null()
33
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Fields ► Field type is specified as a class name ► Simple variable types also have classes ► Normal BBj variable naming rules apply field public BBjNumber Number field private BBjInt Counter% field public BBjString Message$ field private Sample Sample! field public ArrayList List!
34
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 34 Field Accessors ► How do you manipulate the Value field? class public Sample field public BBjNumber Value = 1 classend mySample! = new Sample()
35
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 35 Field Accessors ► Strict control of field Access ► Auto-generated field Accessors setFieldName() getFieldName() mySample! = new Sample() mySample!.setValue(23) print mySample!.getValue()
36
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 36 Field Accessors ► Field visibility is either public or private class public Sample field public BBjNumber Value field private BBjNumber X classend mySample! = new Sample() print mySample!.getValue(); rem ok print mySample!.getX(); rem Error!
37
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 37 Field Accessors ► Field accessors demonstrate key object-oriented concepts Access control Developer controls field accessibility from outside the class Data hiding Implementation modifications have less negative impact if implementation-specific fields are invisible outside the class
38
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Methods ► Objects interact with the world through methods class public Sample method public void Hello() print "Hello, world!" methodend classend
39
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 39 Methods ► Method is a block of code within a class ► Starts with the keyword method ► Ends with the keyword methodend class public Sample method public void Hello() print "Hello, world!" methodend classend
40
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 40 Methods ► Protection level (public or private) indicates method’s accessibility from outside the class class public Sample method public void Hello() print "Hello, world!" methodend classend
41
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 41 Methods ► Return type specifies what kind of value method returns ► Keyword void indicates that no return value class public Sample method public void Hello() print "Hello, world!" methodend classend
42
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 42 Methods ► Method name follows normal variable naming rules ► Method name is case-sensitive class public Sample method public void Hello() print "Hello, world!" methodend classend
43
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 43 Methods ► Parameters (if any) are listed in parentheses after the name ► Sample method with no parameters class public Sample method public void Hello() print "Hello, world!" methodend classend
44
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 44 Invoking A Method class public Sample method public void Hello() print "Hello, world!" methodend classend Sample! = new Sample() Sample!.Hello()
45
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com methodret ► methodret returns a value from a method ► value must be of the correct type class public Sample method public BBjString getHello() methodret "Hello, world!" methodend classend Sample! = new Sample() Hello$ = Sample!.getHello()
46
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Method Parameters ► Methods may have parameters ► Parameters have type and name class public Sample method public void say(BBjString msg$) print msg$ methodend classend Sample! = new Sample() Sample!.say("Hello world!")
47
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 47 Method Parameters ► Methods may take multiple parameters class public Sample method public void say(BBjString msg$, BBjNumber num) print msg$,num methodend classend Sample! = new Sample() Sample!.say("Hello world!",23)
48
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Field Accessors Revisited ► Custom accessors can restrict field access ► User can call getValue(), but not setValue() (Why?) class public Sample field private BBjNumber Value = 1 method public BBjNumber getValue() methodret #Value methodend classend
49
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 49 Referring to Fields ► Class fields use the syntax #Fieldname ► Eliminates ambiguity with other variables class public Sample field private BBjNumber Value = 1 method public BBjNumber getValue() methodret #Value methodend classend
50
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Constructors ► Constructors are special methods implicitly called during class creation ► BBj default constructor class public Sample method public Sample() methodend classend
51
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Contructors ► Constructor takes the name of the class ► Constructor does not show a return type class public Sample method public Sample() methodend classend
52
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Constructors ► Constructors can take parameters class public Sample field public BBjNumber Num method public Sample(BBjNumber Num) #Num = Num methodend classend Sample! = new Sample(42) print Sample!.getNum()
53
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Constructors ► A class can have multiple constructors class public Sample field public BBjNumber MyNumber field public BBjString MyString$ method public Sample(BBjNumber num) #MyNumber = num #MyString$ = "" methodend method public Sample(BBjNumber num, BBjString str$) #MyNumber = num #MyString$ = str$ methodend classend
54
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Constructors ► Constructors can call other constructors class public Sample field public BBjNumber MyNumber field public BBjString MyString$ method public Sample() #this!(0,"") methodend method public Sample(BBjString s$) #this!(0,s$) methodend method public Sample(BBjNumber n, BBjString s$) #MyNumber = n #MyString$ = s$ methodend classend
55
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Constructors ► If a constructor calls another constructor, it must do so before doing anything else method public Sample() rem ' no code can appear here #this!(0,"") methodend
56
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com #this! ► #this! references the current instance of a class
57
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Constructors ► Developer may hide default constructor by overriding it with a private constructor class public Sample field public BBjNumber Num method private Sample() methodend method public Sample(BBjNumber Num) #Num = Num methodend classend ► Why might you do that?
58
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Referencing Class Elements ► The current instance #this! ► A different constructor #this!(...) ► Fields #MyField = Value ► Methods #doSomething() #this!.doSomething()
59
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Static Fields ► A class can include static fields field private static BBjNumber FileChannel ► Shared across all instances of a class ► Created the first time the class is referenced ► Live for the duration of the BBj session
60
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Static Fields class public Customer field private static BBjNumber Channel field private BBjNumber CustNum field private BBjString Name$ method public Customer(BBjNumber num, BBjString name$) if #Channel = 0 then #Channel = unt open (#Channel)"cust" fi #CustNum = num #Name$ = name$ methodend classend
61
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Static Methods ► A class may include static methods method public static BBjNumber getChannel() methodret #Channel methodend
62
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Static Methods ► Can be called on the class class public System field private static BBjNumber SysGui method public Static BBjNumber getSysGui() if #SysGui = 0 then #SysGui = unt open (#SysGui)"X0" fi methodret #SysGui methodend classend sysgui = System.getSysGui()
63
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Static Methods ► Cannot access non-static fields or methods class public System field private BBjString Company$ method public Static BBjString getCompany() methodret #Company$ methodend classend company$ = System.getCompany(); rem ' Error!
64
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Extending Classes ► Class can extend an existing class ► New class inherits all public and protected fields and methods from the class it extends ► Original class is the super class ► New class is a subclass or derived class
65
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Extending Classes ► This is a base class class public Base field public BBjString MyString$ method public Base(BBjString str$) #MyString$ = str$ methodend classend
66
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Extending Classes ► This class is derived, or extended, from Base class public Derived extends Base field public BBjNumber MyNumber method public Derived(BBjString s$,BBjNumber n) #super!(s$) #MyNumber = n methodend method public void print() print #super!.getMyString() print #MyNumber methodend classend
67
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com #super! ► #super! is a reference to the super class ► Constructor in the super class #super!(...) ► Fields of the super class #super!.getFieldName() #super!.setFieldName() ► Methods of the super class #super!.print()
68
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Extending Classes ► Derived class constructor can call a chosen super class constructor ► Derived class constructor does not explicitly call a selected super class constructor, it implicitly calls the default super class constructor ► Call to #super!(), if used, must be the first code in the derived class constructor
69
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com protected ► Fields and methods can be protected field protected BBjNumber Value method protected BBjNumber getValue() ► Protected fields and methods can only be accessed from the current class and any subclasses.
70
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Protection Levels ► Public accessible from within class accessible from subclasses accessible from outside class ► Protected accessible from within class accessible from subclasses ► Private accessible only within class
71
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Interfaces ► Interface is a promise made by a class to implement a set of methods interface public Printable method public BBjNumber getID() method public BBjString getName() method public BBjString getAddress().... interfaceend
72
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Interfaces ► Class implements an interface class public Customer extends Address implements Printable Class must implement all methods of an interface Class can implement multiple interfaces class public Customer extends Address implements Printable,Editable,Searchable
73
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Interfaces ► An interface acts much like a class method Public void printLabel(Printable p!) print p!.getID() print p!.getName()..... ► Interfaces only have methods, not fields ► printLabel(Printable) method accepts any object that implements the Printable interface
74
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 74 What is Type Checking?
75
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 75 Type Checking ► Should object type checking be done at runtime or compile-time? ► Runtime only in earlier versions of BBj ► BBj 6.0 continues to support unchecked object assignments for backward compatibility with existing BBj code ► New options allow for compile-type type checking DECLARE Verb bbjcpl -t -W
76
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Type Checking ► BBj custom class references are type- checked at compile time ► Use the new declare verb to enforce type- checking of object variables declare java.util.HashMap Map! Map! = new java.util.ArrayList(); rem ' Error! ► The BASIS IDE refers to declare statements to implement code completion
77
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Type Checking ► Class fields are type checked ► Type check error attempting to assign a BBjTopLevelWindow object to a BBjChildWindow variable field private BBjChildWindow MyWin! sysgui! = bbjapi().getSysGui() #MyWin! = sysgui!.addWindow(10,10,100,100,"")
78
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Type Checking ► Method parameters are type checked ► Type check error attempting to pass a BBjTopLevelWindow object to a BBjChildWindow parameter sysgui! = bbjapi().getSysGui() win! = sysgui!.addWindow(10,10,100,100,"") #doWork(win!)... method public void doWork(BBjChildWindow win!)
79
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Type Checking ► declare verb enforces type checking ► Type check error attempting to assign a BBjTopLevelWindow object to a BBjChildWindow variable declare BBjChildWindow Win! sysgui!=bbjapi().getSysGui() Win! = sysgui!.addWindow(10,10,100,100,"")
80
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Type Checking ► Why does this work? field private BBjWindow MyWin! sysgui! = bbjapi().getSysGui() #MyWin! = sysgui!.addWindow(10,10,100,100,"") addWindow() returns a BBjTopLevelWindow BBjTopLevelWindow is derived from (extends) BBjWindow Base types are compatible with their own derived types
81
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Type Checking ► Why does this not work? declare BBjButton myButton! declare BBjVector v! open (unt)"X0" sysgui!=bbjapi().getSysGui() win! = sysgui!.addWindow(100,100,100,100,"") v! = bbjapi().makeVector() v!.addItem(win!.addButton(1,10,10,90,25,"OK")) myButton! = v!.getItem(0); rem ' error! ► BBjVector::getItem() returns a java.lang.Object. ► java.lang.Object can't be assigned to a BBjButton variable
82
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Type Checking ► But this works! Why? declare BBjButton myButton! rem ' declare BBjVector v! open (unt)"X0" sysgui!=bbjapi().getSysGui() win! = sysgui!.addWindow(100,100,100,100,"") v! = bbjapi().makeVector() v!.addItem(win!.addButton(1,10,10,90,25,"OK")) myButton! = v!.getItem(0) Undeclared variables (v!) are not type-checked until runtime At runtime, we have a BBjButton, so the assignment succeeds
83
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com Type Checking ► Objects returned from known methods are type checked myWin! = bbjapi().getSysGui().addWindow(...)... method public void doWork(BBjWindow Win!) Win!.setTitle("My new Title") Method call works because BBjTopLevelWindow is a subclass of BBjWindow setTitle(...) fails because it is not a method of BBjWindow, but only of BBjTopLevelWindow
84
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com CAST() Function ► CAST() function treats an object as an instance of a specific class ► cast class must be a superclass of the object's declared type declare BBjButton myButton! declare BBjVector v! v! = new bbjapi().makeVector() v!.addItem(myWin!.addButton(1,10,10,90,25,"OK")) myButton! = cast(BBjButton, v!.getItem(0))
85
©1985-2006 All rights reserved. U.S. 1.800.423.1394 International +1.505.338.4188 Tech Support +1.505.345.5021 sales@basis.com www.basis.com sales@basis.comwww.basis.com 85 Summary ► BBj vs. PRO/5 CUI development ► Compatibility and interoperability ► 64-bit support ► Microsoft Windows Vista ► Cool features ► Object-oriented programming - details ► Type-checking - details
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.