69
1 Introduction

Introduction

  • Upload
    hume

  • View
    19

  • Download
    0

Embed Size (px)

DESCRIPTION

Introduction. Authors: Francis Mariani– Francis Mariani.com (Canada) Susannah Jones– Consultant (United States) Anthony Alsford– EDATA Limited (United Kingdom) Presentation Title: Coding Standards for WebFOCUS Development Abstract: - PowerPoint PPT Presentation

Citation preview

Page 1: Introduction

1

Introduction

Page 2: Introduction

2

Authors:Authors:Francis MarianiFrancis Mariani – Francis Mariani.com (Canada)– Francis Mariani.com (Canada)Susannah JonesSusannah Jones – Consultant (United States)– Consultant (United States)Anthony AlsfordAnthony Alsford – EDATA Limited (United Kingdom)– EDATA Limited (United Kingdom)

Presentation Title:Presentation Title:Coding Standards for WebFOCUS DevelopmentCoding Standards for WebFOCUS Development

Abstract:Abstract:

The Three Virtuosi from three countries, Francis, Susannah, and Anthony, The Three Virtuosi from three countries, Francis, Susannah, and Anthony, combine their near-century of experience to -combine their near-century of experience to -

'Standards in Coding: Structure, Clarity, & Simplicity’.'Standards in Coding: Structure, Clarity, & Simplicity’.

Page 3: Introduction

3

Introduction

Presentation Layer

Questions

Designing the program

Maintainable Code

Page 4: Introduction

4

10. Speed of development.

TOP 10 REASONS FOR STANDARDS IN CODING

9. Simplifies maintenance.

8. Consistent definitions.

6. Passing the baton.

7. Modular / Reuseable code.

Page 5: Introduction

5

3. Quick fix?

TOP 10 REASONS FOR STANDARDS IN CODING

4. Major overhaul?

5. User confidence soars when your site is consistent.

2. Big emergency?

1. @@@@@@@@@@@@@@@@@@@@@@@

Instantly envision the whole thing

Might actually work

Flip a switch, avoid a meltdown

Page 6: Introduction

6

Fex construction

0. dictionary

1. environment variables

2. resource allocation

3. JOINs

4. DEFINEs

5. data extract(s)

6. presentation layer

7. maintainable code

Page 7: Introduction

7

#0. dictionary

● list the dimensions that describe your business ● stabilize the nomenclature

concept data codes &varname keys code names

season SEASON /A1 &SEA SEASON_NAME /A25

style STYLE /A8 &STY KEYSS STYLE_NAME /A25

color COLOR /A3 &CLR KEYSSC COLOR_NAME /A3

division DIV /A2 &DIV DIV_NAME /A25

warehouse WH /A2 &WH KEYSSCW WH_NAME /A25

customer CUST_ID /A5 &CUST KEYSSCWK CUST_NAME /A25

door DOOR_ID /A6 &DOOR KEYKD DOOR_NAME /A25

Page 8: Introduction

8

#0. dictionary

● list the dimensions that describe your business ● stabilize the nomenclature

concept data codes &varname keys code names

season SEASON /A1 &SEA SEASON_NAME /A25

style STYLE /A8 &STY KEYSS STYLE_NAME /A25

color COLOR /A3 &CLR KEYSSC COLOR_NAME /A3

division DIV /A2 &DIV DIV_NAME /A25

warehouse WH /A2 &WH KEYSSCW WH_NAME /A25

customer CUST_ID /A5 &CUST KEYSSCWK CUST_NAME /A25

door DOOR_ID /A6 &DOOR KEYKD DOOR_NAME /A25

as short as possible

Page 9: Introduction

9

#0. dictionary

● list the dimensions that describe your business ● stabilize the nomenclature

concept data codes &varname keys code names

season SEASON /A1 &SEA SEASON_NAME /A25

style STYLE /A8 &STY KEYSS STYLE_NAME /A25

color COLOR /A3 &CLR KEYSSC COLOR_NAME /A3

division DIV /A2 &DIV DIV_NAME /A25

warehouse WH /A2 &WH KEYSSCW WH_NAME /A25

customer CUST_ID /A5 &CUST KEYSSCWK CUST_NAME /A25

door DOOR_ID /A6 &DOOR KEYKD DOOR_NAME /A25

Page 10: Introduction

10

#0. dictionary

● list the dimensions that describe your business ● stabilize the nomenclature

concept data codes &varname keys code names

season SEASON /A1 &SEA SEASON_NAME /A24

style STYLE /A8 &STY KEYSS STYLE_NAME /A24

color COLOR /A3 &CLR KEYSSC COLOR_NAME /A3

division DIV /A2 &DIV DIV_NAME /A24

warehouse WH /A2 &WH KEYSSCW WH_NAME /A24

customer CUST_ID /A5 &CUST KEYSSCWK CUST_NAME /A24

door DOOR_ID /A6 &DOOR KEYKD DOOR_NAME /A24

Page 11: Introduction

11

#0. dictionary

● list the dimensions that describe your business ● stabilize the nomenclature

concept data codes &varname keys code names

season SEASON /A1 &SEA SEASON_NAME /A24

style STYLE /A8 &STY KEYSS STYLE_NAME /A24

color COLOR /A3 &CLR KEYSSC COLOR_NAME /A3

division DIV /A2 &DIV DIV_NAME /A24

warehouse WH /A2 &WH KEYSSCW WH_NAME /A24

customer CUST_ID /A5 &CUST KEYSSCWK CUST_NAME /A24

door DOOR_ID /A6 &DOOR KEYKD DOOR_NAME /A24

● list the measures

as they exist in database different in reports

units UNITS /I8 UNITS/I8S

dollars DOLLARS /D8.2 DOLS/P11.2SM

Page 12: Introduction

12

