Saturday, February 20, 2016

how to write programming pseudocode






Pseudo code is a step-by-step verbal outline of your code that you can gradually transcribe into programming language. Many programmers use it to plan out the function of an algorithm before setting themselves to the more technical task of coding. Pseudo code serves as an informal guide, a tool for thinking through program
In general the vocabulary used in the pseudo code should be the vocabulary of the problem domain, not of the implementation domain.  The pseudo code is a narrative for someone who knows the requirements (problem domain) and is trying to learn how the solution is organized. 
NB:- logic must be decomposed to the level of a single loop or decision.Pseudocode is not a rigorous notation, since it is read by other people, not by the computer. There is no universal "standard" for the industry, but for instructional purposes it is helpful if we all follow a similar style. The format below is recommended for expressing your solutions in our class.
The "structured" part of pseudocode is a notation for representing six specific structured programming constructs: SEQUENCE, WHILE, IF-THEN-ELSE, REPEAT-UNTIL, FOR, and CASE. Each of these constructs can be embedded inside any other construct. These construct represent the logic, or flow of control in an algorithm.
It has been proven that three basic constructs for flow of control are sufficient to implement any "proper" algorithm.
SEQUENCE is a linear progression where one task is performed sequentially after another.
It has been proven that three basic constructs for flow of control are sufficient to implement any "proper" algorithm.
SEQUENCE is a linear progression where one task is performed sequentially after another.
WHILE is a loop (repetition) with a simple conditional test at its beginning.
IF-THEN-ELSE is a decision (selection) in which a choice is made between two alternative courses of action.Although these constructs are sufficient, it is often useful to include three more constructs:
 
CASE is a multiway branch (decision) based on the value of an expression. CASE is a generalization of IF-THEN-ELSE.
FOR is a "counting" loop.
SEQUENCE
Sequential control is indicated by writing one action after another, each action on a line by itself, and all actions aligned with the same indent. The actions are performed in the sequence (top to bottom) that they are written.

IF-THEN-ELSE
Binary choice on a given Boolean condition is indicated by the use of four keywords: IF, THEN, ELSE, and ENDIF. The general form is:
IF condition THEN
sequence 1
ELSE
sequence 2
ENDIF
The ELSE keyword and "sequence 2" are optional. If the condition is true, sequence 1 is performed, otherwise sequence 2 is performed.
Example
IF HoursWorked > NormalMax THEN
Display overtime message
ELSE
Display regular time message
ENDIF
WHILE
The WHILE construct is used to specify a loop with a test at the top. The beginning and ending of the loop are indicated by two keywords WHILE and ENDWHILE. The general form is:
WHILE condition
Sequence
ENDWHILE
The loop is entered only if the condition is true. The "sequence" is performed for each iteration. At the conclusion of each iteration, the condition is evaluated and the loop continues as long as the condition is true.
Example
WHILE Population < Limit
Compute Population as Population + Births - Deaths
ENDWHILE
Example
WHILE employee. type NOT EQUAL manager AND personCount < numEmployees
INCREMENT personCount
CALL employeeList.getPerson with personCount RETURNING employee
ENDWHILE
CASE
A CASE construct indicates a multiway branch based on conditions that are mutually exclusive. Four keywords, CASE, OF, OTHERS, and ENDCASE, and conditions are used to indicate the various alternatives. The general form is:
CASE expression OF
condition 1 : sequence 1
condition 2 : sequence 2
...
condition n : sequence n
OTHERS:
default sequence
ENDCASE
The OTHERS clause with its default sequence is optional. Conditions are normally numbers or characters
Indicating the value of "expression", but they can be English statements or some other notation that specifies the condition under which the given sequence is to be performed. A certain sequence may be associated with more than one condition.
Example 
FOR X = 1 to 10
    FOR Y = 1 to 10
        IF game Board[X][Y] = 0
            Do nothing
        ELSE
            CALL the Call(X, Y) (recursive method)
            increment counter                 
        END IF
    END FOR
END FO


