Wednesday, December 30, 2015

Test Driven Design

My last post was critical of the new control language created to implement a concept called Behaviour Driven Design (BDD).

The process of creating a control language seems liberating at first because the creation process helps improve communications among the creators, but it soon becomes oppressive to those on the outside.

That criticism aside, I actually agree with many of the ideas discussed in Test Driven Design and Behaviour Driven Design.

A quality software shop tests it products thoroughly. Tests are difficult because one needs to test for both expected and unexpected conditions.

Programmers have a tendency to write programs for the way that they imagine people will use their program and fail to realize the creative things people actually do with code. The testers have to test the software for all the different permutations that might happen with the software. This means throwing invalid data at the software and even throwing malicious code at the software to see how it fares against hackers.

Imagine a simple procedure with 5 variables. The testing department has to test all the permutations of those variables.

Object Oriented Programs are even harder to test. Imagine a class with a dozen methods. The testing department needs to test all the paths through that object. 

I find that my testing scripts are generally magnitudes longer than the software itself.

New programs generally need to be tested against existing data. Which is itself a chore.

The idea behind Test Driven Design is that companies should design their tests before writing the software. This seems odd at first. But on considering the vast about of existing data laying around most companies have a good idea about the software will need to handle before coding begins.

Of course, building software around tests is an imbalanced approach. One needs to step back and ask fundamental questions about what the code should be doing ... the case for BDD.

But these questions are already part of the iterative design process.

Anyway, the process of getting my new web site up and running is taking an extremely long time because I am testing every single little piece of code and cranking through some really fundamental questions about the way I want the programs to behave.

Tuesday, December 29, 2015

Control Languages

I wrote this post in reply to Liz Keogh who said responded to my post on the similarities between "Behavior Driven Design" and "Behaviorism"

"BDD is merely the use of examples in conversation to illustrate the desired behaviour of a system. The approach is all about communication, and nothing to do with behaviorism.

There are some supporting tools which turn examples into automated tests, and this is what Kevin Dishman has criticised. They aren't the only tools, nor do they speak to the heart of BDD.