0. dictionary

1. environment variables

2. resource allocation

3. JOINs

4. DEFINEs

5. data extract(s)

6. presentation layer

7. maintainable code

Fex construction

Page 13: Introduction

13

1. environment variables● initialize parameters

-* makes Dept Status Report for email at 1pm-* second comment line

-SET &FEXNAME='myfex';

-SET &EDITDATE='5.19.07';

-DEFAULT &SEA='FOC_NONE';

-DEFAULT &STY='$*';

-DEFAULT &DIV='ALL';

-DEFAULT &CUST='B2900';

-SET &exrate= 1.20 ;

-SET &DD0 = 'myfex';

-SET &DD1 = 'myfex1';

-SET &server='\\servername\d$\';

for ‘ALL’ values of a variable, use ‘FOC_NONE’, or ‘$*’IF SEASON IS FOC_NONEreturns all valuesnb: SEASON is /A1, so $* is too wide; $* not for numbers

Lower case, more readable

use &FEXNAME in usage logs, &FEXNAME and &EDITDATE in report footings

drill-down fexes

One, 1, comment line at top, documentation at the end !

Page 14: Introduction

14

-SET &FEXNAME='myfex';-SET &EDITDATE='5.19.07';-DEFAULT &SEA='FOC_NONE';-DEFAULT &STY='$*';-DEFAULT &DIV='ALL';-DEFAULT &CUST='B2900';-SET &exrate=1.20 ;-SET &DD0=‘myfex’;

-SET &DD1=‘myfex1’;

-DEFAULT &bydis=‘OFF’ ;

-DEFAULT &shwpic=0 ;

-SET &shwpicx=ABS( &shwpic -1) ;

● line up the equal signs !!!

Page 15: Introduction

15

-SET &FEXNAME = 'myfex';-SET &EDITDATE = '5.19.07';-DEFAULT &SEA = 'FOC_NONE';-DEFAULT &STY = '$*';-DEFAULT &DIV = 'ALL';-DEFAULT &CUST = 'B2900';-SET &exrate = 1.20 ;-SET &DD0 = ‘myfex’;

-SET &DD1 = ‘myfex1’;

-DEFAULT &bydis = ‘OFF’ ;

-DEFAULT &shwpic = 0 ;

-SET &shwpicx = ABS( &shwpic - 1 );

● next, complete your environmental variables

SET ASNAMES = ON

SET LINES = 998

SET PAGE = NOPAGE

SET BYDISPLAY = &bydis

Use 0 and 1 for booleans, not ON and OFF, or YES and NO

● line up the equal signs !!!

but never use TAB key

Page 16: Introduction

16

0. dictionary

1. environment variables

2. resource allocation

3. JOINs

4. DEFINEs

5. data extract(s)

6. presentation layer

7. maintainable code

Fex construction

Page 17: Introduction

17

2. resource allocation

● use input parameters for data directories

USE D:\IBI\APPS\&DIV|\INVENTORY.FOC D:\IBI\APPS\&CUST|\ORDERS2007.FOC AS ORDERS D:\IBI\APPS\&CUST|\ORDERS2006.FOC AS ORDERS \\servername\d$\IBI\APPS\&CUST|\ORDERS2005.FOC AS ORDERSENDFILEDEF DECODEDV DISK &servername|IBI\APPS\DECODEDV.FTM

Page 18: Introduction

18

2. resource allocation

● use input parameters for data directories

USE D:\IBI\APPS\&DIV|\INVENTORY.FOC D:\IBI\APPS\&CUST|\ORDERS2007.FOC AS ORDERS D:\IBI\APPS\&CUST|\ORDERS2006.FOC AS ORDERS \\servername\d$\IBI\APPS\&CUST|\ORDERS2005.FOC AS ORDERSENDFILEDEF DECODEDV DISK &servername|IBI\APPS\DECODEDV.FTM

● make report headers from input parameters use a decode file

-DEFAULT &DIV = ‘DR’;FILEDEF DECODEDV DISK D:\IBI\APPS\DECODEDV.FTM-RUN-SET &headerdiv = IF &DIV IS ‘ALL’ THEN ‘all divisions’

- ELSE DECODE &DIV(DECODEDV);-TYPE &|headerdiv = &headerdiv&headerdiv = Dresses Division

Page 19: Introduction

19

What’s a decode file?Take a look at the EDUCFILE… see how COURSE_NAME is repeated?

Make a DECODECC file

with a code snippet…

TABLE FILE EDUCFILE SUM COMPUTE BLANK/A1 = ' '; COMPUTE NAME/A32 = '''' | COURSE_NAME || '''' ; BY COURSE_CODE ON TABLE SAVE AS DECODECC END

Page 20: Introduction

20

2. resource allocation

● use input parameters for data directories

USE D:\IBI\APPS\&DIV|\INVENTORY.FOC D:\IBI\APPS\&CUST|\ORDERS2007.FOC AS ORDERS D:\IBI\APPS\&CUST|\ORDERS2006.FOC AS ORDERS \\servername\d$\IBI\APPS\&CUST|\ORDERS2005.FOC AS ORDERSENDFILEDEF DECODEDV DISK &servername|IBI\APPS\DECODEDV.FTM

● make report headers from input parameters

FILEDEF DECODEDV DISK D:\IBI\APPS\DECODEDV.FTM-RUN-SET &headerdiv = IF &DIV IS ‘ALL’ THEN ‘all divisions’ - ELSE DECODE &DIV(DECODEDV);

● make filters from input parameters

-SET &FILTERDIV = IF &DIV IS ‘ALL’ THEN ‘ ‘ ELSE- ‘IF DIV IS ‘ | &DIV ;

Page 21: Introduction

21

0. dictionary

1. environment variables

2. resource allocation

3. JOINs

4. DEFINEs

