Search This Blog

Friday, 16 March 2018

Post 6 Sequence,selection and iteration

Sequence
Sequencing is when the computer will run the code it receives, one line at a time from the top to the bottom of the requested program. It will start at line 1 then execute line 2 then line 3 and so on unit it reaches the last line of the program it's processing.
An example of Sequencing...
When you first load up a game, you are using sequencing because the program is having to run the all the way through to ensure the program loads correctly.

Selection
 This is used when you may only want to run some lines of code sometimes when a condition is met as so the computer will have to ignore the other lines of code and 'jump' over them. This action can be achieved by using IF statements e.g. if a condition is met then lines 4,5 and 6 are executed otherwise the computer jumps to line 7 without even looking at line 4,5 and 6.
An example of Selection...
When a character for example gets to a certain part of a game for example Selection  may be used to launch what is called a 'cut scene' to be played only when the player reaches that point in the game however. Another example is when a character reaches a stated amount of EXP that character will have the option to level up, this level up feature will only be called on when the player reaches that required amount of EXP (Condition met---> Action)

Iteration
 Iteration is used when sometimes your wanting to execute the same line of code whether it be 2 times in a row to 1000's upon 1000's of times in a row. This is done by using a loop. These loops have three different types: For loops , while loop sand repeat while loops. This is handy as it enables you to not have to copy the same lines of code many times.
An example of Iteration...
Using an example of a game again, when a character is in sort of combat, a while loop will be continuously running to check whether the characters enemy is out of health or has reached a certain amount of health remaining. While loop are extremely efficient at preforming these soft of actions.

Friday, 2 February 2018

Post 5 Programming Standards

To begin with, what is a standard exactly? A standard is a guideline of sorts, as it's basically an agreed way of doing something such as making a product, forming code, delivering something or simply supplying the materials. Standards are a huge part of how organisations, that require a lot of co-operation between the work force, function efficiently.

 Standards in Programming

White Space: White space is the open space between the boundary of your program and where your code starts. White space doesn't really matter to the computer at all it doesn't register the space , only the start and end of your code. White space is used by a lot of programmers to make the code look more presentable and easier to read, however there are those that don't use it and while it doesn't effect their personal code, when working for an employer it can be less desirable to them.

 Naming Conventions: This is basically how different pieces of the code like: variables, functions or characters are named and identified. Naming conventions tend to differ depending on a couple of different conditions. One of these conditions is whether you are working independently or whether your working in a team of some kind.
If your working independently then it's understandable that you would be able to remember and figure out the different names of your variables or functions for example if you was to put a line of code that included a variable like:                         ' if (emailAddress == true);'
You should know where the variable can be declared again. For example whether they are a 'Global' or 'Local' variable or even the type of variable they're (Data type) such as 'char' or 'float'

If however you happen to be working in a team, declaring a set of standard to how you will structure these names will help you reduce the work time as well as the amount of errors. For example of the way in which you all might agree to create name standards is:
'if( g_stremailAddress == true);'
As you can see from the example is differs from the first, in this example 'g_s' has been added onto the variable name. The 'g_' represents the fact that this type of variable is Global and can be declared at any point in the program. the 'str' represents the fact that this variable is a string meaning that it will hold both numbers and characters. Doing something as simple as this will allow the rest of your team to identify these variables quicker and use them for themselves in there own work.

Hungarian notation: These are the base standards for how you should attach a prefix to a variable, function, etc. While most companies have there on twist or flavour of the Hungarian notation if you will they all stem from these base prefixes. An example is for how to state that the variable is a C++ string this being 'str'.

Position of brackets: The position of brackets again is not something that necessarily makes much of a difference as long as they're included and apparent. Most programmers have their own options on how to separate and set the brackets in code, sometimes these ways stem from habits of previous different programming languages that these programmers have used or maybe it's just a personal preference that includes how these brackets should look. It's important again, when your working in a team, that you either come up with an agreeable standard for how your team will set these out or either just simply stating it to them or making a comment at the start of the code.

Comments: Comments can be left in your own code to either help you figure out where certain parts are of simply split them up into separate segments. Comments can also be used to reduce the risk of members of your team if there are any getting lost in your code or not being able to find a certain part of in. Leaving comments is a very useful feature that will save you a lot of time if used properly.

Positional notation:





Composite Word Scheme:



Wednesday, 10 January 2018

Post 4 Varied Data Types

