Tuesday, September 29, 2009

Behavior Software Modeling

I have always wondered, how do we succesfully model what happens in the real world? For instance, if you have a mathematical formula that calculates how long it will take someone to get from their home to the grocery store, how would you try to get the software to accurately display this? Short answer: There are many ways.

1st way: You could have some preset values in a list, and depending on which person you are selecting to go to the grocery store, you can just have the value already programmed into the formulas. For instance, Judy drives really slow, so if the grocery store is 30 miles away, and she drives at 30 miles per hour, it will take her 1 hour to get to the grocery store. If Karen goes to the store, she loves to speed, so if she drives at 90 miles an hour, she would get to the grocery store in 20 minutes, which is 1/3rd of the time it would take Judy to get to the store.

2nd way: You could plug this into a mathematical modeling system that take into account all of the variables that you feed into it. For instance in the mathematical software platform called Mathematica, you could feed in multiple values and try to get the computer to figure it out for you. For instance you say that 1. Judy drives 30 miles per hour; 2. She stopped to get gas for 8 minutes; 3. She went to McDonalds after going to the grocery store, so she was in line for 11 minutes; 4. The traffic was traveling at 5 miles per hour for 6 minutes after she left McDonalds, because there was a car accident.

There are many more ways, but you get the idea.

Thursday, September 17, 2009

IDE Advantages and Disadvantages

IDE Advantages

A couple of people have asked me 'what is an IDE?' so I'll give you a quick answer. IDE stands for Integrated Development Environment. This is a computer program, such as Visual Studio, or Eclipse, or Netbeans, or Borland, etc. that allows you to write a computer program in notepad form. The main advantage to using an IDE, instead of typing your program into notepad is that the IDE usually checks your code for errors as you type.

The biggest advantage that I have found:
1. You can run your code, line by line, and you can find out exactly where your errors are. On top of that, you can also view the status of other variables dynamically as you step through the code.
Look at this snippet of code(I am using Perl, not C#):

1 SisterAge=17;
2 BrotherAge;
3 print "Your brother's age is " . BrotherAge;
4 BrotherAge=15;
5
6

Line 3 has an error, because it is trying to access a value that hasn't been assigned yet. I know this is a simple example, but imagine if you have written about 1000 lines, and then you'll see how useful it is. It is so easy to miss a simple mistake, and you'll be pulling your hair out trying to find it!

There are other reasons why using an IDE is great:
2. You can use it to develop a GUI, because the most common controls, such as buttons, checkboxes, etc. already exist. You can just click and drag them to the screen.
3. The IDE can automatically fix your errors or suggest the proper fixes.
4. The IDE will automatically add the proper packages that you need to import (in Eclipse)
5. You can perfom multiple undos to correct your mistakes you just made.
6. You can get updates and notifications of common fixes in email or through your RSS within your IDE.
7. Some IDEs even have a team of people that can help you with your programming, and they can connect to your computer with remote assistance. It's sort of like a warranty that is provided with your purchase of an IDE (of course school provided software or free software doesn't count).

You can't count out that there are some drawbacks to using an IDE
1. They take up a lot of space on your computer
2. They can be a hassle to update and/or install packages
3. You have to learn each one well, and sometimes there is a steep learning curve.

However, the advantages outweigh the disadvantages, but I would say, PLEASE don't try to go out and learn them all. Just stick to one or two and learn them well. Here is a previous post about IDEs http://josephamospowell.blogspot.com/2009/08/visual-studio-vs-eclipse.html

Tuesday, September 8, 2009

People don't read blogs!

It is presumptuous to think that people sit around at home all day and read blogs on things that they don't care that much about. I know it's true for me. If I wanted to know about the new Halo game, I would go to someone's blog and find out what they thought of it.

There's just one catch... some of the blogs are too long! Just like reading a headline about a certain celebrity that we're obsessed with, or about some odd news around the world, we like our information quick and fast. We do not want to sit around and worry about all the details, we just want the juicy ones.

So if there is any piece of advice I would like to offer anyone who loves writing blogs: Keep it short!

Monday, September 7, 2009

2D arrays

About 2D arrays  

There is a game that is called Tic Tac Toe. It is a great game to understand how 2D arrays work. If you don't know what an array is, I would suggest searching for it online and doing some background work, or looking at my previous post about a 1D array. Basically a 2d array is just a group of items that are arranged in rows and columns. An example of an application that uses 2d arrays is Microsoft Excel. You have items that are in a row and column. Another example is Tic Tac Toe. That is a 3 X 3 array. That means that there are three rows and three columns. The thing to remember is that rows are first and columns are second. So in a 3 X 3 array, just say you have buttons (see picture). To set the name of the top right item, type:
button[0][2]="green arrow";






Another example is the starburst candy, which is a continuation from the last post (can't you see I love candy?)




Always remember to start counting at Zero, not 1.
If you have any questions, just email me at joseph@uthinksmart.com


Thursday, September 3, 2009

What Is An Array?

An array is a container that holds a group of data of the same type. An easy way to understand this is to think about food… I love using food examples to explain computer science concepts, because I LOVE EATING!! But anyway, think about Starburst candy. It has a wrapper, which you can think of as the container, and all of the individually colored candies inside represents the contents. A standard array is just one row long. Look at the picture of the starburst candy. We have to remember that we start counting from zero, and we need to make sure that we name each individual item. For instance in the example, the 6th element is represented by starburst[5] so all you have to do is assign the color of the starburst by using the number contained within brackets. This is pretty self explanatory. An important thing to remember is that we cannot try to print something that is not there, for instance, if you try to do this: print "the color of the 12th piece of candy is " + starburst[11]; Just for the record, the last example was written in the Perl programming language.










Above is an example of a 1D array.

The thing to remember is that arrays and other concepts exist in virtually all languages, all you have to figure out is the syntax.

I will talk about 2D arrays soon.

Wednesday, September 2, 2009

Emulator and exe files

One thing that I discovered while developing the Visual Studio mobile applications is that the emulator runs distinctly different from the .exe files. One perfect example is when doing the checks for the screen size. When you are using the Pocket PC or any of the Other Smart Device emulators, the screen works perfectly. Moreover, when you try to specify a grid size that is too big for the screen, you will get an error message alerting you that you cannot use that grid size and to select a smaller grid. I added this "screen integrity" check into the program to accommodate for different sized screens. In contrast, the exe program that is produced from the debug process does not link explicitly to any emulators and uses the .net platform to display a basic window. It does not do a screen check at all, and it will allow you to specify a grid that is much larger than the original. In this case, I just had to limit the amount of rows and columns within the GUI itself to prevent someone for specifying a huge amount of rows and columns.