5. data extract(s)

6. presentation layer

7. maintainable code

Fex construction

Page 22: Introduction

22

3. JOINs

● Clear your joins before making new ones; its just a good habit JOIN CLEAR *

● Label your joins JOIN KEY IN host TO KEY IN guest AS JPROD to refer to them specifically, to clear when necessary JOIN CLEAR JPROD

● Use TAG syntax when duplicated field names occur across files it allows you to use syntax as in SQL T1.[fieldname]

JOIN KEY IN INVENTRY TO KEY IN PRODUCT TAG T1 AS JPROD END TABLE FILE SUM ….BY INVENTRY.prod_no BY PRODNAME …or TABLE FILE INVENTORY SUM ….BY T1.inv_no BY PRODNAME

Page 23: Introduction

23

3. JOINs

JOIN SHIP_FROM IN host TO SHIP_CODE IN guest TAG T1 AS JCUST1 JOIN SHIP_TO IN host TO SHIP_CODE IN guest TAG T2 AS JCUST2 END

TABLE FILE host PRINT SHIP_FROM T1.CUSTOMERNAME SHIP_TO T2.CUSTOMERNAME

● Use TAG syntax when joining twice

FIELD=SHIP_CODE,.. $FIELD=SHIP_FROM,.. $FIELD=SHIP_TO, .. $. . .

FIELD=SHIP_CODE, .. $FIELD=CUSTOMERNAME,.. $FIELD=ADDRESS, .. $. . .

Page 24: Introduction

24

0. dictionary

1. environment variables

2. resource allocation

3. JOINs

4. DEFINEs

5. data extract(s)

6. presentation layer

7. maintainable code

Fex construction

Page 25: Introduction

25

4. DEFINEs

● Clear your DEFINES not quite as important JOIN statements clear DEFINE statements DEFINE FILE fn CLEAR DEFINE FILE fn ADD SET KEEPDEFINES ON except…

DEFINE FILE HOLD . . . END TABLE FILE HOLD . . . ON TABLE HOLD END ...

These DEFINEs will still apply to this HOLD file

Page 26: Introduction

26

4. DEFINEs● lowercase DEFINE FILE CAR icost/D8 = IF COUNTRY EQ ‘FRANCE’ THEN COST * &exrate

ELSE COST ; COGS/P11M = icost * SALES ; MN6/A6 = F_MN6('200705'); END

Page 27: Introduction

27

4. DEFINEs● lowercase DEFINE FILE CAR icost/D8 = IF COUNTRY EQ ‘FRANCE’ THEN COST * &exrate

ELSE COST ; COGS/P11M = icost * SALES ; MN6/A6 = F_MN6('200705'); END

● UPPERcase COGS/P11M = icost * SALES ;

Page 28: Introduction

28

4. DEFINEs● lowercase DEFINE FILE CAR icost/D8 = IF COUNTRY EQ ‘FRANCE’ THEN COST * &exrate

ELSE COST ; COGS/P11M = icost * SALES ; MN6/A6 = F_MN6('200705'); END

● UPPERcase COGS/P11M = icost * SALES ;

● define business rules in FUNCTIONs , put in edasprof DEFINE FUNCTION F_MN6(YYM/A6) yy1/A2 = EDIT(YYM,'$$99'); month/A2 = EDIT(YYM,'$$$$99'); mn3/A3 = DECODE month(01 Jan 02 Feb 03 Mar 04 Apr 05 May 06 Jun 07 Jul 08 Aug 09 Sep 10 Oct 11 Nov 12 Dec ELSE ' '); F_MN6/A6 = mn3 | ' ' | yy1 ; END MN6/A6=F_MN6('200705'); - - -> May 07

Page 29: Introduction

29

#0. dictionary● list the dimensions that describe your business ● stabilize the nomenclature concept data codes &varname keys code names

season SEASON /A1 &SEA SEASON_NAME /A24

style STYLE /A8 &STY KEYSS STYLE_NAME /A24

color COLOR /A3 &CLR KEYSSC COLOR_NAME /A3

division DIV /A2 &DIV DIV_NAME /A24

warehouse WH /A2 &WH KEYSSCW WH_NAME /A24

customer CUST_ID /A5 &CUST KEYSSCWK CUST_NAME /A24

door DOOR_ID /A6 &DOOR KEYKD DOOR_NAME /A24

● list the measures as they exist in database different in reports

units UNITS /I8 UNITS/I8S

dollars DOLLARS /D8.2 DOLS/P11.2SM

cost of goods sold COGS/P11M

● and functionsdisplay date

YYM /A6 F_YYM/A6 e.g. 200705 -> May 07

Page 30: Introduction

30

0. dictionary

1. environment variables

2. resource allocation

3. JOINs

4. DEFINEs

5. data extract(s)

6. presentation layer

7. maintainable code

Fex construction

Page 31: Introduction

31

5. EXTRACT● filters in the first phase

TABLE FILE CAR &FILTERCAR &FILTERCNTRY &FILTERSEATS

SUM SALES BY COUNTRY BY CARON TABLE HOLD

12-character name limit

● the interim HOLD file, name it something other than HOLD

TABLE FILE CAR &FILTERCAR . . .

SUM SALES BY COUNTRY BY CARON TABLE HOLD AS HCAR1END

TABLE FILE HCAR1SUM SALES BYON TABLE HOLD AS HCAR2END

went away!

-RUN

Page 32: Introduction

32

5. EXTRACT● lowercase for branching, easier to separate from the true body of your logic.

TABLE FILE CARSUM-GOTO by.&BYFIELD ;-by.COUNTRYBY COUNTRY AS ‘manufacturing country’-GOTO by.end ;-by.CARBY CAR AS ‘car’-GOTO by.end ;-by.end

ON TABLE. . . END

