Monday, October 25, 2010

Project 2 - The internet

Based on the article: The Web Is Dead: Long Live The Internet

I don't really agree with the premise of this article, the web is still well and alive, not even mortally injured or sick in my opinion and I can see the web staying alive as time goes on.

As to what's written in the article itself... it's rather silly, in my opinion, to try to point the blame at either "us" or "them" (meaning consumers or corporations). For several reasons, first off: it's like writing a eulogy for someone who's alive and blaming someone for their death. Second, the consumer/corporation relationship is too complex to simply say either one is solely responsible for any change. If people didn't want it, corporations wouldn't make it, and if corporations didn't think they could get people to want it they wouldn't make it. Often times, consumers give some sort of feedback on some product that corporations try to take advantage of and sell (i.e. hey this is nice, but it would be cool if...).

The distinction being drawn in the article is that of: people use the internet, but are moving away from browsers. The blaming difference is why this is going on. The writer giving the opinion of we are to blame, Chris Anderson, primarily argues that the reason for the web "dying" is that smaller app-based things fit into our daily lives better. The writer giving the opinion of we are to blame, Michael Wolff, primarily argues that the reason for the paradigm shift towards apps over the web as we know (knew perhaps) it, is about making money. Of course, because of how capitalism works companies would do their best to make money, but they alone can not kill the web. In particular, there are many aspects of the web that have nothing to do with profit at all, such as the many sites devoted to Linux. Linux is a term used to describe many pieces of freeware (Ubuntu etc.) that are worked on by just anyone who has a mind to. The graph showing a supposed decline in the web over time has a significant issue in it. Whilst it may be true that a smaller amount of internet traffic is used on websites, it should be remembered that the number of people on the internet back in 1990 (when the graph starts) is significantly lower than that in 2010 (when the graph ends), ergo, it is not really representative in how much the web is used except as a comparison to other mediums and it would not surprise me in the least if the amount of web traffic taken by itself shows an increase over most of that time period, instead of the sharp decline that particular graph shows.

Though both articles bring up valid points and ideas about what is going on with the internet market so to speak, it is silly to consider the web dead, by any stretch of the imagination.

Project 12 Program Termination and Return Codes

For the project 12 subjects I will be comparing Java, C++ and Python. All being object oriented languages they share many things in common, but differ on several points as well.

All three of these languages provide exception statements (as discussed earlier). If the program runs into an error that is not handled by an exception, it will terminate. It is good to review code to make sure you have all possible exceptions handled. This way you prevent abnormal termination, although with larger programs it is difficult to place in an exception for every potential error the program may encounter during normal running.

Java provides a line to terminate the code, System.exit(int). The integer doesn't mean anything except for usage in debugging purposes. Typically, and it is considered good convention, a return of zero in there means you reached the end you hoped for, and a return of some other integer will let you know which exit it actually ended up getting to, one or two for instance (though in theory you could use any number, whichever number you as the programmer feel best represents what you want to convey via the exit).

In C++, it is possible to end a program or function prior to its normal termination by using an extra return 0; statement. This will end the entire program or function at that point, which may not always be what you had in mind so it should be used carefully. You can also use the exit(value) function, similar to Java's System.exit() command, this returns a value to the IDE that can than be used for error trapping.

Python is also has a similar ending command, sys.exit(value). Again used for the same thing as the C++ exit() function and Java System.exit() function. There are also a few other commands which you can use, such as raise SystemExit or just exit() though there are a few different things that they do and generally sys.exit is the preferred method to quit out of a program, since it is more "friendly" to other code. Good usage of this command will help during debugging if the program quits at certain times it normally shouldn't and returns a specific number, telling you why it quit.

The return command is also virtually identical through the three languages. Typically, it is used to end a function and return a particular value, be it a string, integer, double or anything else. It can also be used in C++ and Java by adding what is known as an "extra" return 0 command, which basically causes the same thing to happen as the standard exit commands for those languages. The break command, common to all three languages, can be used to quit out of a loop early instead of a return command, and is useful if the loop ends up going somewhere you didn't intend for it to go originally. It will not stop the external loop if you are using a nested loop, just the loop in which it has been places.

Saturday, October 23, 2010

Project 12 Program Errors

