1 / 69

Introduction

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:

hume
Download Presentation

Introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction

  2. 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: • The Three Virtuosi from three countries, Francis, Susannah, and Anthony, combine their near-century of experience to - • 'Standards in Coding: Structure, Clarity, & Simplicity’.

  3. Introduction Designing the program Presentation Layer Maintainable Code Questions

  4. 6. Passing the baton. 7. Modular / Reuseable code. 8. Consistent definitions. 9. Simplifies maintenance. 10. Speed of development. TOP 10 REASONS FOR STANDARDS IN CODING

  5. 1. @@@@@@@@@@@@@@@@@@@@@@@ 2. Big emergency? Flip a switch, avoid a meltdown 3. Quick fix? Might actually work 4. Major overhaul? Instantly envision the whole thing 5. User confidence soars when your site is consistent. TOP 10 REASONS FOR STANDARDS IN CODING

  6. Fex construction • 0. dictionary • 1. environment variables • 2. resource allocation • 3. JOINs • 4. DEFINEs • 5. data extract(s) • presentation layer • maintainable code

  7. #0. dictionary ● list the dimensions that describe your business ● stabilize the nomenclature

  8. #0. dictionary ● list the dimensions that describe your business ● stabilize the nomenclature as short as possible

  9. #0. dictionary ● list the dimensions that describe your business ● stabilize the nomenclature

  10. #0. dictionary ● list the dimensions that describe your business ● stabilize the nomenclature

  11. #0. dictionary ● list the dimensions that describe your business ● stabilize the nomenclature ● list the measures

  12. Fex construction • 0. dictionary • 1. environment variables • 2. resource allocation • 3. JOINs • 4. DEFINEs • 5. data extract(s) • presentation layer • maintainable code

  13. use &FEXNAME in usage logs, &FEXNAMEand &EDITDATE in report footings 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 drill-down fexes 1. environment variables ● initialize parameters One, 1, comment line at top, documentation at the end !

  14. ● line up the equal signs !!!

  15. ● line up the equal signs !!! but never use TAB key Use 0and1for booleans, not ON and OFF, or YES and NO

  16. Fex construction • 0. dictionary • 1.environment variables • 2.resource allocation • 3. JOINs • 4. DEFINEs • 5. data extract(s) • presentation layer • maintainable code

  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

  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

  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

  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 ;

  21. Fex construction • 0. dictionary • 1.environment variables • 2. resource allocation • 3.JOINs • 4. DEFINEs • 5. data extract(s) • presentation layer • maintainable code

  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

  23. 3. JOINs ● Use TAG syntax when joining twice FIELD=SHIP_CODE,.. $ FIELD=SHIP_FROM,.. $ FIELD=SHIP_TO, .. $. . . FIELD=SHIP_CODE, .. $ FIELD=CUSTOMERNAME,.. $ FIELD=ADDRESS, .. $. . . 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

  24. Fex construction • 0. dictionary • 1.environment variables • 2. resource allocation • 3. JOINs • 4. DEFINEs • 5. data extract(s) • presentation layer • maintainable code

  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

  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

  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● UPPERcaseCOGS/P11M = icost * SALES ;

  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● UPPERcaseCOGS/P11M = icost * SALES ; ● define business rules in FUNCTIONs , put in edasprofDEFINE 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

  29. #0. dictionary ● list the dimensions that describe your business ● stabilize the nomenclature ● list the measures

  30. Fex construction • 0. dictionary • 1.environment variables • 2. resource allocation • 3. JOINs • 4. DEFINEs • 5.data extract(s) • presentation layer • maintainable code

  31. 5. EXTRACT ● filters in the first phaseTABLE FILE CAR &FILTERCAR &FILTERCNTRY &FILTERSEATS SUM SALES BY COUNTRY BY CAR ON TABLE HOLD 12-character name limit went away! ● the interim HOLD file, name it something other than HOLDTABLE FILE CAR &FILTERCAR . . . SUM SALES BY COUNTRY BY CAR ON TABLE HOLD AS HCAR1 END TABLE FILE HCAR1 SUM SALES BY ON TABLE HOLD AS HCAR2 END -RUN

  32. 5. EXTRACT ● lowercase for branching, easier to separate from the true body of your logic. TABLE FILE CAR SUM -GOTO by.&BYFIELD ; -by.COUNTRY BY COUNTRY AS ‘manufacturing country’ -GOTO by.end ; -by.CAR BY 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.

  33. 5. EXTRACT Readability: 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: SUM FIELDONE AS ‘some nice label’ FLDTWO AS ‘some other label’

  34. 5. EXTRACT Readability: 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: SUM FIELDONE AS ‘some nice label’ FLDTWO AS ‘some other label’ ● separate lines for fieldnames, easier to count columns for your compute statements. SUM FIELDONE AS ‘some nice label’ FLDTWO AS ‘some other label’ FLD3 AS ‘some nice title’ COMPUTE FLD4/I8=C1+C2+C3; AS ‘nice summary’

  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’

  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’

  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;

  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

  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.

  40. Fex construction • 0. dictionary • 1.environment variables • 2. resource allocation • 3. JOINs • 4. DEFINEs • 5. data extract(s) • presentation layer • 7. maintainable code

  41. 6. Presentation Layer • 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!!

  42. Report Heading Report Subheading 1 Report Subheading 2 Report Subheading 3 Report Dates Report Parameter 1 Report Parameter 2 Report Parameter 3 Report Parameter 4 Report Parameter 5 Report Parameter 6 Report Parameter 7 Report Parameter 8 • 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

  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

  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

  45. RED GREEN RED GREEN • 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?

  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

  47. Fex construction • 0. dictionary • 1.environment variables • 2. resource allocation • 3. JOINs • 4. DEFINEs • data extract(s) • presentation layer • maintainable code

  48. 7. Maintainable Code • 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

  49. Report Heading Report Subheading 1 Report Subheading 2 Report Subheading 3 Report Dates Report Parameter 1 Report Parameter 2 Report Parameter 3 Report Parameter 4 Report Parameter 5 Report Parameter 6 Report Parameter 7 Report Parameter 8 An example– A typical report layout

  50. An example – Coding the “flexible” heading and footing 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; FOOTING BOTTOM "Produced by: &Userid <+0>Page:<TABPAGENO of <TABLASTPAGE<+0>Created on: &RepDate at &RepTime"

More Related