SlideShare a Scribd company logo
INTRO TO SERVER SIDE PROGRAMMING
Week Four
Friday, September 20, 13
Basic Git Workflow Review
Save and test your work often.
If it tests ok, add then commit your work (git add & git
commit respectively)
Need to work alone? Work on a branch (git branch & git
checkout or git checkout -b for short)
Done or need to share your work? Send your work to
remote (git push)
Back to work? Get the latest code (git fetch), then include
it (git merge or git rebase)
Need to make a whole project your own? Copy it (git
clone), then add it as remote and (git pull)
Friday, September 20, 13
CONDITIONAL LOGIC
If This, Then That
Friday, September 20, 13
Friday, September 20, 13
Conditional Logic - In computer science, conditional statements,
conditional expressions and conditional constructs are features of a
programming language which perform different computations or
actions depending on whether a programmer-specified boolean
condition evaluates to true or false. Apart from the case of branch
predication, this is always achieved by selectively altering the control
flow based on some condition.
Computer Science depends heavily on Boolean Algebra
for conditional logic.
"If this thing is true, then do this. If not, do that."
Friday, September 20, 13
Guarding Expressions
Guarding - In computer programming, a guard is a boolean expression
that must evaluate to true if the program execution is to continue in the
branch in question.Boolean expressions in conditional statements usually
also fit this definition of a guard although they are called conditions.
if( ! isset($something) ) $something = 'some value';
do_something_with($something);
$something = ( isset($something) ? $something : 'default' );
$something = do_something_important() or die('error message');
use_the_variable($something);
$something = do_something_important();
if ( $something == false ) die('error message');
Friday, September 20, 13
Can I go to the Park?
Boolean values can be combined with logical operators
The order in which conditionals are evaluated matters
$permission_from_mom = $mom->request('go_to_park');
$permission_from_dad = $dad->request('go_to_park');
$permisson_from_both = (
$permission_from_mom and $permission_from_dad
);
$permisson_from_either = (
$permission_from_mom or $permission_from_dad
);
$permisson_from_one = (
$permission_from_mom xor $permission_from_dad
);
Friday, September 20, 13
Workflow Diagrams & Truth Tables
Friday, September 20, 13
Nested Conditionals
Conditionals can also be nested:
if ( empty($handedness) ) {
if ( test_lefty() and test_righty() )
$handedness = 'Ambidextrous';
else if ( test_lefty() )
$handedness = 'Left Handed';
else if ( test_righty() )
$handedness = 'Right Handed';
else $handedness = 'You Have No Hands!';
}
echo $handedness;
Friday, September 20, 13
Nested More!
Nested conditionals can be written multiple ways:
if ( empty($handedness) ) {
if ( test_lefty() ) {
if( test_righty() )
$handedness = 'Ambidextrous';
else $handedness = ' Left Handed';
}
else if ( test_righty() )
$handedness = 'Right Handed';
else $handedness = 'You Have No Hands!';
}
echo $handedness;
Friday, September 20, 13
ASSIGNMENT 4.1
Diagramming Conditional Logic
Friday, September 20, 13
Diagramming Logic
Partner up and find a project with some if-then-else
logic to examine, particularly nested logic
Individually, sketch a simple workflow diagram of the
logic and assemble a truth table. Discuss any differences
that you may have together when done
Collaborate to make one workflow diagram and truth
table to show and explain to the class
Friday, September 20, 13
Log in to Cloud9 and pull up homework-5.1.md in your
workspace (you should have this already)
Find the WordPress project on Github, fork it to your
account, then clone it into a Cloud9 Workspace
Look for some branching if-then-else logic in the code.
Look for good conditionals and guarding statements
Copy and paste some examples that you find into your
homework and attempt to identify the conditionals with
comments ("If mom says yes", "if right handed")
Save your file locally after review, add and commit it, then
push your changes to Github
Friday, September 20, 13
ASSIGNMENT 4.2
Branching Logic in WordPress
Friday, September 20, 13

More Related Content

PPTX
Spanish verbs friends
PDF
DIG1108 Lesson 6
PDF
DIG1108 Lesson 5
PDF
Dig1108 Lesson 3
PDF
Live virtual machine migration based on future prediction of resource require...
PDF
Dig1108C Lesson 2
PDF
DIG1108 Lesson 8
PDF
Dig1108 c lesson1
Spanish verbs friends
DIG1108 Lesson 6
DIG1108 Lesson 5
Dig1108 Lesson 3
Live virtual machine migration based on future prediction of resource require...
Dig1108C Lesson 2
DIG1108 Lesson 8
Dig1108 c lesson1

Similar to DIG1108 Lesson 4 (20)