For the project 12 subjects I will be comparing Java, C++ and Python. All being object oriented languages they share many things in common, but differ on several points as well.

All three languages provide for try catch statements. The purpose of these statements is to isolate segments of code that may, while the program is running, cause some severe error that would otherwise disrupt the execution of the program, such as a division by 0. By using the exception statements the programmer can prevent sections of code that may cause an issue from terminating the program. Though the exact syntax for exception throwing in the different languages is different and there each language offers a few different options with try catch type statements the basic concept is the same between all three. Reserved words in the languages may only be used for a single purpose, whatever it happens to have been made to do and can not be used as variable or any other identifier names. Common reserved words are things such as: if, while, else, and, except, break and so on. Attempting to use any of these as identifiers will cause errors in compilation.

Java syntax is derived from C and C++, however unlike C++ it is almost exclusively object-oriented. There are no global functions or variables, all code belongs to classes and all values are objects, with the exception of primitive types. Java is case sensitive with everything so a call to System and another call to system will not point to the same place, and will cause an error during compilation. Often times in Java the compiler will not point to where the actual issue is, and you will need to look around to figure out what in the world it wants. Also: fixing one simple issue such as a missing semicolon may cause dozens of other errors to pop up because the compiler hasn't checked those parts because of that first error.

In both Java and C++ lines of code do not necessarily need to be separated, the computer will still be able to read them fine. Example: 


int main ()
{
  cout << " Hello World!";
  return 0;
}


int main () { cout << "Hello World!"; return 0; }
 
Both of these code segments will run properly. However, in Python lines and indentation are rigidly enforced because Python does not end lines with semicolons, as C++ and Java do, so there is nothing directly in the code that allows the computer to know the end of a line other than the return usage at the end.

if True:
    print "True"
else:
  print "False"

if True:
    print "Answer"
    print "True"
else:
    print "Answer"
  print "False"

The first example would run fine, however the second would not because the second line under else: is not indented properly.

Friday, October 22, 2010

Project 12 Program Test Data

For the project 12 subjects I will be comparing Java, C++ and Python. All being object oriented languages they share many things in common, but differ on several points as well.

Java primarily makes use of primitive and reference data types. Declaration follows the same general format for all of them: <data type> variableName;. You fill in <data type> with any given one of the types, int for integer, char for character, boolean for booleans, String for strings and so on. It also allows for printing of the min and max values of types in the form of: System.out.println(<Type>.(MIN/MAX)_VALUE);. Java makes use of several statements controls to decide what portion of code to execute, such as: if and ifelse statements, try catch statements, and switch statements. if and ifelse statements check the if statements in sequence, if elses are tied to an if statement, and as soon as one of their expressions is found true that code segment is run and the others are skipped over. Try catch statements do a portion of code, as as it goes through it checks for (or catches) some exception that may pop up in that code. Switch statements can be used in place of if statements, and check multiple possibilities with just one call of switch, and than subsequent calls of case for each possibility.

C++ uses more or less the same listing of variable types that Java has, (not surprising as Java was influences by C++, amongst others). C++ also uses the same general format for declaration of variables. C++ also makes use of the if, ifelse and else statements, as well as switch statements, to control the flow of the program. Unlike Java and Python, C++ allows for the usage of goto statements to jump to another spot in the code, though the usage of goto is typically shunned in C++, as well as other high level languages. C++ allows you to check the size of a variable with the sizeof(<variable>) command.

Python differs from Java and C++ in its variable declarations. In Python, you do not need to specify what type of variable it is you're putting in, you just assign it a value and it knows what type of variable you want based off of that (100 would be an int, 1000.0 would be floating point, etc.). Python also contains methods for its list and tuple types which allow the programmer to get out the min and max. This is called simply with min(list) and max(list), the same with tuples only you would put in the name of the tuple instead of the list. Python makes use of if, elif (else if) and else statements to decide which segment of code to run and makes use of many fairly standard operators for true/false checking such as ==, !=, >, and <.

Tuesday, October 19, 2010

Project 11 - Problems Solving Techniques (part 7)

 Translating PDL, specifically for the purposes of this part of project 11, into QBASIC.