String
Strings are just lines of text and are most most commonly used to produce: Names, words and labels. Strings take up around 20 bytes of data however this is just the constant while it's usually 20 byte + 2 times the length of the string.
An example of a String: "This is a String"
An advantage of using a string is that it can hold much more characters than the data type "char" however because of this it takes up much more memory than "char" too.
Char
The Char data type is a single one-byte (16-bit) character. The data types stores this one character for future use for the program.Char stores a character from the Unicode character set which includes the variety of symbols ,accents , mathematical and technical symbols as well.
An example(s) of a Char data type: "A" , "a" , "+" , "?"
Boolean
Bools or Boolean data types are just a simple choice of whether something is true or false. They are not very large and take up only 1 bit of data. Boolean data types, as stated before, are simply the choice of whether something is true or false as such the type can only be one of two different values.
An example of a Boolean:  "True" or "False"
There is not much in the way of specific advantages for a Boolean data type apart from that if you were to use it it would help with the optimisation of your program in the way of memory and sometimes speed, however due to Boolean data types only involving either "1 or 0" or "True or False" there is a limited amount that you can do with them.
Integer
Integers are whole numbers that are either positive, negative or zero. Unlike the other data type "Real" also know as "Floating point numbers" integers cannot have decimal places and are one of the most commonly used data types in computer programming.
An example of a Integer: "5" or "-5"
The size of an integer tends to vary between either 2-4 bytes
An Integer has benefits to a point. A small integer up to a 64-bit can be very efficient represent in the underlying hardware and memory meaning that using them will be fairly quick however they have a limitation as for a lot of calculations you need to use real numbers and as such integers are not appropriate for these calculations.
Real
The "Real" data type is used to present an approximation of a real number. Because  these "Real Numbers" are not countable a computer cannot represent them using a limited amount of information. Real numbers are used in the computers computers calculations as well as integer calculations, the calculations that are preformed using the real numbers takes part in a separate section of the CPU known as the FPU or floating point unit.
An example of a Real number: "3.142..."
The size of 4 bytes for a simple float however if your wishing to create a double or long double version of the number it will got to 8 bytes then to 10 bytes.
Real numbers have a couple of advantages the first being that they can represent the values between integers and secondly is that they can represent a much greater range of values. However Real numbers do have their drawbacks as they can be slower than integer operations and may also lose precision.



Wednesday, 13 December 2017

Post 3 Local/Global Variables and Logical Operators

Local/Global Variables

Global Variables are declared outside any function and they can be accessed (used) on any function in the program. Global variables then to very Unreliable and are used for quicker running code more than for reliable and stable code.
Local Variables however are declared inside a function and can be used only inside that function it's placed in.

float a = 1; --> The Global variable is declared outside the function "void my_test()"

void my_test() {

  float b = 77; --> This is the local variable and it is declared inside the known function
  println(a);

  println(b);


void setup() {

  float b = 2; --> This Local variable will not be able to be accessed by any other feature  and you will notice that Local variables names can be re-used as long as they're in different functions 

  println(a);
  println(b);
  my_test();
  println(b);

Post 2 Variables and Naming Conventions

Variables

Variables in programming are things that are assigned values and used in the following code after it. Variables are commonly referred back to when a certain value needs to be taken and used to work something else out further on.

Below is a part of an email checker that I created previously






In this code the two variables known as "foundAT" and "foundDot" are assigned values and as you can see, are later brought back up to work out whether the email entered is valid or invalid and depending on what changes with these two values final outcomes will be produced to state the final answer

Naming Conventions

In computer programming a naming convention is a set of rules for choosing the character sequence to be used for identifiers which denote variables , types functions and other entities in source code and documentation.



Friday, 1 December 2017

Post 1 Selection statements

Selection statements work when a required outcome is desired to produce a specific output if this outcome is not delivered to the selection statement something else will happen that the selection statement would've been told to do.

An Example...



Something else to talk about is "Case Select" statements.
Case select statements is another way for a programmer to test whats inside of a variable but is mainly used when you know that there is only a select amount of things that can be in the variable.

An Example...

                    CASE COMMAND$ OF
            WHEN "Move west","Move left", "Go to the door on the left","Go to the door to the west": THEN ROOM = 2
            WHEN "Move east","Move right","Go to the door on the right","Go to the door to the east": THEN ROOM = 3
            WHEN "Move north","Move up","Go to the door to the top of the room","Go to the door to the north": THEN ROOM = 4
            WHEN "Move south","Move down","Go to the door to the bottom end of the room","Go to the door to the south of the room": THEN ROOM = 5


Monday, 13 November 2017

Week 10

At this point my work has been completed to the best of my ability I do have a few changes to make however those changes are not difficult to complete. As I said last week I had given up looking for jobs in the computing industry and focused on the everything for just the base work experience of being part of a company, i now have a couple of interviews for different places , so i'll see how it goes however i don't know if i'll take them due to having this time to just hold out for the jobs in the computing industry, i can't shake the feeling that if i keep pressing something will turn up eventually. I still haven't started to study again and i keep kicking my self about it but i need to do something to get myself to focus as i just can't after being at college for the entire day , something will have to change eventually.

Post 6 Sequence,selection and iteration

Sequence Sequencing is when the computer will run the code it receives, one line at a time from the top to the bottom of the requested prog...