dig1108c lesson3 fall 2014
DESCRIPTION
Valencia College DIG1108C Lesson3 Fall 2014TRANSCRIPT
![Page 1: DIG1108C Lesson3 Fall 2014](https://reader036.vdocument.in/reader036/viewer/2022082804/547b9c6ab47959a9098b4d9b/html5/thumbnails/1.jpg)
Intro To Server Side Programming
Lesson Three
![Page 2: DIG1108C Lesson3 Fall 2014](https://reader036.vdocument.in/reader036/viewer/2022082804/547b9c6ab47959a9098b4d9b/html5/thumbnails/2.jpg)
Recap - What Have We Found?
• Literals
• boolean - True/False
• integer
• float - decimal numbers
• string - text
• array - ordered key/value pairs
• object - literal within class
• Null - no value
![Page 3: DIG1108C Lesson3 Fall 2014](https://reader036.vdocument.in/reader036/viewer/2022082804/547b9c6ab47959a9098b4d9b/html5/thumbnails/3.jpg)
Recap Continued
• Operators
• Arithmetic - $newvalue = $oldvalue + 1;
• Assignment - $newervalue = 10;
• Comparison - $newvalue != $oldvalue;
• String Operatorsvar_dump('foo' . 'bar');$a = 'foo'; a .= 'bar'; var_dump($a);
![Page 4: DIG1108C Lesson3 Fall 2014](https://reader036.vdocument.in/reader036/viewer/2022082804/547b9c6ab47959a9098b4d9b/html5/thumbnails/4.jpg)
Order of Operations
• PHP (and most languages) follows Operator Precedence rules
• These allow for unambiguous statements
• Parentheses can be used to override default Operator Precedence or to add visual clarity$taxable_income = $wages + $earnings - $deductions; $taxable_income = $wages + ( $earnings - $deductions );
![Page 5: DIG1108C Lesson3 Fall 2014](https://reader036.vdocument.in/reader036/viewer/2022082804/547b9c6ab47959a9098b4d9b/html5/thumbnails/5.jpg)
Programming Blocks
• Blocks are sections of code grouped together
• Blocks consist of declarations and statements
• PHP organizes statements into blocks with { }
• Conventions dictate indentation for readability{$foo=$bar+$bat;echo $foo;} { $foo = $bar + $bat; echo $foo;}
![Page 6: DIG1108C Lesson3 Fall 2014](https://reader036.vdocument.in/reader036/viewer/2022082804/547b9c6ab47959a9098b4d9b/html5/thumbnails/6.jpg)
Coding Conventions
• A set of guidelines for a specific programming language of recommended styles, practices & methods for each aspect of a program
• Covers things like file organization, indentation, comments, declarations, statements, white space, naming conventions, practices & principles
• This improves the readability of code and makes software maintenance easier.
• Conventions enforced by humans, not compilers
![Page 7: DIG1108C Lesson3 Fall 2014](https://reader036.vdocument.in/reader036/viewer/2022082804/547b9c6ab47959a9098b4d9b/html5/thumbnails/7.jpg)
Ease of Reading/Ease of Use• $UP=6;DN=19;$x=0;
while(++$x<=24){echo "hour $x: "; if($x>+$UP&&$X<+$DN); echo "sun is up"; else echo "sun is down": echo "\n"; }
• define( 'SUNRISE', 6 ); define( 'SUNSET', 19 );$hours = range( 1, 24);foreach ( $hours as $hour ) { // ternary operation $up_or_down = ( ( $hour >= SUNRISE and $hour <= SUNSET ) ? 'up' : 'down' ); echo "hour {$hour}: ", "sun is {$up_or_down}", "\n";}
![Page 8: DIG1108C Lesson3 Fall 2014](https://reader036.vdocument.in/reader036/viewer/2022082804/547b9c6ab47959a9098b4d9b/html5/thumbnails/8.jpg)
Assignment 3.1
Good Code, Bad Code
![Page 9: DIG1108C Lesson3 Fall 2014](https://reader036.vdocument.in/reader036/viewer/2022082804/547b9c6ab47959a9098b4d9b/html5/thumbnails/9.jpg)
Good Code, Bad Code
• Log in to Github
• Look through your forked projects for a block (~100) lines of code that are either very hard or very easy to read based on the coding style
• Copy & paste into a file named assignment-3.1.md
• Make a list with your partner of ways that the code style could be improved in each of your examples
• Save files to share with the class. Push to Github? (https://help.github.com/articles/create-a-repo)
![Page 10: DIG1108C Lesson3 Fall 2014](https://reader036.vdocument.in/reader036/viewer/2022082804/547b9c6ab47959a9098b4d9b/html5/thumbnails/10.jpg)
Git and Github - Here to Help
• Git is your robot friend that remembers what you tell it to remember, and only that
• This robot recognizes when things have changed
• It knows how to remember, just not when
• Git can tell you what changed and when, you use comments to tell it (and yourself) why
• If you ask nicely (-h or --help) the robot will help
• This robot is well organized and can track branches of changed code
![Page 11: DIG1108C Lesson3 Fall 2014](https://reader036.vdocument.in/reader036/viewer/2022082804/547b9c6ab47959a9098b4d9b/html5/thumbnails/11.jpg)
Basic git Commands
• git branch - what branches are there & which am I on?
• git status - what files have I changed or created?
• git add (files) - consider this stuff for remembering
• git commit (files) - I really want you to remember what I've considered via git add
• git push [remote [branch] ] - tell the robot named "remote" (default is "origin") about my changes in "branch" (default is "master")
• git fetch [remote] - ask the robot named "remote" for changes or branches that you don't know about yet
• git merge [branch] - attempt to combine changes in "branch"