PDL or Program Design Language is as high-level a language as you can get, without turning speech directly into computer code. When you code in PDL you code in plain English, and use absolutely no computer code, the idea is to make it as ambiguous as possible so you can easily translate it into any other language. There should be absolutely nothing in the PDL code that would indicate a specific language (for instance, ending each line with a Semi-colon would be indicative of Java or C++ amongst others, but not languages such as QBASIC). For instance, saying Lock the surface to prevent access by other programs (when talking about the drawing surface) could easily be attributed to Directx and Lock(), so it would be better to say Prevent the surface from being accessed by other programs.

Making out your code in PDL first, before putting it in another language gives you several advantages. First off, it's easy for project managers and lead programmers to review and look over to make sure you're on the right track and have the right specifications that the program needs, and this way they won't need to sift through endless lines of code to figure out what's going on with your routines and methods. Having done it first in PDL also means you've already written out the comments for your program, and you can just put them on the particular lines of code that they expressed originally.

QBASIC is a very high-level language, and translates from PDL quite well. Becuase QBASIC uses commands such as: PRINT END INPUT RANDOMIZE it is easy to take a similar PDL form and translate it. For example: in PDL you could say: Output the answer. In QBASIC this would come out to: PRINT "The answer is:", answer$.

Similarities in other parts of life would be like British English into American English (or vice versa). For instance, the British refer to football as meaning Association football, known as soccer to Americans, and Americans would refer to Association Football only as soccer, and than Football is the American football. Another small difference would be the term "to table" something during a meeting. To Americans, this would mean to remove it from discussion and bring it up next time. To British, this would mean to bring it into discussion. Translating a book between the two would also be a fairly easy task, as most of the language is the same, however a few changes would need to be made like if the word naff (unstylish, usually used to mean "not very good") the translator would want to change that so an American reader would not be completely confused coming across that word. The same goes with Australian English, as it is also derived from British English, however has it's own divergences.

Those would all be good examples going from PDL to QBASIC, but you can go farther down the levels than that, for instance taking PDL and making Java. This would be like translating English into French, they share a common base in Latin, and there are many similarities between the two, however a lot more effort of translation would be needed to make it work well, unlike translating different types of English between each other.

Project 11 - Problems Solving Techniques (part 6)

 
Using flow charts and pseudocode to plan for and prepare to program.

Flow charts (see right) are useful to show a linear progression of your program and what it will do. Making a flow chart gives you a visual representation of how your program should run, or flow. Since it is simple, it forces the designer to think in very simple terms how their program will flow. You should follow one path linearly before going back up to follow alternate activity paths.








Pseudocode is compact and informal high-level description of a computer algorithim that uses the structural conventions of a programming language, but is meant for people to read rather than machines. It typically omits things not necessary for human understanding of the algorithm, like variable declarations, system specific code and subroutines. For example:


<variable> = <expression>

IF <condition>
    DO stuff;
ELSE
    DO other stuff; 
 
Since pseudocode is similar to the code it mimics it is fairly easy 
to convert into the wanted program. It is also fairly easy to build 
and maintain, since all you need is a text editor (wordpad or notepad would do). 
 
You could use a flow chart to demonstrate a plan or sequence for just about anything. 
It is well used to demonstrate a decision making process. Like how to choose an item 
over others whilst shopping. In this instance you would start off with a desire for some 
particular product, or a need to be filled. Once you have that you would think of 
nearby stores, and decides which ones may have what it is you're looking for. Than 
go into that store, and based off of some rubric compare and contrast different products 
that may fullfill that need. If, by some chance, the store you chose originally didn't have 
what you were looking for, than you could return a few steps back and to choosing 
another store. Than, you would end it out by saying returning home once a satisfactory 
product has been chosen.
  
The idea of giving very simple vague instructions as in Pseudocode can be used to speak 
with professionals in some field you are not as familiar with, but they are, when you want 
to tell them what kind of thing you want done, thereby allowing them to fill in the specifics 
for themselves when it comes down to actually doing the work. They know the technical 
jargon involved in whatever it is they're doing specifically, all you need to know to tell 
them what you need is a general idea of what you would like them to do. This allows you 
to prevent yourself from looking like a fool trying to use technical terms you may not 
actually know or understand completely.

Project 11 - Problems Solving Techniques (part 5)