Pseudo code is a step-by-step verbal outline of your code that you can gradually transcribe into programming language. Many programmers use it to plan out the function of an algorithm before setting themselves to the more technical task of coding. Pseudo code serves as an informal guide, a tool for thinking through program
In general the vocabulary used in the pseudo code should be the vocabulary of the problem domain, not of the implementation domain.  The pseudo code is a narrative for someone who knows the requirements (problem domain) and is trying to learn how the solution is organized. 
NB:- logic must be decomposed to the level of a single loop or decision.Pseudocode is not a rigorous notation, since it is read by other people, not by the computer. There is no universal "standard" for the industry, but for instructional purposes it is helpful if we all follow a similar style. The format below is recommended for expressing your solutions in our class.
The "structured" part of pseudocode is a notation for representing six specific structured programming constructs: SEQUENCE, WHILE, IF-THEN-ELSE, REPEAT-UNTIL, FOR, and CASE. Each of these constructs can be embedded inside any other construct. These construct represent the logic, or flow of control in an algorithm.
It has been proven that three basic constructs for flow of control are sufficient to implement any "proper" algorithm.
SEQUENCE is a linear progression where one task is performed sequentially after another.
It has been proven that three basic constructs for flow of control are sufficient to implement any "proper" algorithm.
SEQUENCE is a linear progression where one task is performed sequentially after another.
WHILE is a loop (repetition) with a simple conditional test at its beginning.
IF-THEN-ELSE is a decision (selection) in which a choice is made between two alternative courses of action.Although these constructs are sufficient, it is often useful to include three more constructs:
 
CASE is a multiway branch (decision) based on the value of an expression. CASE is a generalization of IF-THEN-ELSE.
FOR is a "counting" loop.
SEQUENCE
Sequential control is indicated by writing one action after another, each action on a line by itself, and all actions aligned with the same indent. The actions are performed in the sequence (top to bottom) that they are written.

IF-THEN-ELSE
Binary choice on a given Boolean condition is indicated by the use of four keywords: IF, THEN, ELSE, and ENDIF. The general form is:
IF condition THEN
sequence 1
ELSE
sequence 2
ENDIF
The ELSE keyword and "sequence 2" are optional. If the condition is true, sequence 1 is performed, otherwise sequence 2 is performed.
Example
IF HoursWorked > NormalMax THEN
Display overtime message
ELSE
Display regular time message
ENDIF
WHILE
The WHILE construct is used to specify a loop with a test at the top. The beginning and ending of the loop are indicated by two keywords WHILE and ENDWHILE. The general form is:
WHILE condition
Sequence
ENDWHILE
The loop is entered only if the condition is true. The "sequence" is performed for each iteration. At the conclusion of each iteration, the condition is evaluated and the loop continues as long as the condition is true.
Example
WHILE Population < Limit
Compute Population as Population + Births - Deaths
ENDWHILE
Example
WHILE employee. type NOT EQUAL manager AND personCount < numEmployees
INCREMENT personCount
CALL employeeList.getPerson with personCount RETURNING employee
ENDWHILE
CASE
A CASE construct indicates a multiway branch based on conditions that are mutually exclusive. Four keywords, CASE, OF, OTHERS, and ENDCASE, and conditions are used to indicate the various alternatives. The general form is:
CASE expression OF
condition 1 : sequence 1
condition 2 : sequence 2
...
condition n : sequence n
OTHERS:
default sequence
ENDCASE
The OTHERS clause with its default sequence is optional. Conditions are normally numbers or characters
Indicating the value of "expression", but they can be English statements or some other notation that specifies the condition under which the given sequence is to be performed. A certain sequence may be associated with more than one condition.
Example 
FOR X = 1 to 10
    FOR Y = 1 to 10
        IF game Board[X][Y] = 0
            Do nothing
        ELSE
            CALL the Call(X, Y) (recursive method)
            increment counter                 
        END IF
    END FOR
END FOR
Unity3D Content of the document......