PDF
DIG1108C Lesson 4 Fall 2014
PPTX
Mastering python lesson2
PDF
Decision control
PPT
Chaptfffffuuer05.PPT
PPTX
Speaking 'Development Language' (Or, how to get your hands dirty with technic...
PPT
Class 8 Lecture Notes
PDF
Selection & Making Decisions in c
PDF
Perl_Part2
PPTX
Introduction-to-Conditional-Statements-in-Python.pptx
PPTX
principal of programming language unit 3 explanation
PDF
Chapter 3 branching v4
PPT
chap8-decisionstructuresinpython123 .ppt
PDF
CIS 1403 lab 4 selection
PDF
Init() day2
PDF
DATA STRUCTURES AND ALGORITHMSI (DSA010).pdf
PPTX
03_Gaddis Python_Lecture_ppt_ch03.pptx
PPT
Control statments in c
DOCX
Copyright © 2018 Pearson Education, Inc.C H A P T E R 3.docx
DIG1108C Lesson 4 Fall 2014
Mastering python lesson2
Decision control
Chaptfffffuuer05.PPT
Speaking 'Development Language' (Or, how to get your hands dirty with technic...
Class 8 Lecture Notes
Selection & Making Decisions in c
Perl_Part2
Introduction-to-Conditional-Statements-in-Python.pptx
principal of programming language unit 3 explanation
Chapter 3 branching v4
chap8-decisionstructuresinpython123 .ppt
CIS 1403 lab 4 selection
Init() day2
DATA STRUCTURES AND ALGORITHMSI (DSA010).pdf
03_Gaddis Python_Lecture_ppt_ch03.pptx
Control statments in c
Copyright © 2018 Pearson Education, Inc.C H A P T E R 3.docx
Ad

Recently uploaded (20)

PPTX
Chapter 5: Probability Theory and Statistics
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Getting Started with Data Integration: FME Form 101
PDF
Enhancing emotion recognition model for a student engagement use case through...
PPTX
1. Introduction to Computer Programming.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
A Presentation on Artificial Intelligence
PDF
A novel scalable deep ensemble learning framework for big data classification...
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
project resource management chapter-09.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
August Patch Tuesday
PDF
NewMind AI Weekly Chronicles - August'25-Week II
Chapter 5: Probability Theory and Statistics
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Getting Started with Data Integration: FME Form 101
Enhancing emotion recognition model for a student engagement use case through...
1. Introduction to Computer Programming.pptx
Assigned Numbers - 2025 - Bluetooth® Document
DP Operators-handbook-extract for the Mautical Institute
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
A Presentation on Artificial Intelligence
A novel scalable deep ensemble learning framework for big data classification...
cloud_computing_Infrastucture_as_cloud_p
project resource management chapter-09.pdf
Group 1 Presentation -Planning and Decision Making .pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Tartificialntelligence_presentation.pptx
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Programs and apps: productivity, graphics, security and other tools
August Patch Tuesday
NewMind AI Weekly Chronicles - August'25-Week II
Ad

DIG1108 Lesson 4

  • 1. INTRO TO SERVER SIDE PROGRAMMING Week Four Friday, September 20, 13
  • 2. Basic Git Workflow Review Save and test your work often. If it tests ok, add then commit your work (git add & git commit respectively) Need to work alone? Work on a branch (git branch & git checkout or git checkout -b for short) Done or need to share your work? Send your work to remote (git push) Back to work? Get the latest code (git fetch), then include it (git merge or git rebase) Need to make a whole project your own? Copy it (git clone), then add it as remote and (git pull) Friday, September 20, 13
  • 3. CONDITIONAL LOGIC If This, Then That Friday, September 20, 13
  • 5. Conditional Logic - In computer science, conditional statements, conditional expressions and conditional constructs are features of a programming language which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false. Apart from the case of branch predication, this is always achieved by selectively altering the control flow based on some condition. Computer Science depends heavily on Boolean Algebra for conditional logic. "If this thing is true, then do this. If not, do that." Friday, September 20, 13
  • 6. Guarding Expressions Guarding - In computer programming, a guard is a boolean expression that must evaluate to true if the program execution is to continue in the branch in question.Boolean expressions in conditional statements usually also fit this definition of a guard although they are called conditions. if( ! isset($something) ) $something = 'some value'; do_something_with($something); $something = ( isset($something) ? $something : 'default' ); $something = do_something_important() or die('error message'); use_the_variable($something); $something = do_something_important(); if ( $something == false ) die('error message'); Friday, September 20, 13
  • 7. Can I go to the Park? Boolean values can be combined with logical operators The order in which conditionals are evaluated matters $permission_from_mom = $mom->request('go_to_park'); $permission_from_dad = $dad->request('go_to_park'); $permisson_from_both = ( $permission_from_mom and $permission_from_dad ); $permisson_from_either = ( $permission_from_mom or $permission_from_dad ); $permisson_from_one = ( $permission_from_mom xor $permission_from_dad ); Friday, September 20, 13
  • 8. Workflow Diagrams & Truth Tables Friday, September 20, 13
  • 9. Nested Conditionals Conditionals can also be nested: if ( empty($handedness) ) { if ( test_lefty() and test_righty() ) $handedness = 'Ambidextrous'; else if ( test_lefty() ) $handedness = 'Left Handed'; else if ( test_righty() ) $handedness = 'Right Handed'; else $handedness = 'You Have No Hands!'; } echo $handedness; Friday, September 20, 13
  • 10. Nested More! Nested conditionals can be written multiple ways: if ( empty($handedness) ) { if ( test_lefty() ) { if( test_righty() ) $handedness = 'Ambidextrous'; else $handedness = ' Left Handed'; } else if ( test_righty() ) $handedness = 'Right Handed'; else $handedness = 'You Have No Hands!'; } echo $handedness; Friday, September 20, 13
  • 11. ASSIGNMENT 4.1 Diagramming Conditional Logic Friday, September 20, 13
  • 12. Diagramming Logic Partner up and find a project with some if-then-else logic to examine, particularly nested logic Individually, sketch a simple workflow diagram of the logic and assemble a truth table. Discuss any differences that you may have together when done Collaborate to make one workflow diagram and truth table to show and explain to the class Friday, September 20, 13
  • 13. Log in to Cloud9 and pull up homework-5.1.md in your workspace (you should have this already) Find the WordPress project on Github, fork it to your account, then clone it into a Cloud9 Workspace Look for some branching if-then-else logic in the code. Look for good conditionals and guarding statements Copy and paste some examples that you find into your homework and attempt to identify the conditionals with comments ("If mom says yes", "if right handed") Save your file locally after review, add and commit it, then push your changes to Github Friday, September 20, 13
  • 14. ASSIGNMENT 4.2 Branching Logic in WordPress Friday, September 20, 13