Arithmetic expressions, loops, arrays, logical expressions. These are all elementary subjects associated with beginning programming, and will stay with the programmer as long as they code. Arithmetic expressions make use of variables, constants and operators to make calculations. Variables come into play in most every equation a programmer will write and allow for almost infinite possibilities as to what equations you can write. Loops will continue running the same part of code until some condition is met, whether it's a simple counter or waiting for some input from the user to exit the loop. Care must be taken not to accidentally throw your loop into infinity, being off by just one in your count will mess everything up (called an OBO or Off By One error). Arrays are used to contain data, they can come in many dimensions. They can be used like a simple list of objects, (objects being any data type, i.e. integers, strings etc.) this kind of array is known as a one dimensional array, a grid of objects, known as a two dimensional array, and so on. Most languages can support arrays above 3 dimensions, which can be very confusing to work with. Logical expressions are true/false statements. These are primarily used for decision making, and come in to play mostly in IF statements, and loops. All of these functions need to be understood in order for higher level programs to be created. Once these concepts are understood, it is relatively simple to make a solution for a problem and translate that into using these concepts to fulfill the problem.

In doing anything you need to understand the basics. Understand at the very bottom what is required of you and move from there. Take driving a stick shift car as an example. You need to know 3 pedals, the clutch, the brake and the accelerator. You also need to know the turn signal, and the shifter. You need to know which positions on the shifter put you in what gear. You need to understand at how many RPMs you make a shift up or down. You need to know how to recover from a stall, in case that happens. You also need to know how all of these things interact with each other. So, the accelerator increases your speed and RPM, when you hit around 3 thousand RPM you let go of the accelerator and push in the clutch, move the shifter appropriately so you shift one gear up, and slowly release the clutch. This will reduce your RPMs somewhat, and allow for a greater speed. When you down shift you need to brake a down and as your RPMs drop repeat the same process, only shifting down instead of up, so after each shift your RPMs will go up instead of down. In order to properly drive a stick-shift car, you need to understand how all of this occurs so you won't stall your car or blow out your engine from pushing its RPMs up too much. Every little thing interacts with each other, and when you understand it all, to some degree, you can drive safely and with confidence.

Project 11 - Problems Solving Techniques (part 4)

http://jtf.acm.org/images/ProgramHierarchy.gif
The hierarchy method is simply demonstrated by the diagram on the right. Every component is dependent on one above it, with the exception of the highest component. Designing programs in this manner makes them easier to read, modify and extend. This style of planning is very common in engineering of all types, though one good example is the file systems provided by operating systems. File systems have a top-level (or root), and underneath that root are directories (like Program Files or Documents and Settings) and underneath those are more sub-directories. Properly defined levels in a hierarchy structure allow you to work with one level without necessarily knowing about any other level. Each level is a defined abstraction of some idea, concept or classification. With the abstraction and hierarchy a programmer doesn't need to know what any command does or what it is documented to do, just that it does it. This allows the programmer to build more and more complicated structures, one on top of the other.

For instance: you can make a program to draw a street, which is built off of a drawHouse class, which is built off of drawFront, drawRoof, drawDoor, and drawWindow classes. The only thing you need to know to modify the program is what the inputs to drawHouse are, you don't really need to know how the other classes underneath it function, as long as you know how to use them.

To use this goal in real life, you need to start out with some kind of ultimate goal. Once you have that, move down and figure out all the parts you would need to accomplish that goal. From here, you build down from whatever your goal is to smaller bits and parts and divide that up between people so they can each work on those parts and the work is a lot easier on each person than it would be making everything yourself.

