CART0669,CART0470

“Get a Personal Trainer for Your Computer!”©

NOTE:  Items highlighted in RED are defined elsewhere in this Glossary, while items highlighted in BLUE are site links for further information.

The introduction to several other areas of this site apply here just as strongly:

>>The GiGo (“Garbage In - Garbage Out”) syndrome.  That is, the single largest cause of programming problems is the failure to devote sufficient time to the planning or design phase of the program, not to its creation or implementation.  If there is agreement about the design and the ultimate output, the actual programming phase takes very little relative time.  Just like the assembly of a computer takes up much less time once the design comes together and the parts are purchased.

>>There are lots of websites, on-line videos, courses of all types and, of course, friends who can teach you about specific programming languages and methods.  This isn’t the purpose here.  This page is to lay out the process, give you a grid to superimpose the more detailed information available from other sources.

INTRODUCTION

Simply stated, a “program” is a set of instructions (written in various types of code) that processes raw data (“input”) into useful information (“output”). 

EXAMPLE: TRACKING THE TARGET CREDIT CARD DATA BREACHES:

DATA

>>>>>>>>>>

Raw Data:  All customers, all credit card purchases, all stores, all amounts, all transaction receipts for 5 years

PROGRAM

Microsoft Excel: sorting and filtering through queries

>>>>>>>>>>

OUTPUT

Reports:  Filtered and sorted by transaction, dates, amounts and/or customers

Just like any other computer processing, the data can come from various sources (direct keyboard input, disks, Internet, network, etc.), are loaded onto the computer along with the program itself, and then the results can also be output into several devices (printers, Internet, intranet, etc).  The actual program instructions are encoded in a variety of languages (e.g. C++, Fortran, Cobol, etc.), but all provide set-by-step instructions to accomplish a particular given task.  Once the programmer has created the “source code” using a program, that code must then be “compiled”  into “object code” and then into digital “machine language” that the computer can understand and process (“execute,” see below).  Each program has its own “assembler” to do this.  For example, Cobol has Forth, JavaScript has Ruby, C has C++.   Look below for a comparison of what source code, compiled code and machine language actually look like. 

Z = 0;

X = 3;

WHILE X ~= 0

    Z = Z+Y;

    X = X - 1

Y = Z;

SOURCE CODE

PROGRAM TRANSLATION

COMPILER/ INTERPRETER

ADD R3 R2 R3

SUB R0 R0 R1

BZERO 4

BRANCH 0

MOVE R2 R3

HALT

OBJECT CODE

ASSEMBLER

10100001000000110

10100010000000110

00000010000000100

00000001000000000

100100010000001011

111111111111111111

DIGITAL MACHINE LANGUAGE

PLEASE NOTE: If you have written your own program, you will “own” the source code you have created.  However, if you have created a program using software that you merely are licensed to use, or if you purchase it from someone else who has created it for you, you may not actually own the source code and may not be able to modify or edit it after its creation.  Legally, this has been a source of confusion for unsophisticated businesses who have employed independent programmers, because they believe that, having contracted a coder to create the program, they own his creation, which is not always the case.  (See LAWS)

THE DESIGN PHASE

As stated above, the design phase of programming is of the utmost importance.  Not only must you pay attention to the nature and quantity of raw data that must be collected to become processed, but you must foresee what you expect the output to look like and how you plan on using it as well.  And not only now, but also as the need for additional information may expand over the foreseeable future (I usually opt for a “5-year projection”).  Program requirements are never static, but tend to evolve as time marches on.  There’s always a “wish list”. 

For that reason, it is often useful for a programer to obtain a “screen shot” of the various windows that the user would expect to see when the program is completed.  That way, everyone is “on the same page”.  Programs like Microsoft’s Visual Basic are often useful for this purpose.  That way, using this “prototyping” or “bottom-up” design approach, you are more assured that you will satisfy the end users’ expectations and needs as well as plan for future expansion.  Especially if you physically get the user to “sign off” on the prototype and create a date on which it will be “fixed” and cannot be changed further, at least without substantial delay and increased cost.   In this regard, there is also a process known as “RAD”  (Rapid Application Development) which allows a programmer to create a visual form with “dumb” controls (sometimes called a “wireframe”) so that the end user can see and feel the design of the form as well as the placement of the individual controls that they will be working with in the future.  The “top-down” design approach of starting with the most basic tasks and breaking them down into more and more detail is just as important for creating a program.  Good programmers will usually use both directions, assuring the checks-and-balances necessary to produce a perfect program.