-RUN -IF &FOCERRNUM NE 0 THEN GOTO . . . ● check for compile errors after every paragraph , and handle… so that your fex doesn’t continue, and process incorrectly.

Page 33: Introduction

33

5. EXTRACTReadability: Its all about readability. Next year when you go back to look at your fex, the more readable you’ve made it, the faster you’ll remember what you did .

● align your AS phrases:SUMFIELDONE AS ‘some nice label’FLDTWO AS ‘some other label’

Page 34: Introduction

34

5. EXTRACTReadability: Its all about readability. Next year when you go back to look at your fex, the more readable you’ve made it, the faster you’ll remember what you did .

● align your AS phrases:SUMFIELDONE AS ‘some nice label’FLDTWO AS ‘some other label’

● separate lines for fieldnames, easier to count columns for your compute statements.

SUMFIELDONE AS ‘some nice label’FLDTWO AS ‘some other label’FLD3 AS ‘some nice title’COMPUTE FLD4/I8=C1+C2+C3; AS ‘nice summary’

Page 35: Introduction

35

5. EXTRACT● conditional display:

-SET &field1np = IF … THEN ‘ ‘ ELSE ‘ NOPRINT ‘; -SET &fieldtwonp = IF … THEN ‘ ‘ ELSE ‘-*’; SUM FIELDONE AS ‘some nice label’ &field1np &fieldtwonp.EVAL FLDTWO AS ‘some other label’

Page 36: Introduction

36

5. EXTRACT ● conditional display:

-SET &field1np = IF … THEN ‘ ‘ ELSE ‘ NOPRINT ‘; -SET &field2np = IF … THEN ‘ ‘ ELSE ‘-*’; SUM FIELDONE AS ‘some nice label’ &field1np &field2np.EVAL FLDTWO AS ‘some other label’

Page 37: Introduction

37

5. EXTRACT● conditional display:

-SET &field1np = IF … THEN ‘ ‘ ELSE ‘ NOPRINT ‘; -SET &field2np = IF … THEN ‘ ‘ ELSE ‘-*’; SUM FIELDONE AS ‘some nice label’ &field1np &field2np.EVAL FLDTWO AS ‘some other label’

● in-line documentation

-SET &field1np = IF … THEN ‘ ‘ ELSE ‘ NOPRINT ‘; -SET &field2np = IF … THEN ‘ ‘ ELSE ‘-*’; -* lower case and right SUM FIELDONE AS ‘some nice label’ &field2np &field2np.EVAL FLDTWO AS ‘some other label’ -* . . . . . . . . . . . . . . . . . . added for Lucy 9/07 AND COMPUTE RATE/D3%=FIELDONE/FLDTWO;

Page 38: Introduction

38

5. EXTRACT● drilldowns: The payoff for short names and boolean switches

character length of a url in IE is limited to

focexec=&DD0(SEA = ‘&SEA’ DIV=‘&DIV’ CUST=‘&CUST’ \ STY = ‘&STY’ SHWPIC= &SHWPIC ) , $ TYPE=CUSTOMERNAME, DRILLMENUITEM=‘click for picture’, focexec=&DD0(SEA = ‘&SEA’ DIV=‘&DIV’ CUST= CUSTID \ STY = ‘&STY’ SHWPIC= &SHWPICX ) , DRILLMENUITEM=‘click for detail’, focexec=&DD1(SEA = ‘&SEA’ DIV=‘&DIV’ CUST= CUSTID \ STY = ‘&STY’ SHWPIC= &SHWPIC ) , $

~2k

Page 39: Introduction

39

5. EXTRACT● drilldowns: The payoff for short names and booleans.

character length is limited to ~ 2k

focexec=&DD0(SEA = ‘&SEA’ DIV=‘&DIV’ CUST=‘&CUST’ \ STY = ‘&STY’ SHWPIC= &SHWPIC ) , $ TYPE=CUSTOMERNAME, DRILLMENUITEM=‘click for picture’, focexec=&DD0(SEA = ‘&SEA’ DIV=‘&DIV’ CUST= CUSTID \ STY = ‘&STY’ SHWPIC= &SHWPICX ) , DRILLMENUITEM=‘click for detail’, focexec=&DD1(SEA = ‘&SEA’ DIV=‘&DIV’ CUST= CUSTID \ STY = ‘&STY’ SHWPIC= &SHWPIC ) , $

● Elegant code is beautiful, fun to write, but self-indulgent.

Clarity and self-documenting code beats elegance.

Page 40: Introduction

40

0. dictionary

1. environment variables

2. resource allocation

3. JOINs

4. DEFINEs

5. data extract(s)

6. presentation layer

7. maintainable code

Fex construction

Page 41: Introduction

41

• Importance of Presentation

– A well presented layout will have

• The heading identifying the content

• The user able to discern the facts from the report

• Enough information about the report

– program, date and time, user, pages etc.

• Readability without aides

• Due consideration to colour usage

– Using Company colour scheme to promote Corporate image

– Garish colours do not encourage end users to utilise reports

– Too many colours can detract from content

– Differing output formats do not support certain colours

– Use colour codes instead of names

– Printed / Viewed only report requirements

– Excessive colours can be expensive on toner!!

6. Presentation Layer

Page 42: Introduction

42

• Report Sections

– Heading

• Corporate Image?

• Report title(s)

– Domain (Department?)

– Reporting Group

– Report description

– Report level – Summary, Detail

• Parameters

– Date range selections

– Verbose text not codes

Report Parameter 8Report Parameter 7

Report Parameter 6Report Parameter 5

Report Parameter 4Report Parameter 3

Report Parameter 2Report Parameter 1

Report Dates

Report Subheading 3

Report Subheading 2

Report Subheading 1

Report Heading

Page 43: Introduction

43

• Report Sections

– Footing