I think this post indicates some fundamental misunderstandings (and Kevin Dishman's post is misleadingly titled).

December 27, 2015"

The comment made me feel bad; So, I spent the morning reading reading Dan North's introduction to BDD ( In this article, Dan North says he was using an Agile method called Test Driven Design. TTD creates a barrage of tests on the logic of a system.

He was having a hard time wrapping his head around the logic of programs and decided that replacing the word "test" with "behaviour."

"I found the shift from thinking in tests to thinking in behaviour so profound that I started to refer to TDD as BDD, or behaviour- driven development."

Changing this word made Dan North feel empowered. The little switch in Mr. North's mind pushed the logic of the system back a step and gave him the feeling of control.

This is identical to what happened with Behaviorism.

Prior to behaviorism, academics held that man was a rational being. When researchers spoke of human beings, they would talk about the reasons for their actions.

Behaviorists felt uncomfortable in engaging in this discussion of reason and felt empowered when they pushed reasoning aside and decided to focus strictly on human behavior.

Behaviorists felt extremely empowered because they systematically pieced together an ideology that reduced the people around them from rational beings to test subjects ripe for experimentation.

Behaviorism quickly became a favored ideology of the ruling elite and intellectuals. When you reduce people to behaviors, you no longer feel obliged to engage with their reasoning processes. You can treat them as sets of behaviors.

North's works seems to take on a Chomskian flare. Changing a word made him feel better; So he jumped in to create a new language and that made him feel even more empowered.

Dan North is openly admitting that he created BDD as a control language.

I admit, I like to feel in control. So, I would like to ask you a simple question: Is my organizing a department so that I feel empowered really the best course for a company or for society at large?

If I told you that; you would probably look at me and say: No way! I don't want to be subservient to you!

IMHO, development should start with the questions about what is best for the business and what is best for society at large.

Come on, if a business isn't actually improving things for its customers or for society, should it really be in business?

But, lets get back to Dan North.

Mr. North is writing in 2003. If I take his article as if it were the first article ever written on business communications. Then, yes, it sounds wonderful. But it wasn't the first article on communication. People have been yakking on and on about the best way to organize things since antiquity.

The things we have today were built on things from the past.

Dan North was working on, what was then, a relatively new idea called Test Driven Development which was created to overcome perceived faults in Object-Oriented Analysis, which was created to overcome problems of procedural design, which was created to over problems with control structures in basic programming languages which were designed to overcome the vagaries of assembly language which was created to piece together ideas about algorithms and Boolean Logic with computer circuitry. These ideas, in turn were built on ideas dating centuries before.

Needless to say, there are huge volumes of work on system design. One can't just jump in and say: "Oh wow, this idea makes me feel empowered and go it with."

One actually has to ask if this path is taking a better route than the millions of routes tried and followed before.

It is fun to say: "Dan North is just trying to improve communication by creating a new language."

Stepping back, one has to ask: are our communication problems the result of lack of language? There's over a million words in the English language. The language includes tried and true grammatical forms. Why isn't this language good enough?

The language we have is sufficient for communication. The problem is that, even with a great language, it is extremely difficult to get people do what we tell them to do.

Mr. North isn't creating a new language to communicate ideas. The purpose of this new language is to control a process.

BBD falls into a category called a control language.

This brings up a fun story.

Back in 1949, a man named George Orwell was looking at the control languages being created by behaviorists and other ideologues of his day.

The people creating the control languages felt empowered, but Orwell had the foresight to think ahead and tried to imagine what would happen to the people who inherited a world controlled by the new control languages.

Orwell decided to write a piece of speculative fiction about the people who inherited a control language that he called "newspeak" that took place 40 years in the future. He called the book "1984."

The idea of a control language is not new. Orwell wrote about this very subject 70 years ago. I agree with him. Control languages seem empowering at first but entrap the people who become ensnared in the newspaek.

The idead of creating languages to control processes or people is not a new idea.

The issue of the proper use of language has raged since the invention of language itself.

The proper use of language was a prime topic of Socrates through Aristotle. This tradition created an education based on a thing called the "Trivium." The three legs of classical education were Grammar, Logic and Rhetoric.

Grammar studies the structure of language. Logic is about the structure of ideas. Rhetoric is the art of successfully communicating ideas.

The whole point of classical education was to teach students how to develop and communicate their ideas. Dan North is not the first person on the planet to think that language is about communicating ideas.

I find the Trivium to be relevant in programming. For that matter, I would say that the best way to organize software education would be to revive the Trivium.

So, lets look at computer science:

There are many different computer languages that have similar functions. The syntax of these languages maps to grammar. What the computers actually do is called logic. The way we talk about computers is rhetoric.

Interestingly, the heart of Aristotle's logic is a strange thing called a "syllogism." To cut to the chase, an "if/then" statement is a form of the syllogism. Boolean Logic is a subset of classical logic written in symbols for easy manipulation.

We need to be able to talk about computer design. This talking about design maps to rhetoric.

All of the little tricks we pull on our coworkers to win the battle of ideas fall under the guise of rhetoric.

This whole thing we call computer science is very much a natural development from the discourses Aristotle that took place a few millenniums back.

The computer sitting on your desk top is essentially doing what scholastic monks were trying to do in the Middle Ages. Computers are trying to make sense out of an endless stream of syllogisms.

The book "Aristotle's Children" is a fun read showing hows societies blossom when the people embrace logic and how societies falter when power brokers first try to control the use of logic and are later compelled to stamp out reason.

This cycle of reason blossoming and being suppressed by man's innate desire to control others has been repeated time and time again in history.

Orwell's generation was the generation that removed logic from our primary school curriculum as politicians sought the creation of new control based languages. (The left, the right and this thing called ISIS in the Middle East all use control based languages to consolidate power).

So, let's look at the removal of logic from the curriculum.

Anyway, the Trivium formed the heart of education from Aristotle up until the early 1900s.

We had a education which focused primarily on teaching people how to develop and communicate ideas.

The problem is that people who learn to develope and communicate ideas tend to become unruly.

Seriously, people who are skilled at reasoning start to realize that the ideas coming from the king are no better than those from the learned pauper. Even worse, since they can communicate, their discontent with being ruled can spread.

In 1776, there was an event in which classically trained thinkers in the colonies had the temerity to up and rebel against their beloved king! (gasp)

It happened again in France a few years later! (gasp, gasp).

I don't want to get into that spectacle beyond saying that people who learn to reason will question their leaders and become unruly.

After the horrific events of the American and French Revolution, the ruling class retreated into its ivory halls to address the question: How does one reign in all these unruly people?

If language and logic are the source or rebellion, one must create new languages and new logic to reign the people in!

These new creations were called "ideologies." The new ideologies generally feature some form of "modern logic" coupled with some form of control language.

BDD seems to fit this pattern called "ideology." The people who push it seem to fit to a model called "ideologue."

Historically, one of the first new ideologies was created by King William IV and Sir Robert Peel (1778-1850). It is called "conservatism." The century saw a ton of other control languages and logics including socialism, modern liberalism, capitalism, progressivism, etc..

What the ruling class did was truly clever. Both the Left and Right are based on the essentially the same structure. Rule by George Bush and rule by Barrack Obama both result in centralization and a growing state of individual disenfranchisement.

There's not just one ideology based on the modern form. There's hundreds and many of the ideologies re-inforce each other.

Behaviorism is really just one of a whole class of ideologies that feature a control language and new logic. Behaviorism is often applied in political science where political decide on a desired outcome then set in on manipulating the people until they achieve their outcome.

The US Founders dreamed of a society where people, trained in classical logic controlled their government. The removal of logic from the curriculum flipped the switch and we now have a ruling class set on manipulating the people.

After reading North's work, It is clear that BDD shares both a name and structure with this an other ideologies.

As for the need to create a new language, I contend the existing languages work quite well.

Creating a newspeak to reign in software design is likely to make communication harder in the long run as each little fiefdom develops its own newspeak.

I would encourage anyone confronted with BBD at work to resist.

If you really want to learn to communicate, I suggest reading "The Art of Thinking" (aka The Port Royal Logic) written by Antoine Arnauld in 1662 before inventing a new language.

Sunday, December 27, 2015

I Don't Need sqlLoop

What was I thinking?

Yesterday I introduced a new function called sqlLoop().

I can do everything in sqlLoop() with repeated calls to sqlRow().

sqlRow() works as follows. If it is successful, it returns an array full of data. On failure, it returns an array in which the first element is false. My loop looks like:

$row =sqlRow($sql);

while ($row[0]) {
  // process row
  $row = sqlRow(); 
The one problem with this code is that if I forget to call sqlRow() in the loop, I've created an infinite loop ... and I am very forgetful.

Hey, I have an idea.

Scrambles back to the drawing board.

If you call sqlRow('chk') then the function returns true if the row exists and false if it doesn't. It maintains a counter to that breaks the loop.
$row =sqlRow($sql);

while (sqlRow(DB_CHK)) {
  // process row
  $row = sqlRow(); 
The first form is faster, the second protects from infinite loops. I will put this new code up in a minute.

Saturday, December 26, 2015

The Bug is with the User and Not the Program

This just in: The program does not have a bug. The problem is the user. Here is the bug report. The response is simply that I need to learn to program.

The exact bug I reported was that, on my system, the PDOStatement::fetch(PDO::FETCH_NUM) command returns an array when called on its own, but it returns an incomplete string when called in a foreach loop. PHP's documentation states the function always returns an array and that foreach loop is the preferred method for looping through output.

The program does not do what their examples and their documentation claims.

This is the classic definition of a bug.

Now that the bug report has been rejected, I feel free to solve the problem my way.

I've worked with dozens of SQL drivers over the years. Long ago I realized that a SQL driver needs to do things. One needs to be able to take data out and put data back in.

Now, the very first thing that I do when I encounter a new database driver is to create my own wrapper for the driver. I usually call the program that sends SQL commands to the database execSQL(). I usually create two programs to pull data out of the database which I call sqlValue(), and sqlRow().

As the name imply, sqlValue() pulls a single value from the database with a command like:

$user_nm = sqlValue('SELECT user_name FROM User_Table WHERE user_id = :user_id);

I never liked the mysql_ or the mysqli_ family of programs because they are vendor specific. So, I simply wrapped the vendor specific programs with my programs.

Now, I am not as pigheaded as you might imagine. I strongly believe in following industry standards. I was ready to abandon my tried and true approach for the new Object-Oriented way.

But I have yet to see anything which is as robust as my little database functions.

So, what I decided to do over Christmas was to give up on the "object oriented" way and revive the tried and true style of accessing data with simple functions.

I did make one huge leap forward in the way that I loop through database tables, which I will get to after discussing loops.

So, I would like you to take a moment and consider the while loop.

The loop has the form:

While condition is true perform an action.

The condition is a statement that evaluates to true or false. If you have a condition that is always false, you will never see the inside of the loop. If a condition is always true, the loop will run until some one or something kills the job.

Now, lets consider the following PHP Code which loops through an array:

$arr = array('a','b','c','d');
$cnt = 0;
while ($val = $arr[$cnt++]) {
  echo 'Line '.$cnt.' is '.$val.'';
In the conditional part of the statement. The program attempts to pull an item from the array. If the assignment succeeds, the system reports true and the loop continues. When the assignment fails, the system throws an error and the computer pops out of the loop.

That is a very ugly way to handle a loop.

The foreach loop implements an idea called "traversable." It is functionally the same as the while loop, but captures the error more elegantly.

$arr = array('a','b','c','d');
foreach ($arr as $val) {
  echo 'The value of this object is '.$val.'
  if ($cnt++>100) break;
In a superficial way, the foreach loop appears more elegant. As my experience of this last moth shows, the condition for breaking out of the loop is dependent a weird thing called "traversable".

The problem in both the first and second loop is that we are trying to use the code that assigns the value as the condition for the loop.

The form of a while loop should be: "while condition perform action." This next example shows a better form for the while loop:

$arr = array('a','b','c','d');
$cnt = 0;
while (isset($arr[$cnt])) {
  $val = $arr[$cnt];
  echo 'Line '.$cnt.' is '.$val.'';

The function isset() cleanly evaluates to true or false. It returns true for offsets 0 thru 4 and fails on 5; popping us out of the loop.

Looping with sqlRow()

I decided I wanted to improve the looping with sqlRow(); So, I updated the program to work as follows.
If you call the function as sqlRow($sql,$arr), with $sql containing a SQL statement and $arr being an array of parameters. The program will fetch a row with that statement. If you call sqlRow() with no parameters; it returns a row from the last result set. If you call it with the option DB_CHK; the program returns a true/false statement.

A loop works as follows:
$sql = 'SELECT a bunch of data FROM Table WHERE id = ?';
$arr = [$id];  // arr contains a bound array with the variables for the SQL
$row = sqlRow($sql, $arr);  // get the first row.
while (sqlRow(DB_CHK)) {
  // process data in $row
  $row = sqlRow();  // get the next row.

The big trick in the code above is that I pass the $row parameter by reference.

Creating the first row outside the loop seems awkward at first. However, it is useful when producing tables, lists and other HTML elements. You want to know if you have any data before creating the table as in the following example:

$sql = 'SELECT list_data FROM Table WHERE id = ?';
$arr = [$id];  // arr contains a bound array with the variables for the SQL
$row = sqlRow($sql, $arr);  // get the first row.
if (sqlRow(DB_CHK)) {
  echo '<ul class="ulclass" >';  // open Ordered List
  $closeUL = '</ul>';
} else {
  $closeUL = '';
while (sqlRow(DB_CHK)) {
  // process data in $row
  $row = sqlRow();  // get the next row.
echo closeUL;
You don't want to print the UL tags if there is no data.
I put the pre-alpha version of the code in my code viewer. The code has passed my initial tests on this and a few other servers. I will start writing code with sqlLoop() tomorrow.

Wednesday, December 23, 2015

The Best Way to Connect to the Database

I've been thinking about writing an article on the best way to connect a web server to the database.

I can't write this article because, for some unknown reason, I cannot get PDO to work on PHP7. I've completely removed and reinstalled PHP a half dozen times and it simply doesn't work.

I've spent more time battling PDO than I've spent battling any piece of software in my life.

I've had inconsistent results with PDO on every server that I've encountered. There is something seriously wrong with PDO.

Since I can't get PDO to work with SQLite3. I decided to install PostgreSQL.

I didn't want to install the full application on my account. So, I Googled "postgresql hosting" and found someone reselling Amazon Web Services.

ADVERTISEMENT: You can get access to free (but limited) database hosting with Amazon Web Services. NOTE: This link sets an affiliate cookie. I might get a commission on sales. Of course, you are buying something for $0; So, my commission won't actually be anything, but at least it is a sale. It is better to get a commission on nothing than to not get a commission on anything ... or something like that.

If you don't want to go through my affiliate link, you can just type in your browser.

You can sign up for a PostgreSQL or other database. It will create a and user for you. You can then install the PostgreSQL client on your web server (or home computer) and start accessing the database.

On Ubuntu, you install the postgresql client with the command "sudo apt-get install postgresql-client".

After installing the client, you can access your Amazon hosted database from the command line with psql.

It was like  magic. I was able to create and update tables on the Amazon server.

The next step is to connect PosgreSQL with php. There are different modules for different databases. I installed the module for PHP7.0 with the command "sudo apt-get install  php7.0-pgsql"

And ... it doesn't work. I can query the database, but I am unable to modify the database with the PDOStatement->execute() command.

Anyway, as soon as I figure out how to get PDO to work on PHP 7.0. I am going to write that article on the short comings of PDO.

Unfortunately, I can't write that article until I get the damn thing to work.

Although I am frustrated to no end with PDO, I love having a free database on Here is the affiliate link for those of you who skipped the advertisemnet: Amazon Web Services

Tuesday, December 22, 2015

SQLite3 Object

I feel like the biggest dolt in the world.

Apparently, PHP has a SQLite3 Class that is similar to PDO. The documentation does not say it works in PHP7, but first tests indicate that it can connect to the database.

I thought PHP had deprecated all of the database functions and wanted universal usage of PDO.  The inability of PDO to fetch SQL queries had effectively turned my new domain into nothing but an expensive Boggle Server.

The SQLite3 Class is significantly different than PDO. For example, you can't just send it an array of data, you actually have to bind variables to make it work right.

The class has different function names and might have a slightly different work flow than PDO.

The class might be sufficient for my needs; so I will start developing with it ... keeping in mind that PHP is likely to deprecate the object in a future release.


Never mind. The SQLite3 Class isn't working either. There are too many goofy things with this object. For example, the query() and execute() functions return different types of objects, the big kicker, you can't use bound variables for queries ... which was the whole purpose of moving from functions to objects.

Monday, December 21, 2015

Boggle Server

I've been staring at an expensive Boggle Server for the last several days and feeling like a dope.

I can't do anything with my web site migration until I figure out the PDO fetch problem. So, I've spent the last several days playing Boggle over SSH trying to figure out how I can get the site running.

Anyway, I decided, after long hours of torment, that I would file a bug report. It bug report 71185. I suspect it will be summarily dismissed, but It will be interesting to watch the rejection process as I master typing short words on my Boggle Server.

Sunday, December 20, 2015

SQLite3 Drivers?

I finally figured out the cause of the mysterious PHP problem that has stopped me dead in my tracks.

My problem is that the command PDOStatment::fetch(PDO::FETCH_NUM) is returning a string instead of an array.

Apparently, this is what happened:

The SQL standard (which was established before PHP was a twinkle in Lerdorf's eye) return strings that the receiving program must parse.

The RDMS companies that courted PHP in the early days wrote drivers that presented the data in a more efficient manner.

Big companies, like Microsoft and Oracle, are always happy to provide drivers as the drivers create a dependency on their products.

SQLite is an open source, "zero configuration", standards based program which is designed to be embedded in other applications. The term "zero configuration" means that SQLite does not design drivers. I want to emphasize the term "embedded." SQLite hands you their code and you actually embed it in your program; so there is no driver.

Anyway, the problem I am experiencing today appears to be a repeat of a bug reported experienced in 2008.

If you read the report, the PHP programmers say that this problem is the fault of the drivers between PHP and the database. (The drivers take the standards based output and put it in a form more to the liking of PHP).

SQLite is standards based and embedded. SQLite has no drivers. In the SQLite paradigm, SQLite presents source code to the world. Companies like PHP can compile it into their program ... the catch is that it is the responsibility of the company embedding SQLite to make the driver work.

This error is actually quite humorous. This grand PHP PDO object (which is supposed to be the crown jewel of the new PHP) can't handle standards based output.

PDO has a dependency injection. The PDO object is dependent on the external driver written by large firms like Oracle and Microsoft.

I know that it will be auto rejected, but, I am seriously considering writing up a bug report on this issue, but I think I will try a twitter poll first.

Saturday, December 19, 2015

Repeating Mistakes from Philosophy into Code

There is an interesting trend. The academic community takes popular ideas from philosophy and tries to impose them on computer engineering.

Behaviorism is a weird ideology that appeared last century that de-emphasized individual reason in the study of human behavior in favor of the idea that man is simply driven by impulse.

Historically, Behaviorism played a role in the decision to remove logic from the curriculum last century.

Apparently there is a new buzzword in soft ware design called BDD (Behavior-Driven-Development)  that is becoming popular in agile design circles. I've been reading buzzword rich articles trying to sell this technology.

It appears that the goal of BDD is to create a group-think approach to software development that creates something called "Domain Specific Languages" that spews out code.

Kevin Dishman wrote a blog post called BDDont questioning BDD as a design tool.

I want to applaud Mr. Dishman for standing up and calling out this technology.

The ideology of Behaviorism has not improve society.

Ideas from behaviorism have influenced both the left and right, and we see that many politicians and people are making their decisions based on impulse and are not reasoning through ideas.

How can we reason through ideas if we never learned logic?

What we have now is a political system with media feeding us an unending stream of images which cause impulses which then cause us to vote and tweet in predictable ways.

The factions in our political system use Domain Specific Languages. The result of removing the study of logic from schools and emphasizing behaviorism is that the people at large have become tied up in factions and cannot communicate with each other.

Personally, if I was working for a company that tried to impose BDD, I would probably just leave. But, you know, the imposition of BDD in the work force creates a situation where one can actually measure the results of development driven by a group-think process to ones in which individuals engage in reason.

The latter, reason, produces better results than group think. I hope Mr. Dishman keeps up his scrutiny.

After Hours of Debugging I Discovered This

Two days wasted. I've been running the following code on PHP verion ""
  $sql = 'SELECT id, test_nm FROM Test_File LIMIT 3';

  $db = new PDO('sqlite:/var/www/db/main.db');
  $stmt = $db->prepare($sql);
  $row = array(1,2,3);
  echo gettype($row).'</ br>';
  // This reports row is an array.

  foreach ($stmt->fetch(PDO::FETCH_NUM) as $row) {
    echo 'This should be an array it is a '.gettype($row).'.
    // this reports that row is a string.
This is the result of the query on my server:
The PDO::fetch() directive on this version of PHP returns a string. The description on PHP.NET says: "PDO::FETCH_NUM: returns an array indexed by column number as returned in your result set, starting at column 0"

I got my compiled version of PHP from I guess I am stuck waiting for Ondřej Surý to update this package to PHP 7.0.1 to figure out if this bug is related to something I did or this version.
This failure brings me back the the question: Are objects superior to procedures? Here is an object a production version of PPP 7 causing total failure in the system I am trying to port to PHP 7.

This particular failure took several additional hours to debug because I assumed that the problem was something to do with the path I took through the object. It didn't even dawn on me to actually check the type of the data coming out of PDO::fetch() as the manual said it was an array.

NOTE: A 2008 bug report says the problem is with the database driver and not PHP:

Thursday, December 17, 2015

Expanding Source Files

The first version of my source code viewer had a fatal flaw: It could only display one file at a time.

When I code, I usually break things up into several files.

I don't want to open every file; So, I took advantage of the fact that PHP has two ways into include a file: include() and require(). The code viewer will put a link to the code if included with include(). If I use require() it will include the code from the required file in line and light up the line with a purple background.

You can expand and hide the required code by clicking on the line.

As mentioned in the last post. I am trying to write this program in vim and vim is driving me batty.

I wanted the program to include the files with a recursive call. But something wasn't working.

I took the low road and wrote the code so that it buffers the code from the various files and re-orders them the way I like.

Anyway, this exercise of writing a program in vim was very useful as it showed me how the tools one uses to write code affects the code.

Here is the current version of the code viewer:

Hmm, I just tried saving this post by hitting esc and typing :w. I appear to have gone off the deep end.

Tuesday, December 15, 2015

Source Code Viewer

I wrote a Source Code Viewer.

There are two things behind this project. The first was the practical problem. I was cutting and copying code for display on my site and I accidentally added errors to the code.

Since my goal is to discuss working code, why not just pull the code from my site?

The second thing. I was playing with the vim text editor that comes with Linux and I wanted to see if I could just sit down and write a program in vim.

Now, I admit, I had become accustomed to the advance code editing features of the WYSIWYG Notepad++ editor. So, I wanted to prove that I could write code in another editor.

By default the code viewer shows the code I wrote to make the code viewer. Unfortunately, this particular piece of code is a big funky as I haven't figured out how to efficiently move text around with vim. In Notepad++, I just highlight it with the mouse, copy and paste. In vim one has to switch modes, yank and move.

I think it is good to periodically switch environments as it forces a rethinking of basics.

My Source Code Viewer lets me display the actual source code of my new site online. It pulls the code from production directory with file_get_contents() and highlights the different parts of the code with bright colors for easy reading.

Currently the code only shows two programs. I will add more as I start porting my sites to this new server. You can comment on the project below or on the Discus Forum.

Sunday, December 13, 2015

PHP PDO Wrapper (Pre Release)

I dread writing this post and keep putting it off, but I have to get it out of the way before completing my web site upgrade.

After experimenting with dozens of different designs, I decided that the best way to handle PDO database connection in PHP is to encapsulate the PDO object in a procedure.

The Design Pattern crowd labels this approach an anti-pattern and a dependency injection.

The two pieces of code that I am publishing are: A notification which I am calling msgNote and a procedure that encapsulates the PDO connection called dbMain().

Together these two programs have 200 lines of code ... a third of the lines are comments.

WARNING: This morning I decided to change the error handing on dbMain(). I have not tested the program fully. Expect dbMain() to change as I run it through tests on this, my test server.

The program is in a test phase. I welcome comments on this page or on my disqus widget.

Thursday, December 10, 2015

Trump and other forms of Low Quality Discourse

The "Trump equal Hitler" campaign has been in the works for the last several months.

The campaign hit with such a fervor last week that I finally relented and looked up the incindiary remark that Trump made to throw the campaign into full swing. Here is the video:

What Trump said is that we should block Muslims from entering the country until congress debates the issue and finds out what is going on. He then cites sonm reports with troubling polls which indicates a troubling amount of radicalization within the immigrant community.

Technically this is a call for debate. Using a bombastic sound bite to start a debate is a rhetorical style. In Marxian theory, it is called a Praxis. Bernie Sanders often lets loose with bombastic statements.

The big question here is if Trump follows through with a quality debate or not.

I admit, I have a certain amount of empathy for Trump on this issue. I spent a solid six years trying to find a group within 500 miles of Salt Lake willing to talk about free market health care reform.

I finally gave up. Not being able to find people willing to talk about the issue devasted me. I don't mind losing debates. Not being able to find people brave enough to discuss free market health care reform completely floored me.

We, as a society, have lost the ability to discuss issues.

Come on world. The United States is in a horrible situation. The Obama Adminstration passed the most intrusive health care legislation in American history and no-one is willing to discuss the mathematics of health care.

In the Bush Adminstratioin, our president invaded Iraq before asking the fundamental question: Is the Islamic world open to Western ideas about democracy.

Bush simply assumed that the people in Iraq were yearning for freedom and would automatically take to the idea of electing their leaders. The actual experience was that tribal warlords set in on each other seeking political dominance.

It is naive to believe that all religions on this world share the same ideals about governmance as Christianity.

From its inception, Christianity drew a distinction between the secular and sacred. The New Testament holds that Jesus Christ was far more interested in individual ethics and the after life than in worldly power. Jesus surrendered unto Caesar what was Caesar's. The message was about individual salvation than a quest for power.

Politicians love to cross the line between Church and State. The core theology of Christianity holds the sacred, which deals with the eternal, is of a higher rhealm than the secular which deals with the politics of day to day life.

Not all religions make the same division.

To the world's misfortune, the political impulse is for people and groups to grab for all the power that they can get. Notably, in the Roman Empire, the Caesar set himself up as a god.

One finds many religions with a close tie in between the political structure and religion.

Western history shows politicians (in both the clergy and state) eager to jump across the division between the secular and sacred to grab power.

Of particular interest in the English speaking world: King Henry VIII set up the monarch as the head of both church and state.

The American Experiment in secularism wasn't just a political argument. It was a combined political and theological argument. It is an argument that assumes that both political and religious leaders are supportive of secularism.

The truth is that the politically ambitious use whatever is at hand to take and consolidate power.

I live in Utah which is dominated by Mormons. Mormonism is a religion created in the United States. While most contemporary Mormons support a strong separation between Church and State, when one looks at the history of this American born religion one finds politically ambitious people in the movement seeking to establish a theocracy. (Eg, an LDS Prophet named James Strang declared himself king. One can find references of Brigham Young attempting to establish a thing called "The Empire of Deseret" which included a good chunk of Colorado and stretched Southwest to San Diego. Brigham Young held both religious and political authority.

On the otherside of the religious spectrum, most atheists support "secularism." One can find radical versions of atheism which are simply intolerant of religion. Modern atheists committed many of the worst atrocities in history in the efforts to purge religious.

The political impulse is for people to dictate their beliefs.

BTW, "secularism" itself is a paradoxical belief. The Parliament of World Religions had its conference in Salt Lake this year, giving members a chance to interface with people from different religions. Some people in the Parliament seem to be set on creating a new über-religion that incorporates elements of all religion. Is an ecumencial effort to merge all religions into some sort of super religion secular or is it a grab at power?

But that's a future debate.

The number of historical incidences where political leaders sought to use religion to gain power or for religious authorities to use political power to impose their morality exceed the incidences of people trying to separate the two.

It is naïve for the West to encourage wide scale immigration from the Islamic world without addressing the important issue of how the west will assure that the immigrants adhere to the ideals of secularism.

The bombing in Paris and attempts by Islamic groups in the Middle East and North Africa to impose Sharia Law indicate that maybe something is amiss here.

France has bent over backwards since WWII in accommodating Islam. France and Belgium seem to be having more problems with Islam than other immigrant groups.

The picture below came from wikipedia. Assuming its true, then it shows people who are not appreciative of democracy:

About Tolerance

I favor tolerance. But true tolerance must be based on understanding.

The first thing we need to know about tolerance is that tolerance is subject to the reflexive paradox:

Supressing intolerance is an act of intolerance. Yet if a society that favors tolerance fails to address intolerance, the intolerant might come to rule the day.

This is one of a myriad of paradoxes that Hegelian dialectics works upon. People, left and right, jump on the band wagon to supress Donald Trump failing to realize that the spectre of irrational group action is precisely the thing that made Trump's message so appalling.

I want to repeat my remarks above. There were people who wanted to debate whether or not Islam was open to Democratic/Secular form of government before Bush invaded Iraq. In theory, Trump thinks that we should have that debate before blindly inviting large throngs from Syria into becoming citizens of the United States.

I sincerely believe that such debates are good things. Blindly believing that Muslims are good Christians who believe in separating the sacred and secular, we should actually listen.

Many religions and ideologies seem to take well to the ideal of a secular and pluralistic society. Some do not.

Most religions present a mixed bag. Most people favor tolerance, but the politically ambitious have, throughout history, felt compelled to impose their morality on others.

As for Trump

As for my actual feelings about Trump. While I understand why he did what he did, I think his actions show that he is not in tune with the psyche of the American people and is unlikely to be an effective president.

It is infuriating that people cannot debate immigration policy in this country without being labeled racist. It is infuriating that Obama passed a healthc care bill without adequate debate. It is infuriating the Bush invaded Iraq without apropriate deliberation.

Something has happened to this country which has destroyed our ability to engage in public discourse.

Trump claimed that he simply wants Congress to debate the issue.

That's a laugh. It's been decades since Congress last engaged in a debate. Today's Congress simply a collection of individual fiefdoms full of political leaders who posture as government leaders dictate. Congress has not engaged in serious deliberation over an issue for decades.

Unfortunately, we cannot break out of our disputational malaise through bombastic statements. It has been tried again, and again and again to no avail.

There are things that the right could do to win debates, which I don't have time to develop right now. The approach Trump just tried is doomed to failure.

Trump's little soundbite was trumped by an even louder sound bite with pre-engineered campaign to project the image of Hitler on Trump and the image of the National Socialist Party on the GOP. [BTW, the Hitler campaign is rather funny. The left claims that anyone who stands against socialism is a National Socialist ... but people have such poor education these day that people fall for it.

Our inability to engage in discourse appears to be setting our society up for failure.

We've just seen terrorist attacks in Paris and San Bernardino. Rather than uniting and looking for ways to address the growing international problem if Jihad, our leadership and American press have turned into a full frontal, no-holds-barred, attack on their political enemy---the GOP.

America has lost its ability to engage in rational discourse and that does not bode well for the future.

Tuesday, December 08, 2015

Disqus Thread

I am doing a huge web redesign for Community Color and my home page. I will open source the code I write under the title The Resource Model for Web Design.

I decided to open a Disqus thread on the site in the remote chance that there are people who find PHP programming, database and web design an interesting topic.

I am blocking out the site in HTML while testing and porting the code to PHP7.

I admit, there is a political aim to the site. I want to encourage PHP programmers to resist the dictates of the design pattern crowd.

Saturday, December 05, 2015

Hello You Silly Person

NOTE: I finally got PHP7 installed and working from Apache2.

I logged into the server as "root" and ran all of the scripts without "sudo."

there is not supposed to be a "root" user on Ubuntu; my web host created one so the administration of their VPS servers would be consistent.

Anyway, they are going to send me to Ubuntu Hell for logging in as a superuser, but maybe I am already there.

I've been working my web server configuration.

For those of you who think I am too stupid to get PHP 7 installed on a server, I posted the image above to prove that I got the program installed. This little command line program executes the phpversion() command and tells me that it's version 7.0.
I am smart enough to get PHP on the server. I am just not smart enough to get the web server to run the blazing script.

I can't officially write a hello world because the flappin' program can only talk to me.

BTW, I realized I probably made a mistake installing Ubuntu. The Ubuntu world seems driven by the idea that installing programs is all about the installation script.

The site AskUbuntu says that, since PHP7 was just released on Dec 3, we shouldn't expect a Ubuntu script for quite sometime. It sounds like it might be a couple of months.

I've been reading web pages about all of the different install scripts and forks of install scripts that people have made for this release. The idea that we can maintain web servers through magic scripts by third parties is even more confusing than the idea of just learning to read and directly edit configuration files.

The command line tells me that PHP is working. I now just need to figure out what I need to do to apache2 so that it can find and execute the programs.

I did learn one thing today. Apparently, admins were adding the line:

AddHandler application/x-httpd-php .php? 

to their Apache configuration file; so that php would run on various php extensions and that script-kiddies would upload files with the a name like "image.php.png" The upload program would think this a harmless image. Apache2 would see that it matches the AddHandler pattern and execute the malicious code in the file.

Anyway, all the nice little scripts by ubuntu are fun. In the long run, I still think it best to figure out the configuration files and to learn what programs do what on the web server.

I am just wondering how much longer it will take before I get this server ready. I need to find a page that tells me all the pieces that need to be in place for apache to run php on scripts and I can't find a good resource.

Thursday, December 03, 2015

On the Makers of Refugees

Last month, I wrote a long post on the refugee problem.

The post started with the observation that refugees tend to dislike the tyrants who made them refugees and refugees tend to become staunch advocates of liberty and are prone to be hawkish on the needs for strong national defense on seeing what happens when a nation fails to defend its people.

A general rule of thumb is that if the west treats refugees well, the refugees will develop into advocates for a free society.

That said, it is possible that a refugee group itself has been radicalized.

The attacks in Paris prove that some immigrants to France have been radicalized.

When discussing refugees, one has to look at the particular refugees and there has to be a dialog about the long term effects of the refugees.

I suspect that, on the large, the people made refugee by ISIS will be staunchly against radical Islam.

Since the Syrian refugees have personal stories about the horrors of radical Islam, it is highly likely that they could help stem within the existing Islamic community in the West.

To assure that the refugees will be a positive influence, our nation needs to scrutinize the refugees.

Here lies the problem. The activist roots of our current president raises question as to whether or not the administration would engage in the proper scrutiny of the refugees.

Obama's treatment of the San Bernardino shows a president who is more interested in attacking his political opponents at home than in defending our nation against terrorist threats. Obama did not wait to find out information about the shooter before shooting off attacks of his political opponents.

The San Bernardino attacks followed shortly after similar attacks in Paris, yet the president is so blinded by his partisan views that he was out agitating against domestic rivals before intelligence on the shootings were available.

A community activist, by definition, is a person who activates a group of people against the activist's enemies. So, while we are looking at refugees who are likely to become allies in the struggle against radical Islam, we can't be sure that our activist president will not, himself, seek to activate the refugees in his political.

This political style of Obama makes claims like Mike Savage's accusation that Obama is Building and Seeing a Refugee Army within the United States plausible.

Ann Coulter points out at that a disproportionate number of the mass killings in the US seem have been committed by immigrants.  There a great deal of documentation showing that there has been efforts to radicalize immigrant communities.

In conclusion, if handled properly, the Syrians refugees could help stem radicalization in the Islamic community by telling people the horrors that drove them into exile from the Islamic State.

In practice there is very little reason to believe that the current administration will handle the acceptance of refugees properly.

The ideologies in place in the US and Europe may have created a climate where the influx of refugees will destabilize nations and lead to even more horrors and refugees.

San Bern(uh)dino

There was a mass shooting yesterday in San Bernardino.

Before the bodies were cold, President Obama rushed to the nearest microphone and began agitating against his political enemies and campaigning for new regulations.

There were hundreds of thousands of comments and retweets on the mispelled hashtag #SanBernadino ... most were from people who were simply trying to spin a sensational event to their political bent.

Many of the tweets asked why becoming so violent. Favorite answers included the Tea Party, the NRA, the GOP and Christianity.

Having invested a great deal of time into studying the history of logic, I suspect that the reason we are becoming more violent is the result of the way that we are taught in school.

Back in college, my dream was to become a high school math teacher. I attended the education department of the University of Utah back in the 1980s.

This department, and other departments across the nation, were teaching an activist model for education. Paulo Freire's "Pedagogy of the Oppressed" was a primary text along with Plato's and Marx's "Manifesto."

A primary theme of Freire is that education is a praxis in the social revolution. We were given assignments in which we were asked how to organize a classroom around the ideal of a social praxis.

I was horrified by what they were teaching. Having studied the history of math and logic, I realized that they were teaching the same ideology that had taken Europe by storm before World War II. Back in the 1980s, I said that if we organize education this way, we will end up with a violent society.

The professors at the U were so upset at my challenging their authority that they flunked me out. I flunked three classes in one quarter, destroying any attempt I could make at pursuing a career in teaching.

My distaste of activist education is so strong, that I was willing to stand against authority and have my career destroyed by taking the stand.

An activist education teaches us that the society progresses though social conflict and that the activist teacher needs to prepare students through propaganda and by organizing the students against the enemies of the party.

Activism can be effective in bringing a party to power. Activism can help a partisan group put down its enemies.

The problem with an activist education is that it destroys people's ability to communicate and can even destroy their ability to reason.

Back in the 1980s (and even today) my ideals about math education is that the goal of a math teacher is to teach mathematics. A good math teacher might delve into the history and conflicts which have taken place in mathematics and logic, but should stay away from the political.

The hope behind this form of education is that students who have a firm grip of mathematics might be better equipped to handle the challenges they face in life.

Truthfully, I've become even firmer in this stance.

Freire drove the ideas that schooling should be seen as a praxis.

The term "praxis," in the Marxian school of thought, is an action taken to realize a philosophy.

Many of the mass shootings that we see today seem to follow a pattern of a Marxian praxis.

The Colorado Springs shooting was done by a man upset at Planned Parenthood's selling baby parts. He killed some people at random and said the selling of baby parts must stop at his arrest.

This is a praxis. It is a classic praxis.

This is what Paulo Friere was teaching should be fundamental to education!!!!

Thirty years ago when I was flunked out of the University of Utah, my complaint was that education theory which had swept the nation would lead to a populace that was unable to engage in discourse and that was likely to engage in violence.

Today we have a president who was weened on the Alinsky style of community organization. The fact that Obama was using the shooting to agitate for political change before we even knew the name of the suspect in the shootings shows that the ideals of activism are fully in play in our nation ...

... and, as I feared in the 1980s, we are becoming a violent society as result.


Now, I need to point out something that is extremely scary.

The education we receive in school affects both the left and the right.

The Right Wing Conservatism that we see today shares the same foundational philosophy as the left.

I've attended Tea Party meetings and Conservative rallies in which the organizers are repeating exactly the same methodology that occurred on the left.

So, we are seeing an unprecedented amount of agititation coming from both sides of the political fence and are seeing fewer and fewer public figures effectively engaged in discourse.

The reason that this is happening is because our schools have been using the activist model.

There were over three hundred thousand posts and retweets with the misspelled hashtag #sanbernadino before the police released the names of the shooter. My tumblr feed was polluted with activist messages using the shooting to attack their enemies.

The activist education that we received in school is destroying our ability to engage in discourse. Unfortunately, it has affected the right as deeply as the left giving us no where to turn.

Tuesday, December 01, 2015

On Aiming a Canonical

I accomplished less than I wanted to today. I spent most the day researching SSL Certificates, then installed one on

If I did everything right, the SSL version of the page should no longer issue warnings about the site. Please drop a note if it does not.

Switching to https also meant I had to add an "s" to inbound links so that people will go to the SSL version.

When there are more than one version of a page online, Google suggests adding a "rel/canonical" tag to let search engines know which page to index. The tag on should look like this <link rel="canonical" href="" />

Now, I tend to have typos when I type URLS.

While trying to figure out how to text the links, I discovered that FireFox has greatly improved its view source program. If you are in a web browser, you can right click in the page and select "View Source" from the menu.

The View Source Page highlights all of the links including the link in the rel/canonical tag. The best part of FireFox's View Source is that you can follow the links and verify that they work.

If you are a web developer, it is to browse through view source and check all of the links on the page. IMHO a good web developer should spend a good portion of the day checking out HTML code in view source. This is a topic I will address in my upcoming web tutorial.