RPG books, sample code, etc.
* This FREE site is dedicated to all *
|
|
"C makes it easy to shoot yourself in the foot; C++ makes it harder,
but when you do, it blows away your whole leg." --Bjarne Stroustrup |
Links page |
Utilities,
Code-Samples, Demos, Tutorials |
There is a lot of information on the internet about C and C++ and Java, JavaScript, and HTML etc. but, it is disorganized and scattered. Worse yet for RPG programmers (those who work on IBM's AS/400 = iSeries), there just isn't much at all.
On my Links page, I am not trying to list as many sites as possible, like some others I have seen, but only the best, most comprehensive, sites and, where there is a small site with somthing of value, I try to specify exactly what it is. If I can make the list useful to me, it could be good for you also. If you know of a great site that I have not yet found, please add it on. ( To stop the shameless spammers I just put a hold on new entries till I have verifyed that they are from a programmer, not a spammer. )
Times are changing. Today we may still have what were "back end" or "internal" or "in house" programmers and separate from them the internet or web site designer but, more and more, today, one person is doing both and though "back end" business programming is complex enough, ... and all the complexity of the layout design is "complex enough", they are starting to get mixed together creating "double trouble!"
I have built a data base for sample code and information that we have not been able to find elsewhere but feel sure many would like to see. I am adding to it as I discover things and hope you will also.
SQL is a nonprocedural or "set oriented" language and
HTML is a Markup Language
but, T-SQL and PL/SQL are procedural extensions to SQL, making it like Java, C/C++, PHP, Perl, VBA, and etc., where every little step is spelled out, where, unstructured code, with its goto's, exits, jumps, and etc., becomes a tangled web of "spagetti", on the average, taking twice as long figure out, modify or enhance and, the larger the program grows, the more often it is modified, the more disastrous it becomes. Software vendors and IT departments alike, know the all too real limitations of continually updating and enhancing their programs. The ability of a co. to survive may be affected by the professionalism of their programmers. or of their vendor's IT depts. Good structured code can keep IT costs down and prevent lost time that can cost it market share, even profitability. . .
"The most basic practice, for those programming in procedural languages, is to avoid the infamous goto statement—well structured and designed programs simply have little need for it. "Spaghetti code," riddled with gotos, is notoriously difficult to decipher."
- 1 programmer's affirmation
| THE 3 BASIC PROGRAMMING CONSTRUCTS | |
1. SEQUENCE |
consecutive |
2. BRANCH |
if - else | 3. LOOP |
do while |
|
The basics of structured programming:
All code stays within the 3 constructs, therefore (the condition may be expressed at the top) |
The Sequence is the in-line "execute one line after another" code between loops and branches.
A branch is an if "do something" (else, "do another").
A loop is just a sequence that is repeated while some condition is true. ( or for a given count, etc. )All too often programmers get lazy and don't think of the consequences. They insert some kind of "if X then exit", failing to see that they have just put one more nail in the coffin of a dying program which, if it is only one of many, could lead to the replacement of all the software and maybe hardware. If that happens, the programmers could soon be gone also, if not the whole company.
Consider that no one cares what won't happen. and 3 lines saying what won't happen is ever more a waste when 2 lines could have said, clearly, what will:
like
if not [OK] exit, jump, iterate, goto, ... spagetti, spagetti; end if // your code (???) //instead, the clear and more concise (2 lines) structured alternative:
if [OK] // your code // end ifWow, so much clearer and Obvious!
more notes from others:
"It's frequently necessary to thoroughly understand all the details of long-forgotten code. I've often had the challenge of trying to decipher another person's application - and I've also had the humbling experience of trying to understand code that I wrote years ago. ...
"I now believe that if it takes more than a moment to understand a code segment, either more documentation is in order or the program structure should be revised. If I have to get back into this code five years from now, I'll want to know exactly what everything does, and why - and I'll want to know it fast!
"All variable, constant, function, and source file names should be succinct and descriptive, and accurately reflect the purpose of the variable. Even the lowly loop index needs to be more than just "i", "j", "k", etc."Also, imagine your anger if "i" is all you have to go on for finding a loop somewhere in a large program.
(As bad as "ii" or "jj" or "kk" is, at least there may be some hope of finding it.)
Finally, source code benefits from peer review. You may only need to clarify a few comments and make variable names more descriptive, but when a second pair of eyes finds fundamental implementation flaws at an early - and inexpensive - stage of development, the extra process is worth it.
JAVA Timeline
Year Month Event 1996 January Sun releases Java Development Kit 1.0 (JDK 1.0). 1997 February Sun releases Java Development Kit 1.1 (JDK 1.1). 1998 December Sun releases the Java 2 Platform with version 1.2 of the Software Development Kit (SDK 1.2). 1999 August Sun releases Java 2 Platform, Standard Edition (J2SE). 1999 December Sun releases Java 2 Platform, Enterprise Edition (J2EE). 2000 May Sun releases J2SE with version 1.3 of the SDK. 2002 February Sun releases J2SE with version 1.4 of the SDK. 2004 September Sun releases J2SE with version 5.0 (instead of 1.5) of the JDK.
Applications, Applets, Servlets and JSP's:
Since an applet runs within a browser on the client, it's not ideal for working with resources that run on the server, such as enterprise databases. To provide access to enterprise databases, many developers use the Enterprise Edition of the Java 2 Platform (J2EE) to create applications that are based on servlets.
A servlet is a special type of Java application that runs on the server and can be called by a client, which is usually a web browser. The servlet works much the same way as the applet. The main difference is that the code for the application runs on the server. When a web browser calls a servlet, the servlet performs its task and returns the result to the browser, typically in the form of an HTML page.
Apache Tomcat is the servlet container that is used in the official Reference Implementation for the Java Servlet and JavaServer Pages technologies jakarta.apache.org/tomcat
To make it easy to store the results of a servlet within an HTML page, the J2EE specification provides for JavaServer Pages (JSPs). Most developers use JSPs together with servlets when developing server-side Java applications.
JSP vs. Servlets
A basic consideration is the ratio of markup to code: the more markup the greater the case for a JSP, and the more code the greater the case for a servlet. "Code" being content such as loops and conditionals that surround blocks of HTML. This sort of code cannot be locked away inside a bean, whereas much else can. In fact it is a design goal of JSP development to keep as much code as possible out of the page and in a bean or other class which is then referenced in the page. The code sections of a JSP can quickly become unmanageable and difficult to debug, especially since the compiler is working on the generated ".java" source file and not directly on the JSP. But for a page with simple server-side functionality, such as altering output based on a few request parameters, a JSP can be much simpler and quicker to build than a servlet.
A spot check for jobs nationally on 8-10-2005 came up with 509 jobs mentioning servlets, 868 with JSP, 14 for jhtml-Dynamo, and 6,484 for java - just to put all the above paragarphs in perspective.
A new tool for an old concept:
AJAX (Asynchronous JavaScript and XML): aka "remote scripting" allows client-side
JavaScript to request data from a server without having to refresh the Web page.
"The March of Progress" ("return to basics") 1980: C printf("%10.2f", x); 1988: C++ cout << setw(10) << setprecision(2) << showpoint << x; 1996: Java java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance(); formatter.setMinimumFractionDigits(2); formatter.setMaximumFractionDigits(2); String s = formatter.format(x); for (int i = s.length(); i < 10; i++) System.out.print(' '); System.out.print(s); 2004: Java System.out.printf("%10.2f", x); ( from http://www.horstmann.com/ )
|
Save Me from Cleverness
By Peter Coffee
Programming guru Brian Kernighan has famously said that debugging code is twice as difficult as writing it - and, he said, it follows that, "If you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." I'd generalize this to two principles that should be followed by anyone who buys, builds or uses complex and powerful systems: Leave half of what you have in reserve, and assume below-average cleverness. I first saw Kernighan's warning in the 1988 paperback reprint of his 1974 McGraw-Hill book (with P.J. Plauger), "The Elements of Programming Style." Many people have been quoting his comments this May in the context of a flaw found in March in a widely used implementation of the X Window System, an MIT-originated protocol for cross-platform GUI construction. Despite the mocking label of "the first fully modular software disaster" seen on a poster at one X Window conference, X Window has been a pathway to portability for any number of useful tools that might otherwise be available only on Windows. For example, the Macintosh version of the SlickEdit programmer's editor runs on Macs by means of the X Window implementation packaged with OS X. X Window is an open-source project (www.x.org), with plenty of eyes scanning its reference implementation and other implementations for bugs or vulnerabilities. A Department of Homeland Security audit (your tax dollars at work) found the flaw that provoked this month's comments on cleverness - and many have since made the point that this demonstrates a key virtue of open-source efforts. In our own eWeek story on how the vulnerability came to light (see "Gov't-funded security audit flags X11 vulnerability" at eweek.com), the chief technical officer of the DHS contractor doing the audit described the cause as "something as seemingly harmless as a missing closing parenthesis." That's not quite correct, and the problem would have been found much sooner if that had been the case. Missing punctuation will generally result in a program's failing to compile, let alone run - although substituting one punctuation mark for another can be devastating, as in the legendary case of the FORTRAN code that disrupted a NASA mission when a period replaced a comma. In the case of the recently discovered X Window flaw, the missing marks were a pair of parentheses, creating a classic case of the machine doing exactly what it was told instead of what was wanted. In two places where the code should have said "geteuid()" (call function "geteuid" with no arguments and return the result), there instead appeared "geteuid" (return the memory location of the "geteuid" code). The error would have been caught if the C programming language distinguished between the concepts of zero (a number) and null (absence of a value), but it does not. The convenience of using "0" for both, and the cleverness of letting a function's name serve as both verb of invocation and noun of code location, are defining features of the C language - of which cleverness critic Kernighan, ironically, was one of the main designers. Famously terse, C is not a language where you'd expect to find something as verbose as Visual Basic .Net's "AddressOf" operator, which appears in statements such as "AddHandler Button1.Click, AddressOf Button-ClickHandler" (an example from Microsoft documentation) and makes the code's intention perfectly obvious. Another good rule to remember is that most code will be written only once but read many times, and that it's more important for a language to be easy to read without ambiguity than to be easy to write with few keystrokes. But coders are not the only ones who are ill-served by systems designed to treat almost every possible input as a legitimate (if, perhaps, obscure) command. Try to find a keystroke in an application like Microsoft Word that doesn't have some function, changing the editing session's behavior without telling the user how or why. Real systems and real users don't do well when balanced on the sharp edge of making too many things too easy to do, in ways that are often too difficult to see. Peter Coffee can be reached at peter_coffee@ziffdavis.com. |
| Home | Links | Code-Samples | Exper.-Notes | Color Table | Job Market | ILE-RPG |
| Nikola Tesla, energy | PWSDB | Fuel Efficient Vehicles | Love | Login | About Us | Contact Us |
| PWSDB - Programming WebSites and DataBases * gregs@pwsdb.com |