• Date and time of creation

– Know to which time frame the report relates

• User identity

– Who created the report

» Batch

» Individual via portal

• Page numbering

– What page is this?

– How many pages?

• Data sensitivity

– Commercial in Confidence

• Program information?

– Consider support requirements as well

Produced by: UserId Page x of y Created on : Date at Time

Page 44: Introduction

44

• Report Sections

– Report Body

• Well laid out

– Can the User discern the facts?

– Is the report easily readable

» Report audience with disabilities

• Consider disparate output pitfalls

– Image locations differ between HTML and PDF

» URL resource or embedded

– Is the report paneled in PDF?

» Have different report layouts with Sub Heads on sort fields

» SQUEEZE or WRAP wide columns

» Output via Report Caster (Report Broker)

– Single Excel output

» SET PAGE-NUM = OFF

– Multiple worksheet bursting

» ON TABLE PCHOLD FORMAT EXL2K BYTOC

• Data density - Verbose or sparse

– BYDISPLAY

Page 45: Introduction

45

• Report Styling

– Content - colouring, imaging and report usage

• Corporate colour scheme

• Avoid garish colours

– Red and Green together – Ugh!

• Images and / or Corporate logo

– Avoid domination of report heading

• Data type styling

– Negative values

» Braced

» Coloured red

• Fonts and Sizing

– Three (generally available) main faces – arial, verdana, trebuchet

– Disparate output formats

– Special report usage

» OCR

• Printing a report

– Will the report print equally as well in colour as mono?

RED GREENRED GREEN

Page 46: Introduction

46

• Report Styling

– Specific tips on using colours

• Use codes instead of names

– Use Web page advice

» Using “websafe” colour ranges

» #00, #33, #66, #99, #CC, #FF

– Some colour printers are not able to discriminate

» Closely related colours print the same

• Do not use too many colours

– Can make a report unbearable to view

– Some people have Colour blindness

– Fonts and Sizing

• Are internal reports to be styled differently to external?

– Separate styling code modules (CSS, WebFOCUS Style etc.)

• Report special usage

– Disabled person(s) as target audience

– Particular layout requirement (e.g. OCR)

Colorsontheweb.com

Page 47: Introduction

47

0. dictionary

1. environment variables

2. resource allocation

3. JOINs

4. DEFINEs

5. data extract(s)

6. presentation layer

7. maintainable code

Fex construction

Page 48: Introduction

48

• Design of components

– Flexibility of report static components

• Header, Footer, Imagery

• Image physical locations for differing output formats

– PDF and HTML require different locations

– Will the report be used via Report Caster

» Well formed or complete URLs (excl. PDF)

• Parameterise

• Well formed and laid out

– Program synopsis in header

– Indentation

– Code blocks

– Aligned

– Commented (Documented)

– Consistent

7. Maintainable Code

Page 49: Introduction

49

Report Parameter 8Report Parameter 7

Report Parameter 6Report Parameter 5

Report Parameter 4Report Parameter 3

Report Parameter 2Report Parameter 1

Report Dates

Report Subheading 3

Report Subheading 2

Report Subheading 1

Report Heading

Produced by: UserId Page x of y Created on : Date at Time

An example– A typical report layout

Page 50: Introduction

50

FOOTING BOTTOM "Produced by: &Userid <+0>Page:<TABPAGENO of <TABLASTPAGE<+0>Created on: &RepDate at &RepTime"

HEADING " <+0 &Rep_Heading" " <+0 &Rep_Heading1" " <+0 &Rep_Heading2" " <+0 &Rep_Heading3" "&Rep_Dates <+0 "-* Only show those parameter lines that contain data.-IF &Rep_Parms1.LENGTH LE 1 AND &Rep_Parms2.LENGTH LE 1 THEN :SkipPrm1; "&Rep_Parms1 <+0>&Rep_Parms2"-:SkipPrm1;-IF &Rep_Parms3.LENGTH LE 1 AND &Rep_Parms4.LENGTH LE 1 THEN :SkipPrm2; "&Rep_Parms3 <+0>&Rep_Parms4"-:SkipPrm2;-IF &Rep_Parms5.LENGTH LE 1 AND &Rep_Parms6.LENGTH LE 1 THEN :SkipPrm3; "&Rep_Parms5 <+0>&Rep_Parms6"-:SkipPrm3;-IF &Rep_Parms7.LENGTH LE 1 AND &Rep_Parms8.LENGTH LE 1 THEN :SkipPrm4; "&Rep_Parms7 <+0>&Rep_Parms8"-:SkipPrm4;

An example – Coding the “flexible” heading and footing

Page 51: Introduction

51

-* Default report variables to ensure focexec doesn't prompt or fail-DEFAULT &WFFMT = 'HTML'-DEFAULT &Rep_Heading = 'Possible WebFOCUS Standard'-DEFAULT &Rep_Heading1 = ''-DEFAULT &Rep_Heading2 = ''-DEFAULT &Rep_Heading3 = 'Reporting Criteria:'-DEFAULT &Rep_Dates = ''-DEFAULT &Rep_Parms1 = '' , &Rep_Parms2 = '' , &Rep_Parms3 = '' , &Rep_Parms4 = ''-DEFAULT &Rep_Parms5 = '' , &Rep_Parms6 = '' , &Rep_Parms7 = '' , &Rep_Parms8 = ''-SET &Userid = GETUSER(USERID);-SET &RepDate = &DATEtDMYY;-SET &RepTime = EDIT(&TOD,'99$:99$:99');

An example – Default variables used in heading and footing

Page 52: Introduction

52

