1 Include Files ? Handy Helpers or The Root of All Evil? Abstract: Back in the day include files were a significant tool for promoting code re-use and.

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

PHP I.
Using XA Browser/Power-Link Preferences to Improve Efficiency
Programming Languages and Paradigms
ProTop version 3 – An open source Progress database performance monitor ProTop is a free, Open Source database monitor for Progress OpenEdge databases.
ProTop version 3 – An open source Progress database performance monitor ProTop is a free, Open Source database monitor for Progress OpenEdge databases.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
1 How I Stopped Using Shared Variables and Learned to Love OO Abstract: The use, and abuse, of shared variables has been with us since version 3 of the.
Abstract Data Types Data abstraction, or abstract data types, is a programming methodology where one defines not only the data structure to be used, but.
Programming Logic and Design Fourth Edition, Introductory
Object Oriented Programming with Progress 4GL Scott Auge.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 06.
MIRC Matthew Forest. Introduction mIRC itself is a program designed for text based messaging via the IRC (internet relay chat) protocol. (Link:
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
Using Objects and Properties
Run time vs. Compile time
John Sadd Progress Fellow and OpenEdge Evangelist
C++ fundamentals.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
Performance testing of Progress Appservers and a plug-in for Jmeter
Datasheets II: Sum, sort, filter, and find your data Overview: Sum it up, and more Access 2007 makes it easier than ever to perform math functions on your.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
JAS3 + AIDA LC Simulations Workshop SLAC 19 th May 2003.
1 Growth: It's a Good Problem To Have! But what are you going to do about it? Abstract: Many partners start out with a great idea, create a fantastic product,
Functions Part I (Syntax). What is a function? A function is a set of statements which is split off into a separate entity that can be used like a “new.
Chapter 9 Database Management Discovering Computers Fundamental.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
Microsoft ® Office Access ® 2007 Training Datasheets II: Sum, sort, filter, and find your data ICT Staff Development presents:
Stored Procedures, Transactions, and Error-Handling
ARCH-03: Implementing the OpenEdge™ Reference Architecture – Part 1 John Sadd Progress Fellow and OpenEdge Evangelist.
DEV-5: Introduction to WebSpeed ® Stephen Ferguson Sr. Training Program Manager.
New team member / new project for the team Helps analyze relationships and structure Understanding code Locates code in unfamiliar code bases Understand.
PowerBuilder Online Courses - by Prasad Bodepudi
Axel Naumann University of Nijmegen / NIKHEF, NL ROOT 2004 Users Workshop The Future of THtml Plans and Status of ROOT’s documentation facility.
CSE 219 Computer Science III Program Design Principles.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Introduction to ABAP Selection Screens. Slide 2 Screens (Types) There are three types of screens Selection screens get parameter input for reports List.
Chapter 13. Procedural programming vs OOP  Procedural programming focuses on accomplishing tasks (“verbs” are important).  Object-oriented programming.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Functions, Procedures, and Abstraction Dr. José M. Reyes Álamo.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
44222: Information Systems Development Documenting a Solution Ian Perry Room:C41C Extension:7287
1 What to do before class starts??? Download the sample database from the k: drive to the u: drive or to your flash drive. The database is named “FormBelmont.accdb”
CPS120: Introduction to Computer Science Decision Making in Programs.
CPS120: Introduction to Computer Science Functions.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
INFO1408 Database Design Concepts Week 15: Introduction to Database Management Systems.
Debugging and Profiling With some help from Software Carpentry resources.
8 1 Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
AN OBJECT LESSON IN CLASSES “or how OO ABL solves everything.”
What is a Package? A package is an Oracle object, which holds other objects within it. Objects commonly held within a package are procedures, functions,
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
1 CS161 Introduction to Computer Science Topic #9.
1 How I Stopped Using Shared Variables and Learned to Love OO Abstract: The use, and abuse, of shared variables has been with us since version 3 of the.
Lecture 10: Modular Programming (functions) B Burlingame 13 April 2015.
A Guide to SQL, Eighth Edition Chapter Eight SQL Functions and Procedures.
 2003 Prentice Hall, Inc. All rights reserved. 1 IS 0020 Program Design and Software Tools Preprocessor Midterm Review Lecture 7 Feb 17, 2004.
Chapter 3 Functions. 2 Overview u 3.2 Using C++ functions  Passing arguments  Header files & libraries u Writing C++ functions  Prototype  Definition.
Review of Parnas’ Criteria for Decomposing Systems into Modules Zheng Wang, Yuan Zhang Michigan State University 04/19/2002.
Learningcomputer.com SQL Server 2008 –Views, Functions and Stored Procedures.
SPECIAL NOTE The customer on arrival at the post office is supposed to approach the counter for payment after that, he goes to writing duty for allocation.
OOP Basics Classes & Methods (c) IDMS/SQL News
Be “GUI ready” developing in RPG by Robert Arce from PrismaTech. Be “GUI ready” developing in RPG-ILE Presented by: Robert Arce.
Functions in C++ Top Down Design with Functions. Top-down Design Big picture first broken down into smaller pieces.
CLASSES AND OBJECTS Chapter 3 : constructor, Separate files, validating data.
Mr H Kandjimi 2016/01/03Mr Kandjimi1 Week 3 –Modularity in C++
Datasheets II: Sum, sort, filter, and find your data – Easy math, sorts, and searches Lesson 19 By the end of this lesson you will be able to complete.
OpenEdge Standard Storage Areas
OpenEdge Standard Storage Areas
CS 350 – Software Design Principles and Strategies – Chapter 14
Presentation transcript:

1 Include Files ? Handy Helpers or The Root of All Evil? Abstract: Back in the day include files were a significant tool for promoting code re-use and building frameworks. Like any tool they were also sometimes abused and as new capabilities were added to the 4gl the old and familiar may have out-lived its welcome. In this session we will explore some of the more "exotic" uses of include files (for you kids that have never seen one) and talk about the pros and cons of different views on their appropriate use in today's coding world.

Include Files! Handy Helpers? Or The Root of All Evil? Tom Bascom, White Star Software

A Few Words about the Speaker Tom Bascom; Progress user & roaming DBA since 1987 Partner, White Star Software, LLC – Expert consulting services related to all aspects of Progress and OpenEdge. – Partner, DBAppraise, LLC – Remote database management service for OpenEdge. – Simplifying the job of managing and monitoring the world’s best business applications. – 3

The oldest and most respected independent OpenEdge DBA consulting firm in the world! Four of the world’s top independent OpenEdge DBAs! Author of ProTop, the #1 FREE OpenEdge Database Monitoring Tool: Who is White Star Software?

{disclaimer.i} The content of this session is heavily laced with opinion! 5

Audience Survey! What version of Progress do you have now? What version of Progress did you start coding with? What version of Progress was your application first written in? 6

What is an “Include File”? That seems like a silly question… But there are an amazing number of posts online that make it clear that lots of people do not know what they are. 7

What is an “Include File”? Source code which is stored in a distinct source file, but “included” into the main routine at compile time. Referenced in Progress 4gl code as {fileName} – Complicated by possible arguments. De-facto standard file extension is “.i” – But that is not a requirement –.f,.v … – Or no extension at all! 8

example.p 9 /* example.p */ {variables.i} find customer no-lock where cust-num = 999 no-error. if not available customer then {msg.i 3} else display name.

{variables.i} 10 /* variables.i */ define variable msgtext as character no-undo extent 5 initial [ “no such customer”, “try again”, “what?”, “good work!”, “huh? I’m confused” ].

{msg.i} 11 /* msg.i */ do: message msgtext[ {1} ]. pause. end.

compile example.p listing “example.list” 12 {} Line Blk /* example.p */ 2 {variables.i} 1 1 /* variables.i */ define variable msgtext as character no-undo extent 5 initial [ 1 4 "no such customer", 1 5 "try again", 1 6 "what?", 1 7 "good work!", 1 8 "huh? I’m confused" 1 9 ] find customer no-lock where cust-num = 999 no-error. 4 if not available customer then 5 {msg.i 3} 1 1 /* msg.i */ do: message msgtext[{1}3] pause. 1 6 end. 6 else 7 display name.

compile example.p debug-list “example.dbg” 13 1 /* example.p */ 2 /* variables.i */ 3 4 define variable msgtext as character no-undo extent 5 initial [ 5 "no such customer", 6 "try again", 7 "what?", 8 "good work!", 9 "huh? I’m confused" 10 ] find customer no-lock where cust-num = 999 no-error. 13 if not available customer then /* msg.i */ do: 18 message msgtext[3]. 19 pause. 20 end. 21 else 32 display name.

Back in 1985… There were no “objects” in “abl”. There were not even internal procedures nor parameters to external procedures  But we did have include files: – Code reuse! – Standardization! – Productivity! 14

15

Programmers Progress, 1991 The advanced programmer can take advantage of Progress’ excellent facilities using includes, run-time arguments and parameters. The more a programmer uses these capabilities, the more flexible his code becomes, approaches the structure of “C” and the modularity of “object-oriented” thinking. 16

How are Include Files Used? Uniform Data Definitions – To define variables common to many routines. – Similar to a C “header file” i.e. #include Repetitive Code Snippets – An improvement over “cut & paste” – “in-line function” Frameworks and “Skeleton” Procedures – “pick routine” – CRUD maintenance To extend the language 17

Uniform data definitions Shared variables – Shame on you! – Conflict in extent, datatype or undo status for global xyzzy. (390) – Shared variable pflugh has not yet been created. (392) Temp-tables and ProDatasets – One of the 4gl’s best features! Magic used by frameworks 18

Repetitive Code Snippets 19 /* fixtime.i * * keep the clock updated... * * march 6, 1989 */ put screen row 1 column 1 substring( string( time, "hh:mm am" ), ( if substring( string( time, "hh:mm am" ), 1, 1 ) = " ” then 2 else 1 ) ) + " ". (TRIM() came along in v5…)

Repetitive Code Snippets 20 /* lib/upd-xrec.i */ {1}[3] = {2} {1}[4] = {1}[3] - {1}[1] {1}[5] = {1}[3] - {1}[2] {1}[2] = {1}[3] /* and used like this… */ assign {lib/upd-xrec.i tt_table.tbl-cre _TableStat-create} {lib/upd-xrec.i tt_table.tbl-rd _TableStat-read} {lib/upd-xrec.i tt_table.tbl-upd _TableStat-update} {lib/upd-xrec.i tt_table.tbl-del _TableStat-delete}. /* [1] = base * [2] = last (previous current) * [3] = this * [4] = current * [5] = interval */

Frameworks enterdata: do while true with frame queries: {inc/fixtime.i} find person no-lock where recid( person ) = p_recid no-error. display person.person-name person.active person.phone-num. if ( q = 1 ) then {inc/query.i person person-name} else if ( q = 2 ) then {inc/query.i person active} else if ( q = 3 ) then {inc/query.i person phone-num} {inc/basename.i ""{0}"" scrname} {inc/switch.i} end. (The CASE statement came along in v7…)

Extending the Language Fill in gaps and smooth over rough edges Modernize legacy 4gl with modern approaches (OO) Provide missing 4gl functionality Emulate features from other languages 22

Mike Fechner, Director, Consultingwerk Ltd. Lists, Generics, Enumerators, Enumerations, Serialization DIY: Closing the OO Gap

foreach.i 24 {3} not used, only used to fill up syntax and match c#

Named Arguments Named Arguments are position independent. And optional. There is no equivalent for parameters to procedures, functions and methods. 25

26 The Other Side Speaks!

Programmers Progress, 1991 … since the contents of an include file cannot be seen by the reader, you should be VERY parsimonious in using include files... As often as not, using an include file to make code more readable can have the opposite effect. 27

Bad Things About Includes Code Bloat Side Effects Hidden Dependencies Ugly Syntax Bad Code 28

Code Bloat Each reference to an include file is copied into the source routines The listing files show that the expanded source can be much larger that it appears This results in larger r-code 29

Side Effects Includes can impact flow of control, record locks and transaction scope and everything else Code in an include is not “protected” in any way – At best you get “security through obscurity” – Someone who knows what the include does can easily extract information … – … or arrange for pre-conditions to be met – … or do funky things with arguments to inject their own code snippets. 30

Hidden Dependencies Within the code Between modules (what code needs to be recompiled?) 31

Side Effects & Dependencies enterdata: do while true with frame queries: {inc/fixtime.i} find person no-lock where recid( person ) = p_recid no-error. display person.person-name person.active person.phone-num. if ( q = 1 ) then {inc/query.i person person-name} else if ( q = 2 ) then {inc/query.i person active} else if ( q = 3 ) then {inc/query.i person phone-num} {inc/basename.i ""{0}"" scrname} {inc/switch.i} end. (The CASE statement came along in v7…)

Spaghetti! 33

Ugly Syntax “{“ and “&” – need I say more? 34

Ugly Syntax “{“ and “&” – need I say more? Unpacking nested quotes… 35

Bad Code “Include files let you hide bad code…” Technology is a tool. The quality of results depends on the person using the tool. 36

Bad Coding… Who here thinks they are “better than average”? Who has looked at some code and said “that’s really awful, the person who wrote that should be fired!”? … and then realized it is their own code from X years ago? Do you know someone who writes better code than you do? Can you explain what is “better” about it? Does that person work in your company? Is it your boss? Is your boss in the room? 37

Hiding Bad Code Yes. When done right – that’s sort of the point. 38

39 Conclusion!

Handy Helper? 40

Root of All Evil? 41

Undecided? 42

Questions? 43

Suggested Additions? 44

Exotica Using an argument as the name of an include to include Use the contents of an include as the arguments to another include Using {*} and providing defaults for optional args Same include, different behaviors controlled by pre-processor (positional args vs named args) Recursive includes The /* conditional compile example 45

Thank You! 46