For larger projects, there are several “methodologies” that can be used for the software development process.  Which one, if any, you choose will have a lot to do with where you work, who you are working for or with and how complex and/or important the code will be.  At one extreme, there’s what’s sometimes derogatorily called “cowboy coding,” in which the programmers have complete autonomy over the development process, including the choice of the programming tools, languages, algorithms, frameworks, coding style, even the project schedule.  You can see why a corporate client might find this discomforting.  At the other extreme is Agile software development, which has many different variations, each with its own emphasis, like Scrum (continuous collaboration), extreme programming (frequent “releases” over short development cycles), waterfall (each phase completed before moving on, no going back), KanBan (just-in-time delivery) and many others.

THE LOGIC PHASE

Once the goals have been agreed upon between the programmer and the client in the program design phase, the next step is for the programmer to develop the logic for the program.  This can be done with a flow chart (using decision symbols in a graphic format) or possibly pseudocode (a decision tree written in plain text) [see examples below]:

Flow Chart

FLOW CHART

  For every student in the class:

      If they have perfect attendance,

      Then they have a grade of at least B

      Otherwise they will be demoted one-half grade

      For each two days they have each been delinquent

      But not below grade C

      Print the report for all students

        in declining alphabetical order.

PSEUDOCODE

Most knowledgeable programmers don’t even begin to write the programming code itself until these steps have been completed, any more than a surgeon would perform an operation without a detailed surgical procedure, a builder would build a house without plans to follow or a car manufacturer would attempt to build a car without first designing it.   You can’t start until you know not only the expected outcome but a plan to get to it.

THE PROGRAMMING PHASE