This would be a good way to plan things well in advance due to it's capability for additions and modularity. Planning a conference well out in advance, for instance, some new things may come up that you want to implement, but the basic idea would remain the same and you could add or remove as needed to achieve making the best possible conference. Say you had a speaker scheduled to speak on a certain topic, and they had to cancel. If you've laid out what you wanted, you can look back at this and take that particular talk out and see what you could replace it with as it pertains to other things. Like, say the talk was about courage, you could replace it with someone talking about integrity (assuming you didn't already have said talk, in which case you would know because you have everything laid out). If you define each part of what you want to do well, you can also split up the planning work between several people so that they can all take a part.

Project 11 - Problems Solving Techniques (part 3)

A common technique when working out a solution to a problem is to use systems and program mapping tools. These are visual representations of the problem and how to solve it. Planning out the program in this manner allows for relationships and functionality between parts of the problem and solution to be shown early on, so the programmer will know how things interrelate, which is crucial to know for larger programs involving several thousands of lines of code. There are a few different ways in which you can map out a problem. One way is to map out how the process or system flows. Using this method, there is a starting point, and from there you follow lines in a step-by-step manner through to the end of the program. A structure chart shows how each component relates. It looks similar to a systems flow chart, however, it really is more of a hierarchical representation of the problem. Program logic models detail out the logic behind the program. This is also a visual schematic, and is used to convey the process of logic inputs, factors, processes and outcomes. These are best used to manipulate the program to see how it will function under different conditions, which is helpful to improve the overall design of a complex program. Mapping out the program beforehand is good to convince someone that you have a good idea for a programmed solution to their problem. It is also well used to get a team working on the same project all on the same page as to how this program should run.

One could use a flow chart for many things outside of programming. Most commonly, it is used as a troubleshooting guide, the starting point is what the problem is and usually follows a methodology of trying one solution, than depending on what result you got, moving on to either one of two continuations. Usually one branch of is: okay it's fixed now, and the other is: try this thing next and see what happens.  This transitioning of solution to solution is good for new people trying to do basic troubleshooting, perhaps in mechanics or getting a computer to work. A good example of another use of a structure chart would be explaining the internal workings of a fairly complex machine, such as a car. Making a structure chart would be a good way to train people in showing them how each part connects and effects the others. This is a good way to troubleshoot, as sometimes the obvious problem is just a symptom of the actual problem, but you could only figure this out if you knew how that other thing may be related, as sometimes it seems to the novice to have absolutely no connection. A detail program logic model would best be used when in uncertain circumstances, such as a game of football. In this, you never perfectly know how the other team is going to play, so you need to have some ability to allow the quarterback to make decisions out on the field during the play. This way, he can compensate for different circumstances, and if the whole team knows the plan than you can all have a good idea of what the quarterback will do and therefore play well as a whole.

    Monday, October 18, 2010

    Project 11 - Problems Solving Techniques (part 2)

    Coupling and cohesion are measures of how much each program modules relies on each one of the other modules. Usually the two are contrasted, that is to say low coupling often correlates with high cohesion and vice versa.

    Coupling is how much one module is dependent on another module. If they have high coupling, that means one module modifies or relies on the internal workings of another module (e.g. accessing local data of another module), so if you were to change the way the second module processes data it would lead to changing the dependent module. Low coupling means they share little data and therefore changes in one module would not affect another module very much.

    Disadvantages of coupling:
    • A change in one module usually causes a ripple effect of changes in other modules
    • Assembly of modules might require more effort due to increased inter-module dependency
    • Particular modules may be difficult to test independently due to their dependence on other modules
    Cohesion is how strongly-related or focused the functionality of a single module is. If the methods that serve the given class tend to have many similarities, than the class is said to have high cohesion. In a highly-cohesive system, code readability and reuse is increased, whilst complexity is kept manageable. High cohesion would mean the parts of a module are grouped because they all contribute to a single well-defined task of the module. Low cohesion would be that they have been grouped arbitrarily, and that the only relationship between the parts is that they have been grouped together.

    Coupling is comparable to playing in a team sport where formation is important, such as American football. Every player needs to be in a certain position for a play to work out, but if you change one player's position, usually many players also change around to match him so you still have a unity in your formation and play. This same thing works with other sports as well, in baseball everyone needs to be in their position to cover all the areas the ball could be hit to and take it back into the center to achieve the out, and everyone has to turn based on who has the ball and where they're throwing it to in order to achieve the common goal of outs so they can take their turn up at bat.

    Cohesion would be like a relay race with different parts, like part one the competitors skateboard, part two they roller blade and part three they bike. Each member of the team is would be specialized for the section they'd be racing in, and have very little action with each other, just clapping hands or something to pass off lead. The only thing they share in common is being grouped together as land vehicle racers, because they all race on land with some mode of transportation. All fairly similar, but slightly different depending on the specific part. Low cohesion would be like a swimmer, a runner and a biker, they share very little in common, but have been semi-arbitrarily grouped together as a "race team".

    Tuesday, October 12, 2010

    Project 11 - Problems Solving Techniques (part 1)

    The top-down design for programming puts emphasis on planning and having a complete understanding of the system before you start to do any coding. It is particularly good for larger projects with many inter-connecting parts so that as you code you run into unexpected difficulties connecting pieces of the project together.

    When using the top-down method the programmers will write a main procedure that names all the major functions it will need. Than the team looks at the requirements for each of those functions and the process is repeated. As the coders get farther down the sub-routines will perform simple actions that can be easily and concisely coded, and once you have all the building blocks made up all the programmers need to do is work their way back up the design.

    The top-down approach:
    • Leads to a modular design
    • Modular design allows the development to be self contained
    • Illustrates clearly how lower level modules integrate
    • Work more easily spread between the programmers
    • Easy to maintain
    Two important things about top-down design:
    1. Stepwise refinement: The process of writing software where you gradually add in error checking and functionality. Often, you take the results to show the end user to see if experimenting with a the prototype changes their mind at all about the overall program specifications.
    2. Process Modules: Additional resources that are loaded into a running process (DLL's basically)
    Top-down design can be used in other aspects of your life. Just take a big idea, and brake it down into smaller parts until you have the base components of what you need. For instance, you want to plan a party, so that's the big thing. What else do you want? Decorations, food, guests could all be considered slightly smaller modules. So what decorations? Confetti? Balloons? From there you would go through all the other things asking the same kind of questions (what kind of food, which guests etc.) and see if anything could go together (matching cake colors with party color themes). Separating things out like this is also good to divide up the tasks, asking different people to go out and handle different things. Sending person A out to handle the cake, person B out to get party decorations, etc. Or, just building a good checklist of things for you to do yourself, making an otherwise large and daunting task seem simple by breaking them down into their simple base components.

    Monday, October 11, 2010

    Project 10 - Control Structures


    A. Four basic control structures and their sub-constructs

    The four basic control structures are:
    1. Conditional (if and else)
      • If statements check a condition
      • If else statements will be checked after the initial If statement
      • Else statements come last and will always be activity IF no other parts returned true.
    2. Iteration (loops)
      • While loop, continue doing an action until condition is false
      • Do-While same as while loop, only it will always perform the process once before checking the condition
      • For loop, same as a while loop, only provides specific locations to contain an initialization statement and increase statment
    3. Jump Statements
      • Break statements will leave a loop even if the condition for its end has not been fulfilled
      • Continue Statements will skip the rest of the loop in the current iteration as if the end block had been reached
      • Goto make an absolute jump to another point in the program
      • Exit terminates the currend program
    4. Selective (switch statement)
      • Check several possible constant values for an expression, similar to if and else if instructions

    B. Sequence 

    Sequence is a very basic control structure. It is simply a list of things to do.
    • Do this thing
    • Than this thing
    • Than this other thing.
    And so on. There is no decision-making, looping, or branching. It is just a series of statements, one after the other. For example:

    This would be an example of a sequence structure.

    double average = 0;
    int first = 8; 
    int second = 5;
    int third = 3;
    int fourth = 7;
    average = (first + second + third + fourth)/4;
    System.println(average);

    All it does is run through the code line by line until it reaches it's end and therefore has performed the function the programmer wanted it to. This is the simplest and least powerful control structure available and is usually used in combination with selection and loop structures.





    C. Selection (Decision, If Then/Else) - Case Statement Available in Some Language

    Selection is exactly what it sounds like, it selects something based on some condition.

    This is an example of the selection structure

    Selection statements come in if/then/else format. For instance:

    bool cake = false;

    if(cake){
       eatCake();}
     else{
       sleep();}

    The selection control structure takes the statement and decides wether it is true or false (Boolean logic comes into play here and if it's numbers you need <, >, or = for comparison) than depending on whether this statement is true or false it takes a certain action. In this case, since cake is always false the program will never run the method eatCake() and will always go to the else statement and run the method sleep().

    D. Loop (looping, iteration) - For Statement Available in Some Language

    Loop statements will continue to perform some function until some parameter is met.

    Example:

    int piecesOfCake = 10;

    while(piecesOfCake > 0){
        eatPiece();
        piecesOfCake--;}

    sleep();

    In this example the paramater is checking if there are any pieces of cake left, if there are it eats a piece then goes to check if there is another one again and so on until there is no longer cake, then it exits the loop and goes to sleep. Some languages also use do-while (execute statement, than check paramater) and for (so long as this condition is true, usually a counter of some sort) loops.

    E. Unconditional Branch (Goto)

    Goto statements are a one-way trip to another section of the code. Most languages use label to identify the place where the Goto statement jumps to, though some languages use line numbers. There has been a lot of criticism about Goto statements as bad programming habit, favoring instead the structured programming paradigm, though it has been argued that sensible programmers could use it to improve speed, size and code clearness. Whichever side one tends to agree with, it seems both can agree that newer programmers should stay away from the Goto statement until they are more familiar with the potential advantages and disadvantages involved.

    Friday, October 8, 2010

    Project 8 - Source Code Verses Executable Code

    Many people have some idea of what source code and executable code are, however, most only know the laymen terms for it. The differences between these types are not particularly well defined.

    In laymen's terms, source code is what is written by the programmer, which is human-readable, cannot immediately be executed by the machine, and usually has meaningful variable names and comments intended only for humans. Executable code, (or object code) is not human readable, must be compiled by a compiler, and is a sequence of bytes that give specific instruction to the computer.

    When you delve deeper, however, you find that executable code is readable by humans, it's just more difficult than high level languages such as Java or C, and that to be executed a program doesn't necessarily need to be compiled. An interpreter can be used  instead to communicate to the machine the source code as it is.

    When two people who speak different languages want to talk to each other, they need a third person, called an interpreter to speak in between them who knows both languages. Let's say persons A and B speak languages T and U respectively only, and person C speaks both T and U. As person A gives instructions to person B, person C relays them as they are spoken. This is like what an interpreter for computers does. In this example person A would be the programmer, person B would be the machine, person C would be the code interpreter, language T would be the source code and language U would be the executable code. A compiler on the other hand, would be more like person A writes a letter to person B in language T and gives it to person C. Person C than, takes that letter (source) and translates it into language U and makes sure everything is correct before than handing the now translated (compiled) letter to person B. Person B than follows the instructions (executes) laid out in the letter.

    In this example, person A is the programmer, person B is the computer and person C is the compiler or interpreter. So what does assembly language have to do with anything? Well assembly language is as close as you can get to binary language without actually using binary. It's very short commands (usually 3-5 letters long each) which directly translate into the machine language. Because of this it's very specific to each machine, like different dialects between tribes. While the languages are very similar, it must be spoken slightly differently depending on whom (which processor architecture) you're speaking to. Assembly language reduces the translation needed for the programmer to talk to the computer. So, person A would be able to say his bit, and person C would be able to take it to person B with little changes, sayings that exist in language T would translate effectively over to language U (If I said "he's pulling you across the table" you would look at me weird, but if I told a German-speaker this it would come across the same as "he's got you wrapped around his little finger" would to you).

    Saturday, October 2, 2010

    Project 9 - Data structures and Data Representation

    List of definitions as asked for in project 9. Sources will be numbered and placed at bottom.

    Global Variable - A variable that can be changed anywhere in the program. (1, 2, 3)

    Local Variable -A variable that is only available within some smaller scope or function (1, 2, 3)

    Elementary Data Types
    • Character - Any given symbol or letter, (a % Q ; could all be characters) (1, 3, 4)
    • String - A set of characters, usually a word but not necessarily, (America, $!@sadc, QWERTY could all be considered strings) (1, 3, 4)
    • Integer - Any whole number, so no fractions or decimals (1 16 72 would be integers, 1/2 5.7 .66 would not) (1, 4, 5)
    • Floating - Similar to an integer, only it may contain parts (such as 1/2, 5.7, or .66) (1, 4, 5)
    • Boolean - A true or false variable, often used with operands such as AND, OR, OF THEN, EXCEPT, and NOT (1, 4, 5)
    Data Identifier (name) - The classification of an element (1, 6, 7)

    Its Data Type -Classification of a particular type of information, such as int char or string (1, 7, 8)

    Its Memory Address -Place on the hard-disk that is referenced for where the data resides. (1, 9, 10)

    A Variable -Some symbol or name that stands for some value and is subject to change. (1, 8, 10)

    Literal -A value that has been written exactly as it is meant to be interpreted, and is not subject to change (1, 10, 4)

    Constant -A name or value that cannot be changed (1, 10, 4)

    Number Base Systems

    BASE 2 - Number Base System using 2 integers, 1 and 0m this is the language computers use, it's an on/off system (1, 4, 11)

    BASE 10 -Number Base System using 10 integers, 0-9 this is the one most people are familiar with (1, 4, 11)

    BASE 16 -Number Base System using 16 integers, 0-9 and A-F, used for memory location identifiers (1, 4, 11)

    Floating Point - The system used for representing numbers too large or small to be represented by integers, the number that can be represented is: Significant Digits * Base^exponent  (1, 12, 13)

    Decimal Data Representation -Data representation is the manner in which data (ints, strings, chars, etc.) are stored on the computer. (1, 18, 19)

    Relative Addressing- An addressing scheme which allows for a domain to be taken from one server and placed to another without changing the links, as the links are relative to your current position in the domain (10, 16, 17)

    Data Types and Data Abstraction
    • File - Block of arbitrary information (1, 4, 10)
    • Record - A group of fields of a single field treated as a unit. (1, 4, 10)
    • Array - A grouping or series of objects, usually in rows and columns. (1, 4, 10)
                1. Single Dimension - Just going in one direction (1 row and 1 column)
                                               Ex: [1, 0, 5, 10, 6, 6, 1, 10]
                2. Multi Dimension - Multiple rows and columns 
                                               Ex: [1, 5, 6, 7, 5
                                                      2, 7, 1, 0, 8]
      Language Statements 

      (all 1, 10, 20 for this section)

      A. Natural Language Statements/Grammar and Logic - The idea of making programming statements that uses the grammar of the human language.

      B. Artificial Language Statements/Syntax and Semantics - An artificial language designed to express the accounts that can be carried out by the device. Can be used for to create programs that control the behavior of the device, to express algorithms precisely, or a form of human contact

      C. Input/Output Statements - Part of the program that tells the computer how to take and use information from input devices or send that information out of an output device.

      D. Assignment Statements - Statement that sets a variable to a value

      E. Program Design Language (PDL) - Meta Language - Methodology of designing and documenting methods and procedures in programming. Written in plain language without any conditions that would indicate use of a language or library.

               1.Syntax Diagrams - Schemes such as flow charts for organizing the flow of programs.

               2.BNF - Formal way to describe the mathematical language devloped to describe the syntax of programming language.

      F. Elementary Language Statements and Structured Language Statement

               1.Assignment and Unconditional Statements - Assignment statements assign a value to something, unconditional statements allow you to direct the program to another part without an assessment of conditions.

               2.Selection and Looping Statement - Selection statements are used to determine what and when code should be executed, looping statements are used to run the same part of code a certain number of times.
       
      Expressions Components

      A.Operators, Operands and Results
      1. Unary- An operation with only one operand, (+, -. *, / etc.) (1, 4, 14)
      2. Binary- Having 2 operands (1, 4, 14)
      B. Simple Types
      1. Arithmetic -A mathematical equation (1, 4, 10)
      2. Logical - Equations regarding boolean (true/false) logic (1, 4, 10)
      3. Relational - An expression comparing 2 objects, usually returns a true/false value (such as x > y) (1, 10, 15)
      C. Result
      1. Unconditional (Not Boolean) - A result not pertaining to true/false logic (i.e. an integer or string) (1, 5, 10)
      2. Conditional (Boolean) - A result pertaining to true/false logic (1, 5, 10)
        1. True -Statement is correct
        2. False -Statement is not correct
      Sources:
      1. Wikipedia
      2. Web Developers Notes
      3. Linux-France.org
      4. Dictionary.com
      5. wordnetweb.princeton.edu
      6. europa.edu
      7. OCED glossary
      8. SQA Tester
      9. PC Computer Notes
      10. Wedopedia
      11. Tejat.net
      12. Princeton.edu 
      13. sun.com
      14. SGI
      15. Macs.hw.ac.uk 
      16. rxs-enterprises.org 
      17. wustl.edu
      18. osdata.com
      19. answers.com
      20. computerhope.com