TYPE=HEADING, LINE=1, ITEM=1, CLASS=Headline1a, WIDTH=1.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=14,$TYPE=HEADING, LINE=1, ITEM=2, CLASS=Headline1b, WIDTH=5.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=14,$TYPE=HEADING, LINE=2, ITEM=1, CLASS=HeadLine2a, WIDTH=1.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=12,$TYPE=HEADING, LINE=2, ITEM=2, CLASS=HeadLine2b, WIDTH=5.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=12,$TYPE=HEADING, LINE=3, ITEM=1, CLASS=HeadLine3a, WIDTH=1.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=10,$TYPE=HEADING, LINE=3, ITEM=2, CLASS=HeadLine3b, WIDTH=5.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=10,$TYPE=HEADING, LINE=4, ITEM=1, CLASS=HeadLine4, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=10,$TYPE=HEADING, LINE=4, ITEM=2, CLASS=HeadLine4, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=10,$TYPE=HEADING, LINE=5, ITEM=1, CLASS=HeadLine5, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=5, ITEM=2, CLASS=HeadLine5, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=6, ITEM=1, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=6, ITEM=2, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=7, ITEM=1, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=7, ITEM=2, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=8, ITEM=1, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=8, ITEM=2, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=9, ITEM=1, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=9, ITEM=2, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$

TYPE=FOOTING, LINE=1, ITEM=1, CLASS=FootPart1, WIDTH=2.62, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$ TYPE=FOOTING, LINE=1, ITEM=2, CLASS=FootPart2, WIDTH=0.90, JUSTIFY=RIGHT, STYLE=BOLD, SIZE=8,$ TYPE=FOOTING, LINE=1, ITEM=3, CLASS=FootPart3, WIDTH=0.15, JUSTIFY=CENTER, STYLE=BOLD, SIZE=8,$TYPE=FOOTING, LINE=1, ITEM=4, CLASS=FootPart3, WIDTH=0.15, JUSTIFY=CENTER, STYLE=BOLD, SIZE=8,$TYPE=FOOTING, LINE=1, ITEM=5, CLASS=FootPart3, WIDTH=0.15, JUSTIFY=CENTER, STYLE=BOLD, SIZE=8,$TYPE=FOOTING, LINE=1, ITEM=6, CLASS=FootPart4, WIDTH=3.37, JUSTIFY=RIGHT, STYLE=BOLD, SIZE=8,$

An example – WebFOCUS style sheet - cover main output formats

Page 53: Introduction

53

