Posts

Showing posts from May, 2019

Is trying to program making you loopy...?

So we've discussed two of the main building blocks of programming: Data and Control Structures. With those, you can do things once for every time your program runs. Well what if you want to do more than once and done? Loops. As I've mentioned before, there are two basic kinds of loops. One kind runs a particular number of times that the program 'knows' in advance. The other type runs until some condition becomes true. That first kind is a For loop. Here is an example of how you would use one...Suppose you wanted to print out the numbers from one to one hundred. The pseudo-code: For the numbers 1 to 100 Print the number Sort of a trivial use though. How about if we want to also print out whether the number is even or odd: For the numbers 1 to 100 If the number is even Print the number and the word even Else Print the number and the word odd Did you just feel a twinge of excitement? The pieces are starting to come together... Let'...

Am I too controlling?...

Well, we've discussed an overview or programming terms and discussed data. How do we get a program to do something interesting? The answer...control structures! Control structures are commands that check for some condition and then, base on the result of that check - run different blocks of code. The simplest type of check is whether or not something is 'true'. To accomplish this, we use If-Then. For example, suppose we want to have a program either say 'Good Morning' if it is before 12 noon. I will be using pseudo-code so I get to ignore some of the details - like 'how do you know what time it is?': Find the time and store the hour of the day in a variable If the hour is less than 12 then Print 'Good Morning' Easy-peasy! But, if it is after noon, then our program won't do anything (at least as far as the user can tell). So, let's have the program say 'Good Afternoon' if it isn't morning. To do this, we move on...

Constants and Variables....

So, you want to make a computer do something useful. Well, then data is going to be involved one way or another. Even the simplest programs (like 'Hello World') deal with data! Some of it might be invisible to you - but it is there. Let's take a look at Hello World. First of all, if you don't already know - the objective of this 'first' program whenever you are beginning to program in a new language is to print out 'Hello World!' (or some variation of that). We may as well take a look at the objective to figure out what the algorithm and pseudo-code would be for this. First the algorithm: Open a connection to some output device (usually the screen) Print the string 'Hello World!' Close the connection Most programming languages automatically open a connection to the screen for you so this step is almost always ignored. But if you think about the fact that it is happening (even if behind the scenes) then it will make your life eas...

Building Blocks...

When thinking about how to build a program, you need some vocabulary and some pieces to build programs out of. There are a relatively small number of basic building blocks to build programs out of: Data Control Structures Loops Data structures Each one of these deserves and needs extensive explanation. But first, here is a quick overview of these. To start - lets talk about about data. In order to make sure that we don't make this specific to any particular language I will just talk about fairly basic data types: Integers (whole numbers) Reals (decimal numbers) Booleans (true or false) Strings (text) With these four types (possibly in combination) you have enough to store just about anything that you need to. Control Structures provide you a way to decide which section of code is run based on some condition. Examples of control structures are: If Then If Then Else Case (or Switch) The If-Then lets you run a block of code only if some condition...

So, what is programming?

Image
Well, that is a good question. And I think that it has a simple answer: Programming is the act of transforming a desired process into an algorithm and then implementing it. I don't know if anyone else ever said it that way - So I am going to pretend that I was the first 😀 But what does that even mean? If I want to be a programmer/coder what do I have to do? Well, there are two major steps there: Transforming a desired process into an algorithm (a defined set of steps to be followed) Implementing it The first step means that you have to figure out all of the little steps that are part of the process that you want the computer to perform. Doing this is usually harder than the actual coding. Here is an example to illustrate: add up the odd numbers between zero and 100 Well, for a person - that would be enough. Computers need a bit more detail. For example, what is an odd number? And, this is where pseudo-code makes its appearance. Pseudo-code is something that...

New beginnings...

I've run into an interesting realization. I'm not 'good' at front end development. But I am 'good enough' for everything that I've needed to do up until now. The first web app that I wrote was back in 2005/6 - right around the time that AJAX (Asynchronous JavaScript and XML) was beginning to catch on and interactive web development began to be commonplace. Up until that point I had always considered that JavaScript was a fairly useless language. In my defense, the main usage that I had seen for it was things like scrolling banners. Because AJAX was so new - the first version of that app was written in PHP and it depended on full page submissions with completely new page loads to get the screen updates. Luckily for me, the performance of the site was TERRIBLE. So, I went searching for alternatives. And, I found out that another of my old prejudices was about to be destroyed. For a bit of history, back in the mid-1990's Applets were the main way ...