Generally, it’s difficult to write about this part of programming without being program specific.  The choice of program can be determined by the type of program itself (e.g. Fortran is better suited for scientific and security purposes, COBOL for business applications and banks, Java for web applications, Ruby for development speed, Clojure is best for shipping, Python has many features, C+ is serious programming, PhP old school and the opposite. 

The programs can also be separated by paradigm, that is how it works to build the structure and elements of the program itself.  Some may use object-oriented programming, others functional programming, imperative, declarative, functional, procedural, logic, symbolic, etc.  Some programs may use more than one paradigm.  This can be complex; click HERE for an extensive  chart of programming paradigms.   Depending on the speed or accuracy required for the job, one type of paradigm may be superior to the other for your purposes.

Then, you’ll have to choose a framework and various established libraries for that language to structure your work and make it easier.  The essential difference between a framework and a library - you decide which framework you want, then the library comes with it.

Then, for larger or corporate projects, there are various “software development processes,” some of which are discussed above under methodologies (with names like TDD, BDD, FDD, DDD and MDD which stand for things like feature-, domain-, model- and test-driven design or development; you can check the Wikipedia page for “software development process for more about this...)  Normally, if you have a job to do, you’ll probably want to stick with the program(s) you know well, rather than spend time learning something new.   But there is some commonality between almost all programs, so we’ll discuss those here.

Programming can be really simple or extremely complex, depending on the amount and type of data you’re working with and the features you (or your client) desire.  Some programs require you to write actual code (e.g. Cold Fusion), while others (e.g. Net Objects Fusion) provide you with a simple and easy GUI interface while creating the code and compiling it for you in the background. 

So, for our example, let’s take something easy:  Since so much programming involves the web, let’s stick with JavaScript (not the same thing as Java, click HERE for an explanation of the difference), which is also one of the easiest to use.  Why?  For one thing, you don’t have to purchase and install a program to use it.  You just have to have an operating system and a browser, any browser.  Even if you don’t have Microsoft Word installed on your computer, the Windows Notepad or Wordpad which comes with your Operating System Accessories will work just fine to write your instructions, so long as you save them in “.html”  format so you can view the output using Internet Explorer, which also comes built right inside your operating system. Or any other browser of your choice.

You just have to know how to structure your instructions:

For example, here’s a simple program that I wrote in Windows Notepad and then saved by naming it “js1.html”:

Capture

And here’s what it displays when I click on the browser icon:

Capture2

When we look at the code screen, what do we learn?

1.  First, we have to tell the program what type of language it’s going to be written in: HTML.   You will notice that almost every line in the program begins with a backwards carat (“<”) and ends with a forward carat (“>”).  Also, when a line which specifies something (like body or script), it starts with bracketing carats (e.g. <body>, but must end sometime with a slash within the bracketing carat (e.g. </body>.

2.  You will notice in the example that the designation of “//” (much like “rem” (remarks) in DOS) means that anything written to its left will not display when the program is executed.

3.  If you want to display text, it is prefaced by “document.write” and then bracketed between “(“<p>     <p>”);”

4.  The header (title) is bracketed between “<h1> and    <h1>”  [no / this time before the final <h1>]. 

Two other important parts of JavaScript are “functions” and “arguments”.  Functions are blocks of code (instructions) that will be executed when “called”.  It is called, for example, when someone clicks a button or runs a mouse over text or depresses the enter key.  Often, before the function is called, some information is passed on to it for its execution.  This information is called an argument, and it is used inside the function for its execution.  Some functions will return text (as in “Welcome”), while others will have a “return value” (“5”).  The function code block is preceded by the word “function” and is enclosed between braces ({  }).  For example,

function functionname()

{

code

}

Or a more specific example of “calling” a function:

<button onclick=”myFunction(“Joe Kelly”,”Computer Coach”)”>More</button>

<script>

function myFunction(name, job)

{

alert(“Welcome “ + name + “, the “ + job);

}

</script>

In the above function, clicking the botton will alert “Joe Kelly the Computer Coach” when the button is clicked.  But it is a variable function and you can call it using different functions which will display different messages, as follows:

{

<button onclick=”myFunction(“Joe Kelly”,”Computer Coach”>More</button>

<button onclick=”myFunction(“Harry Smith”,”Computer Coach”>More</button>

}

EXECUTION

Here’s how a computer program, once written, tested and de-bugged, works:  As explained elsewhere on this site, computers operate using binary code, i.e. “0”s and “1”s.  These zeros and ones are processed via the CPU, which is the computer’s “brain”.  A CPU has a lot  (sometimes literally billions) of electronics like Transistors, which act as what’s called logic gates”.  Transistors operate on electrical current which, as discussed in binary, has specific attributes.  Either the current is “on” (“1”) or it’s “off” (“0”).  Two choices only.  Binary.  This is important because the electronics that implement logical “arguments” are what actually executes or runs the program itself.  The three basic logic operators are AND, OR and NOT.  That’s it.  And it’s all that’s necessary to implement all logic, including arithmeTransistortic operations. When combined in great numbers, of course, the operations can become quite complex.  As applied to transistors, which normally have three wire connectors (two for input and one for output; see photo at right), AND means that the output will have current only if BOTH of its inputs have it (1 AND 1 = 1), OR  means only one is sufficient (1 OR 0 = 1), while NOT simply reverses the existence of current (NOT 0 = 1).  So the computer’s CPU reads code and then executes the instructions using logic.  This can be explained in a “truth table” like the one below.  There are different kinds of logic gates, each with its own table; a computer is made of many gates, all wired together, using an “adder,” to add up the signals Click HERE for more.

 

A

B

OUT

-

-

-

-

+

-

+

-

-

+

+

+

Code, as discussed above, is a process.  Today’s high abstraction “programs” (like C or COBOL or FORTRAN) are very high level and can be used to express very complicated concepts and tasks quite succinctly.  But a computer can’t use the instructions from such programs directly.  The output must be translated into machine language so that the program can be “executed” (i.e. run).  This is done with software known as a “compiler,” which takes the instructions from a high abstraction program and converts it into either assembly language (which is then translated into machine language) or sometimes directly into machine language which the computer can then understand.  Depending on the operating system being run on the particular computer, the compiler must take into consideration the output that will be required, so that it plays well with the file system, peripherals and other things comprising any operating system.

LEARN MORE

LEARN MORE:  There are some really great basic apps which teach you how to program code.  While they may be made for children, adults can benefit as well:

If you have an Apple computer, the free Codeacademy: Code Hour app for iOS is an easy to use app where the top half of the screen explains a concept, while the bottom half is an interactive example of the program code, with explanation.  Also available is Hopscotch, which is more text based, and uses “blocks” to create a drawing.  And the Kahn Academy has lots of free courses to learn coding.  Also Code School.  Once you get a little knowledge, you might try TheCodePlayer, which has excellent video-style walkthroughs for various languages. Same for Programmr, which teaches you by doing, step-by-step.   HTML5 Rocks is a project from Google promoting HTML 5, the newest standard in web development.  And, if you want to build web pages, Code Avengers is excellent, as is W3 Schools.

You could also try Lightbot, available for iOS ($2.99) and Android ($2.75), with free samples to try first, which is aimed at children, but is informative enough to be useful for many adults as well.  It comes as a game in which a little robot navigates a maze turning on lights.  It’s deceptively easy, but teaches you programming principles without the drudgery of actually writing code.

These courses will also teach you bad habits to avoid when you write code.  Things like “spaghetti code,”  where you make overuse of the “GOTO” command to skip to another line of already created code, or failing to document the code, or creating unreasonably long lines of code, or creating “yo-yo” code (where the code jumps back and forth between strings and integers, for example) as well as a host of other bad habits that you should learn to avoid.

CLICK TO SHARE THIS PAGE

CLICK THE FIRST LETTER OF YOUR ACRONYM OR TERM TO SEARCH GLOSSARY:

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

© Computer Coach.  All written materials are the sole property of Computer Coach (unless otherwise attributed) and no part of this website may be used in any format without the express written permission of Computer Coach.