.HeadLine1a {font-family:Tahoma; font-size:14pt; font-weight:bold; color:#000000; background-color:#FFFFFF; width:29%; text-align:left; border-style: NONE;}.HeadLine1b {font-family:Tahoma; font-size:14pt; font-weight:bold; color:#000000; background-color:#FFFFFF; width:69%; text-align:left; border-style: NONE;}.HeadLine2a {font-family:Tahoma; font-size:12pt; font-weight:bold; color:#000000; background-color:#FFFFFF; width:29%; text-align:left; border-style: NONE;}.HeadLine2b {font-family:Tahoma; font-size:12pt; font-weight:bold; color:#000000; background-color:#FFFFFF; width:69%; text-align:left; border-style: NONE;}.HeadLine3a {font-family:Tahoma; font-size:10pt; font-weight:bold; color:#000000; background-color:#FFFFFF; width:29%; text-align:left; border-style: NONE;}.HeadLine3b {font-family:Tahoma; font-size:10pt; font-weight:bold; color:#000000; background-color:#FFFFFF; width:69%; text-align:left; border-style: NONE;}.HeadLine4 {font-family:Tahoma; font-size:10pt; font-weight:bold; color:#000000; background-color:#FFFFFF; width:49%; text-align:left; border-style: NONE;}.HeadLine5 {font-family:Tahoma; font-size:8pt; font-weight:bold; color:#000000; background-color:#FFFFFF; width:49%; text-align:left; border-style: NONE;}.HeadLine6 {font-family:Tahoma; font-size:8pt; font-weight:bold; color:#000000; background-color:#FFFFFF; width:49%; text-align:left; vertical-align:middle; border-style: NONE;}

.FootPart1 {font-family:Tahoma; font-size:8pt; font-weight:normal; color:#000000; background-color:#FFFFFF; width:35%; text-align:left; border-style: NONE;}.FootPart2 {font-family:Tahoma; font-size:8pt; font-weight:normal; color:#000000; background-color:#FFFFFF; width:12%; text-align:right; border-style: NONE;}.FootPart3 {font-family:Tahoma; font-size:8pt; font-weight:normal; color:#000000; background-color:#FFFFFF; width:2%; text-align:center; border-style: NONE;}.FootPart4 {font-family:Tahoma; font-size:8pt; font-weight:normal; color:#000000; background-color:#FFFFFF; width:45%; text-align:right; border-style: NONE;}

An example – Using external Cascading Style Sheets – HTML control

Page 54: Introduction

55

• Reusability of components

– Coding modules

• Parameterise

• Reduction of maintenance

– One change fixes all

• Decreases development time

– Ease of Usage by Power Users in End User reporting

– Consistency across BI

• Easier learning curve

– of learning complexities of style sheets

7. Reusable Code

Page 55: Introduction

56

-INCLUDE std_initDEFINE FILE CAR IMG/A36 WITH COUNTRY MISSING ON = IF '&WFFMT' EQ 'EXL2K' THEN '<img src=&ImageFile border=0>' ELSE MISSING;ENDTABLE FILE CARSUM RCOST AS 'Retail Cost' DCOST AS 'Dealer Cost' BY COUNTRY AS 'Country'SUM RCOST AS 'Retail Cost' DCOST AS 'Dealer Cost' BY COUNTRY BY CAR AS 'Car'SUM RCOST AS 'Retail Cost' DCOST AS 'Dealer Cost' BY COUNTRY BY CAR BY MODEL AS 'Model'-INCLUDE std_head-INCLUDE std_footON TABLE PCHOLD FORMAT &WFFMTON TABLE SET HTMLCSS ONON TABLE SET STYLE *-INCLUDE std_styleENDSTYLEEND-RUN

-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *-* Focexec: std_init.fex-*-* Author: Anthony Alsford - EDATA Limited-*-* Date: 29 August 2006-*-* Project: IBI User Conference 2007-* WebFOCUS Reporting Standards-*-* Purpose: Provide initialisation procedure for standard-* reporting within WebFOCUS.-*-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *-DEFAULT &WFFMT = 'HTML'-SET &ImageFile = IF '&WFFMT.EVAL' EQ 'PDF' THEN 'web.gif' ELSE '/ibi_html/web.gif';-SET &ImagePos = IF '&WFFMT.EVAL' EQ 'PDF' THEN ' POSITION=(5.50 0.00), ' ELSE '';-DEFAULT &Rep_Heading = 'Focus on Developers'-DEFAULT &Rep_Heading1 = 'Thought provoking Style'-DEFAULT &Rep_Heading2 = ''-DEFAULT &Rep_Dates = ''-DEFAULT &Rep_Parms1 = '' , &Rep_Parms2 = '' , &Rep_Parms3 = '' , &Rep_Parms4 = ''-DEFAULT &Rep_Parms5 = '' , &Rep_Parms6 = '' , &Rep_Parms7 = '' , &Rep_Parms8 = ''-SET &Userid = GETUSER(USERID);-SET &RepDate = &DATEtDMYY;-SET &RepTime = EDIT(&TOD,'99$:99$:99');-RUNSET CSSURL = '/approot/standards/standard.css'SET HTMLCSS = ONSET NODATA = ''

Reducing code development and maintenance timings

Page 56: Introduction

57

-INCLUDE std_initDEFINE FILE CAR IMG/A36 WITH COUNTRY MISSING ON = IF '&WFFMT' EQ 'EXL2K' THEN '<img src=&ImageFile border=0>' ELSE MISSING;ENDTABLE FILE CARSUM RCOST AS 'Retail Cost' DCOST AS 'Dealer Cost' BY COUNTRY AS 'Country'SUM RCOST AS 'Retail Cost' DCOST AS 'Dealer Cost' BY COUNTRY BY CAR AS 'Car'SUM RCOST AS 'Retail Cost' DCOST AS 'Dealer Cost' BY COUNTRY BY CAR BY MODEL AS 'Model'-INCLUDE std_head-INCLUDE std_footON TABLE PCHOLD FORMAT &WFFMTON TABLE SET HTMLCSS ONON TABLE SET STYLE *-INCLUDE std_styleENDSTYLEEND-RUN

-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *-* Focexec: std_head.fex-*-* Author: Anthony Alsford - EDATA Limited-*-* Date: 29 August 2006-*-* Project: IBI User Conference 2007-* WebFOCUS Reporting Standards-*-* Purpose: Provide standard heading using variable-* reporting within WebFOCUS.-*-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *HEADING " <+0 &Rep_Heading" " <+0 &Rep_Heading1" " <+0 &Rep_Heading2" " <+0 &Rep_Heading3" "&Rep_Dates <+0 "-* Only show those parameter lines that contain data.-IF &Rep_Parms1.LENGTH LE 1 AND &Rep_Parms2.LENGTH LE 1 THEN :SkipPrm1; "&Rep_Parms1 <+0>&Rep_Parms2"-:SkipPrm1;-IF &Rep_Parms3.LENGTH LE 1 AND &Rep_Parms4.LENGTH LE 1 THEN :SkipPrm2; "&Rep_Parms3 <+0>&Rep_Parms4"-:SkipPrm2;-IF &Rep_Parms5.LENGTH LE 1 AND &Rep_Parms6.LENGTH LE 1 THEN :SkipPrm3; "&Rep_Parms5 <+0>&Rep_Parms6"-:SkipPrm3;-IF &Rep_Parms7.LENGTH LE 1 AND &Rep_Parms8.LENGTH LE 1 THEN :SkipPrm4; "&Rep_Parms7 <+0>&Rep_Parms8"-:SkipPrm4;

Reducing code development and maintenance timings

Page 57: Introduction

58

-INCLUDE std_initDEFINE FILE CAR IMG/A36 WITH COUNTRY MISSING ON = IF '&WFFMT' EQ 'EXL2K' THEN '<img src=&ImageFile border=0>' ELSE MISSING;ENDTABLE FILE CARSUM RCOST AS 'Retail Cost' DCOST AS 'Dealer Cost' BY COUNTRY AS 'Country'SUM RCOST AS 'Retail Cost' DCOST AS 'Dealer Cost' BY COUNTRY BY CAR AS 'Car'SUM RCOST AS 'Retail Cost' DCOST AS 'Dealer Cost' BY COUNTRY BY CAR BY MODEL AS 'Model'-INCLUDE std_head-INCLUDE std_footON TABLE PCHOLD FORMAT &WFFMTON TABLE SET HTMLCSS ONON TABLE SET STYLE *-INCLUDE std_styleENDSTYLEEND-RUN

-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *-* Focexec: std_foot.fex-*-* Author: Anthony Alsford - EDATA Limited-*-* Date: 29 August 2006-*-* Project: IBI User Conference 2007-* WebFOCUS Reporting Standards-*-* Purpose: Provide standard footing using variable-* reporting within WebFOCUS.-*-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *FOOTING BOTTOM "Produced by: &Userid <+0>Page:<TABPAGENO of <TABLASTPAGE<+0>Created on: &RepDate at &RepTime"

Reducing code development and maintenance timings

Page 58: Introduction

59

-INCLUDE std_initDEFINE FILE CAR IMG/A36 WITH COUNTRY MISSING ON = IF '&WFFMT' EQ 'EXL2K' THEN '<img src=&ImageFile border=0>' ELSE MISSING;ENDTABLE FILE CARSUM RCOST AS 'Retail Cost' DCOST AS 'Dealer Cost' BY COUNTRY AS 'Country'SUM RCOST AS 'Retail Cost' DCOST AS 'Dealer Cost' BY COUNTRY BY CAR AS 'Car'SUM RCOST AS 'Retail Cost' DCOST AS 'Dealer Cost' BY COUNTRY BY CAR BY MODEL AS 'Model'-INCLUDE std_head-INCLUDE std_footON TABLE PCHOLD FORMAT &WFFMTON TABLE SET HTMLCSS ONON TABLE SET STYLE *-INCLUDE std_styleENDSTYLEEND-RUN

-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *-* Focexec: std_style.fex-*-* Author: Anthony Alsford - EDATA Limited-*-* Date: 29 August 2006-*-* Project: IBI User Conference 2007-* WebFOCUS Reporting Standards-*-* Purpose: Provide standard styling using variable-* reporting within WebFOCUS.-*-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * UNITS=IN, PAGESIZE='A4', LEFTMARGIN=0.20, RIGHTMARGIN=0.20, TOPMARGIN=0.20, BOTTOMMARGIN=0.20, SQUEEZE=ON, ORIENTATION=PORTRAIT, BACKCOLOR=RGB(240 245 255),$TYPE=HEADING, IMAGE=&ImageFile, CLASS=HeadImg, SIZE=(2.25 0.45), &ImagePos$TYPE=HEADING, BORDER=LIGHT, BORDER-STYLE=SOLID, SIZE=8, BACKCOLOR='WHITE', STYLE=BOLD,$TYPE=HEADING, LINE=1, ITEM=1, CLASS=Headline1a, WIDTH=1.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=14,$TYPE=HEADING, LINE=1, ITEM=2, CLASS=Headline1b, WIDTH=5.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=14,$TYPE=HEADING, LINE=2, ITEM=1, CLASS=HeadLine2a, WIDTH=1.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=12,$TYPE=HEADING, LINE=2, ITEM=2, CLASS=HeadLine2b, WIDTH=5.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=12,$TYPE=HEADING, LINE=3, ITEM=1, CLASS=HeadLine3a, WIDTH=1.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=10,$TYPE=HEADING, LINE=3, ITEM=2, CLASS=HeadLine3b, WIDTH=5.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=10,$TYPE=HEADING, LINE=4, ITEM=1, CLASS=HeadLine4, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=10,$TYPE=HEADING, LINE=4, ITEM=2, CLASS=HeadLine4, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=10,$TYPE=HEADING, LINE=5, ITEM=1, CLASS=HeadLine5, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=5, ITEM=2, CLASS=HeadLine5, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=6, ITEM=1, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=6, ITEM=2, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=7, ITEM=1, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=7, ITEM=2, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=8, ITEM=1, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=8, ITEM=2, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=9, ITEM=1, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=HEADING, LINE=9, ITEM=2, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=FOOTING, LINE=1, ITEM=1, CLASS=FootPart1, WIDTH=2.62, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$TYPE=FOOTING, LINE=1, ITEM=2, CLASS=FootPart2, WIDTH=1.05, JUSTIFY=CENTER, STYLE=BOLD, SIZE=8,$TYPE=FOOTING, LINE=1, ITEM=3, CLASS=FootPart3, WIDTH=0.15, JUSTIFY=CENTER, STYLE=BOLD, SIZE=8,$TYPE=FOOTING, LINE=1, ITEM=4, CLASS=FootPart3, WIDTH=0.15, JUSTIFY=CENTER, STYLE=BOLD, SIZE=8,$TYPE=FOOTING, LINE=1, ITEM=5, CLASS=FootPart3, WIDTH=0.15, JUSTIFY=CENTER, STYLE=BOLD, SIZE=8,$TYPE=FOOTING, LINE=1, ITEM=6, CLASS=FootPart4, WIDTH=3.37, JUSTIFY=RIGHT, STYLE=BOLD, SIZE=8,$

Reducing code development and maintenance timings

Page 59: Introduction

60

Resulting in consistent look and feel and highly maintainable code

Page 60: Introduction

61

3. Quick fix?

TOP 10 REASONS FOR STANDARDS IN CODING

4. Major overhaul?

5. User confidence soars when your site is consistent.

2. Big emergency?

1. @@@@@@@@@@@@@@@@@@@@@@@

Instantly envision the whole thing

1. SO THAT YOU CAN READ YOUR OWN CODE!

Might actually work

Flip a switch, avoid a meltdown

Page 61: Introduction

62

Report Caster good idea

killcast.fex

-SET &&KILLRPC = ‘N’ ;

Page 62: Introduction

63

Report Caster good idea

Make a backup copy of your empty Caster log file, on the day you first install

To purge your caster log,stop caster, and overwrite your botlog files from your backup; Faster than ‘Purge’

Page 63: Introduction

64

Report Caster good idea

Get the .gifs out of the .war file

Faster loading, if you have to get in on a dial- up line

Page 64: Introduction

65

MRE good idea - names

Don’t do this!Don’t name your domain, your report group, your folder, or your fex with its long, display name

Page 65: Introduction

66

MRE good idea - names

Do name your domain with a nice directory name, . . .

Page 66: Introduction

67

MRE good idea - names

… then give the nice long display name in the Properties Box

Page 67: Introduction

68

MRE good idea - names

Display name sorts in alpha order, True domain directory name is unchanged.

Page 68: Introduction

69

MRE good idea - names

Number your fexes in run order

Mre’s random fex names are for temp work, only

Page 69: Introduction

71

“Things should be made as simple as possible, but no simpler” — Albert Einstein 1933