1. Downloading and Installing Unity
You can download and install the Unity Editor from the Unity Website:-unity3d.com/download.
Unity Download
To download unity 3D one has to visit the site and with that you will get different versions of the unity and with that i prefer you choose the latest version to be able to have enough options for your gaming. Like below we can use version 5.3
Unity Download Assistant - Leave the default selections if youre not sure which to choose
>Access the location where you have installed the unity3D.Then install it in the specific location in the drive one uses, with this let it install.Downloading Unity via a Torrent>After the installation one will have the following windows to start with
>After that one has to choose the assets needed to be used in the given project and with that he has to know what are the requirements he needs to include in the game.
>After this one is ready to start creating games and shown below in the editor
Introduction to unity3D
Unity 3d is the best platform for gaming world, it has more options to include in the scenes, one can import, design, make different changes to the game. After you have opened the editor,you need to follow the given steps:-
a).Open unity3d software->open new project->name the project and save it .
b). import characters to the scene
Go to file hierarchy at the top of unity editor->Assets-> then choose import assect/character from here one can import the animated character from the stored asset of import the assets from the stored location to unity.


 
2.How to Write Pseudo code           
Pseudo code is a step-by-step verbal outline of your code that you can gradually transcribe into programming language. Many programmers use it to plan out the function of an algorithm before setting themselves to the more technical task of coding. Pseudo code serves as an informal guide, a tool for thinking through program
In general the vocabulary used in the pseudo code should be the vocabulary of the problem domain, not of the implementation domain.  The pseudo code is a narrative for someone who knows the requirements (problem domain) and is trying to learn how the solution is organized. 
NB:- logic must be decomposed to the level of a single loop or decision.Pseudocode is not a rigorous notation, since it is read by other people, not by the computer. There is no universal "standard" for the industry, but for instructional purposes it is helpful if we all follow a similar style. The format below is recommended for expressing your solutions in our class.
The "structured" part of pseudocode is a notation for representing six specific structured programming constructs: SEQUENCE, WHILE, IF-THEN-ELSE, REPEAT-UNTIL, FOR, and CASE. Each of these constructs can be embedded inside any other construct. These construct represent the logic, or flow of control in an algorithm.
It has been proven that three basic constructs for flow of control are sufficient to implement any "proper" algorithm.
SEQUENCE is a linear progression where one task is performed sequentially after another.
It has been proven that three basic constructs for flow of control are sufficient to implement any "proper" algorithm.
SEQUENCE is a linear progression where one task is performed sequentially after another.
WHILE is a loop (repetition) with a simple conditional test at its beginning.
IF-THEN-ELSE is a decision (selection) in which a choice is made between two alternative courses of action.Although these constructs are sufficient, it is often useful to include three more constructs:
 
CASE is a multiway branch (decision) based on the value of an expression. CASE is a generalization of IF-THEN-ELSE.
FOR is a "counting" loop.
SEQUENCE
Sequential control is indicated by writing one action after another, each action on a line by itself, and all actions aligned with the same indent. The actions are performed in the sequence (top to bottom) that they are written.

IF-THEN-ELSE
Binary choice on a given Boolean condition is indicated by the use of four keywords: IF, THEN, ELSE, and ENDIF. The general form is:
IF condition THEN
sequence 1
ELSE
sequence 2
ENDIF
The ELSE keyword and "sequence 2" are optional. If the condition is true, sequence 1 is performed, otherwise sequence 2 is performed.
Example
IF HoursWorked > NormalMax THEN
Display overtime message
ELSE
Display regular time message
ENDIF
WHILE
The WHILE construct is used to specify a loop with a test at the top. The beginning and ending of the loop are indicated by two keywords WHILE and ENDWHILE. The general form is:
WHILE condition
Sequence
ENDWHILE
The loop is entered only if the condition is true. The "sequence" is performed for each iteration. At the conclusion of each iteration, the condition is evaluated and the loop continues as long as the condition is true.
Example
WHILE Population < Limit
Compute Population as Population + Births - Deaths
ENDWHILE
Example
WHILE employee. type NOT EQUAL manager AND personCount < numEmployees
INCREMENT personCount
CALL employeeList.getPerson with personCount RETURNING employee
ENDWHILE
CASE
A CASE construct indicates a multiway branch based on conditions that are mutually exclusive. Four keywords, CASE, OF, OTHERS, and ENDCASE, and conditions are used to indicate the various alternatives. The general form is:
CASE expression OF
condition 1 : sequence 1
condition 2 : sequence 2
...
condition n : sequence n
OTHERS:
default sequence
ENDCASE
The OTHERS clause with its default sequence is optional. Conditions are normally numbers or characters
Indicating the value of "expression", but they can be English statements or some other notation that specifies the condition under which the given sequence is to be performed. A certain sequence may be associated with more than one condition.
Example 
FOR X = 1 to 10
    FOR Y = 1 to 10
        IF game Board[X][Y] = 0
            Do nothing
        ELSE
            CALL the Call(X, Y) (recursive method)
            increment counter                 
        END IF
    END FOR
END FOR

3.How to debug php
Introduction:-
>PHP (recursive acronym for "PHP: Hypertext Pre-processor") is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML
>PHP was developed to specifically address needs of the web to provide dynamic content on web It is a "markup" language (unlike a typical programming language), in that its commands (tags) are designed to assist in the formatting and layout of textual data
>It by definition is a "static" language, in that the content displayed using the standard HTML language will always look the same -- it will not change over time or by who accessed it.First, you should turn display errors on. This can be done either in your php.ini file or at the head of your code like:-
 <? php
ini_set('display_errors', 'On');
> 

1. Syntax Errors

Syntax errors are caused by a type in your code. For example a missing semicolon, quotation mark, brace or parentheses. When you encounter a syntax error you will receive an error similar to this, it is common that it is a type on the line above causing the error. Here’s an example:
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);

2. Warnings

Warnings aren’t deal breakers like syntax errors. PHP can cope with a warning; however, it knows that you probably made a mistake somewhere and is notifying you about it. Warnings often appear for the following reasons:
  1. Headers already sent. Try checking for white space at the head of your code or in files you’re including.
  2. You’re passing an incorrect number of parameters to a function.
  3. Incorrect path names when including files.

3. Notices

Notices aren’t going to halt the execution of your code either, but they can be very important in tracking down a pesky bug. Often you’ll find that code that’s working perfectly happily in a production environment starts throwing out notices when you set error reporting to E_ALL.This information can be extremely useful in debugging your application. Say you’ve done a simple database query and pulled a row of user data from a table.

4. Fatal Errors

Fatal errors What it means,  is that PHP understands what you’ve asked it to do but can’t carry out the request. Your syntax is correct, you’re speaking its language but PHP doesn’t have what it needs to comply. The most common fatal error is an undefined class or function and the error generated normally points straight to the root of the problem:
Fatal error: Call to undefined function create() in /Document/Root/example.php on line 23

Using var_dump() to Aid Your Debugging

var_dump() is a native PHP function which displays structured, humanly readable, information about one (or more) expressions. This is particularly useful when dealing with arrays and objects as var_dump() displays their structure recursively giving you the best possible picture of what’s going on. Here’s an example of how to use var_dump() in context:
Below I have created an array of scores achieved by users but one value in my array is subtly distinct from the others, var_dump() can help us discover that distinction.
The output from var_dump() will look like this:
array(4) { ["Ben"]=> int(7) ["Linda"]=> int(4) ["Tony"]=> int(5) ["Alice"]=> string(1) "9" }
While this is a very basic example of how var_dump() functions it can similarly be used to inspect large multi-dimensional arrays or objects. It is particularly useful in discovering if you have the correct data returned from a database query or when exploring a JSON response from say, Twitter:

Tools to Consider when Debugging

1. Xdebug

Xdebug is one of the most popular debugging PHP extensions. It provides a ton of useful data to help you quickly find bugs in your source code.
Xdebug is a PHP extension that aims to lend a helping hand in the process of debugging your applications. Xdebug offers features like:
  • Automatic stack trace upon error
  • Function call logging
  • Display features such as enhanced var_dump() output and code coverage information.
Xdebug is highly configurable, and adaptable to a variety of situations. For example, stack traces (which are extremely useful for monitoring what your application is doing and when) can be configured to four different levels of detail. This means that you can adjust the sensitivity of Xdebug’s output helping you to get granular information about your app’s activity.

2.Debugging using print statements

Use of debugging print statemenents lets you show the errors in scripts to display all variables submitted.eg
<?php
 $j = "";
 print("Lets retrieve all the variables submitted to this ");
 print("script via a GET request:<br>");
 foreach($_GET as $key => $i){
     print("$key=$j<br>");
 }
 if($_GET['Submit'] == "Send GET Request")
     $j = "done!<br>";
?>
<form method="GET">
     Name: <input name="name"><br>
     Email: <input name="email" size="25"><br>
     <input name="Submit" type="submit" value="Send GET Request">
</form>
You may be able to spot the bug in Listing 2 very easily. Stack traces show you where errors occur, allow you to trace function calls and detail the originating line numbers of these events. All of which is fantastic information for debugging your code

3. FirePHP               

 FirePHP is a really useful little PHP library and Firefox add-on that can really help.
FirePHP enables you to log debug information to the Firebug console.