SlideShare a Scribd company logo
Speaking “Development Language”
Or, how to get your hands dirty
with technical stuff.
GWU Libraries ● 12 June 2012
Julie Meloni // @jcmeloni // jcmeloni@gmail.com
Today’s Goal
• To increase the number of people who can
“work” on technical issues in the library
• Technical “work” in the future come from the
needs of the present: your needs.
▫ When you can articulate them to someone who
can do the codework, we all win.
▫ If YOU can do the codework, you win even more.
Today’s General Outline
• Development Lifecycle & Where You Fit In
• Computer Programming Basics
• Python in Particular
• Where to Learn More
and Where You Fit In…
General Software Development Lifecycle
• Define
▫ What you want to do
• Design
▫ How you want to do it
• Implement
▫ Actually do it
• Test
▫ Did what you do actually work
• Deploy
▫ Send it off into the wild
• Maintain
▫ Don‟t forget about it!
Design Phase Needs Domain Knowledge
• Functional requirements define the functionality
of the system, in terms of inputs, behaviors,
outputs.
▫ What is the system supposed to accomplish?
• Functional requirements come from
stakeholders (users), not (necessarily)
developers.
▫ stakeholder request -> feature -> use case ->
business rule
Example Functional Requirement
• Example functionality: representation and manipulation of
hierarchy
• Description: The GUI should allow users to view and interact with
hierarchical structures representing the intellectual arrangement
and the original arrangement of files and directories within ingested
accessions. For each component level in the intellectual
arrangement, the user interface should present associated digital
assets and an interface to view and edit descriptive metadata
elements.
• Specific Components: collapse and expand record nodes for
viewing (applies to both the original ingest and the intellectual
arrangement), add new child record, add new sibling record, copy
all or part of the existing structure to the intellectual arrangement,
delete a record in intellectual arrangement.
• An epic is a long story that can be broken into smaller stories.
• It is a narrative; it describes interactions between people and
a system
▫ WHO the actors are
▫ WHAT the actors are trying to accomplish
▫ The OUTPUT at the end
• Narrative should:
▫ Be chronological
▫ Be complete (the who, what, AND the why)
▫ NOT reference specific software or other tools
▫ NOT describe a user interface
Writing Use Cases (or Epics)
• Stories are the pieces of an epic that begin to get to the heart of the
matter.
• Still written in non-technical language, but move toward a technical
structure.
• Given/When/Then scenarios
▫ GIVEN the system is in a known state WHEN an action is performed
THEN these outcomes should exist
▫ EXAMPLE:
 GIVEN one thing
 AND an other thing
 AND yet an other thing
 WHEN I open my eyes
 THEN I see something
 But I don't see something else
Writing User Stories
• Scenario: User attempting to add an object
▫ GIVEN I am logged in
 AND I have selected the “add” form
 AND I am attempting to upload a file
▫ WHEN I invoke the file upload button
▫ THEN validate file type on client side
 AND return alert message if not valid
 AND continue if is valid
▫ THEN validate file type on server side
 AND return alert message if not valid
 AND finish process if is valid
Actual Story Example
Now You Do One!
• Think of a problem you want to solve (a batch
process, something displayed in the OPAC, etc)
• Think of the use case:
▫ WHO is doing WHAT to achieve OUTPUT
• Break it down into a story:
▫ GIVEN something WHEN something happens
THEN do something else
That Was the Define Phase…
• From a set of stories, developers begin to
DESIGN a way to bring the stories to life.
• At some point, programming begins and the
stories are IMPLEMENTED in code.
• During the coding process, TESTS are written
and code is TESTED.
• When the tests pass, the code is DEPLOYED.
• As time goes on, the code is MAINTAINED.
Why Program?
• Express complex logic and perform
computations.
▫ We make the computer do what we want it to do.
▫ These behaviors come from our imaginations.
▫ The processes come from our needs and desires.
• Do things that take a long time or are difficult
for humans to do (counting, comparing,
repeating)
What is a “Programming Language”?
• An artificial language with a limited purpose
• A means of expressing computations (math) and
algorithms (logic)
What Does a Programming Language
Look Like?
• ...a lot like human language, as it has:
▫ Syntax (form)
▫ Semantics (meaning)
 signs/words (variables, symbols, numbers, strings)
 expressions
 flow control (decisions, conditions, loops, narrative)
 complex entities (methods, structures, & objects)
A Few Basic Programming Components
• Variables & Arrays
• Operators
• Flow Control
• Functions
Putting together these pieces adds up to
programming (or scripting, or in general “writing
some stuff to tell the computer what to do”)
Variables & Arrays
• A variable is a bucket that holds one piece of
information.
• Examples:
▫ $string_variable = “The Library”;
▫ $numeric_variable= 4;
▫ $myname = “Julie”;
Variables & Arrays
• An array is a type of variable (or bucket) that
holds many pieces of information.
• Example:
▫ $rainbow = array(“red”, “orange”, “yellow”,
“green”, “blue”, “indigo”, “violet”)
 $rainbow[0] holds “red”
 $rainbow[1] holds “orange”
Operators
• Arithmetic
▫ +, -, *, / (add, subtract, multiply, divide)
• Assignment
▫ = (“Assign the value of 4 to the variable called a”)
 $a = 4;
▫ += (“Add the value of 5 to the variable that already
holds 4”)
 $a += 5; // $a now holds 9
▫ .= (“Attach the value „World‟ to the end of „Hello‟ to
make a new value for the string variable”)
 $string = “Hello”;
 $string .= “World”; // would print “HelloWorld” (no
space because we didn‟t add that!)
Operators
• Comparison
▫ == (“when I compare the value in variable a to the
value in variable be, that comparison is true”)
 $a == $b
▫ != (“when I compare the value in variable a to the
value in variable be, that comparison is not true”)
 $a != $b
▫ >, >= (“the value of variable a is greater than (or
greater than or equal to) the value of variable b”)
 $a > $b
▫ <, <= (“the value of variable a is less than (or less
than or equal to) the value of variable b”)
 $a < b
Operators
• Concatenation
• + (string + string = stringstring)
• Logical
• && (and)
• || (or)
• ! (not)
Flow Control
• if
if (something is true) {
do something here
}
• if ... else ... else if
if (something is true) {
do something here
} else if (something is true) {
do something here
} else {
do something here
}
Flow Control
• while
while (something is true) {
do something here
}
• for
for (something is true) {
do something here
}
Procedures and Functions
• Scripts can contain linear, procedural code.
• Scripts can also contain references to reusable
bits of code, called functions.
▫ Built-in language functions
▫ Functions you write yourself.
Why Python?
• It is a general-purpose language
• It has been around for a long time (20+ years)
• It has a strong developer community
• It includes a large built-in library of functionality
• It is readable
• It is expressive (you can do a lot with a little)
Uncluttered Layout
• Less punctuation
▫ While some languages use $ to indicate variables, or
brackets around logical constructs, Python does not.
• More whitespace
▫ Instead of brackets to set off blocks, indentation
means something in Python.
Variables in Python
• Do not begin with a symbol and do not end with
terminating punctuation.
• Examples:
▫ string_variable = “The Library”
▫ numeric_variable= 4
▫ myname = “Julie”
Set and Print Variables
# set up the variables
string_variable = "The Library";
numeric_variable = 4;
myname = "Julie";
# print the variables
print string_variable
print numeric_variable
print myname
Arrays in Python
• …are called lists.
• Example:
▫ rainbow = [“red”, “orange”, “yellow”, “green”,
“blue”, “indigo”, “violet”]
 print rainbow[0] shows “red”
 print rainbow[1] shows “orange”
Operators in Python (are not terribly special)
• Arithmetic
▫ +, -, *, /
• Assignment
▫ =
▫ +=, -=, *=, /=
• Comparison
▫ >, <, >=, <=
• Logical
▫ and, or, not
Flow Control in Python
• if
if something is true:
INDENT and do something here
# here’s an example
people = 20
space_aliens = 30
if people < space_aliens:
print "Oh no! The world is doomed"
if people > space_aliens:
print "We're cool."
Flow Control
• if ... elif ... else
if something is true:
INDENT and do something here
elif something is true:
INDENT and do something here
else:
INDENT and do something here
Flow Control
• EXAMPLE
people = 30
cars = 40
if cars > people:
print "We should take the cars."
elif cars < people:
print "We should not take the cars."
else:
print "We can't decide."
Flow Control
• while
while something is true:
INDENT and do something here
# here’s an example
count = 0
while (count < 9):
print 'The count is:', count
count = count + 1
print "...and we're done!"
Flow Control
The count is: 0
The count is: 1
The count is: 2
The count is: 3
The count is: 4
The count is: 5
The count is: 6
The count is: 7
The count is: 8
...and we're done!
Flow Control
• for
for there are things in a sequence:
INDENT and do something here
#here’s an example
rainbow = ["red", "orange", "yellow", "green",
"blue", "indigo", "violet"]
for color in rainbow:
print color
Flow Control
red
orange
yellow
green
blue
indigo
violet
Functions in Python
• Start with the keyword def
• Accepts parameters
• There‟s indentation
• You get something in return
Functions in Python
def fibonacci(n):
a, b = 0, 1
while a < n:
print a,
a, b = b, a+b
fibonacci(1000)
/////////////////////////////////////////////////
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
So How Does Your Group Use Python?
• As batch scripts, with or without a web interface
▫ One-offs, utilities, etc
• Using a Web Framework (Django)
▫ Frameworks allow you to write web applications
quickly because they include, well, a framework
for doing so.
 Reusable libraries common to web applications
 Coding standards
 Template and templating processes
Sample Utility (pymarc)
• For manipulation of MARC records
▫ In GitHub at https://github.com/edsu/pymarc/
▫ From command-line or wrapped within an app
• Example 1:
from pymarc import MARCReader
reader = MARCReader(open('marc.txt'))
for record in reader:
print record['245']['a']
Sample Utility (pymarc)
• Example 2:
from pymarc import Record, Field
record = Record()
record.addField(
Field(
tag = '245',
indicators = ['0','1'],
subfields = [
'a', 'The pragmatic programmer : ',
'b', 'from journeyman to master /',
'c', 'Andrew Hunt, David Thomas.'
]))
out = open('file.dat', 'w')
out.write(record.asMARC21())
out.close()
Launchpad
• Works within a Django framework
• Has a directory structure you can follow to find
how things are pieced together
• Even in a framework, it is still readable code
Launchpad (example from a template)
{% extends "base.html" %}
{% load launchpad_extras %}
{% block title %}{{ bib.TITLE }}{% endblock
title %}
…
{% if bib.ISBN|clean_isbn %}
ISBN: <a href='{% url isbn bib.ISBN|clean_isbn
%}'>{% url isbn bib.ISBN|clean_isbn %}</a>
{% endif %}
Launchpad (example from a template)
def clean_isbn(value):
isbn,sep,remainder = value.strip().partition('')
if len(isbn) < 10:
return ''
isbn = isbn.replace('-', '')
isbn = isbn.replace(':', '')
return isbn
Additional Resources
• Learn Python the Hard Way
▫ http://learnpythonthehardway.org/book/
• The Python Tutorial
▫ http://docs.python.org/tutorial/index.html
• Django
▫ https://www.djangoproject.com/
• GWU Libraries GitHub repositories
▫ https://github.com/gwu-libraries/

More Related Content

What's hot

Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
Christian Lilley
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
elliando dias
 
Web Development with Smalltalk
Web Development with SmalltalkWeb Development with Smalltalk
Web Development with Smalltalk
Mariano Martínez Peck
 
SADI: A design-pattern for “native” Linked-Data Semantic Web Services
SADI: A design-pattern for “native” Linked-Data Semantic Web ServicesSADI: A design-pattern for “native” Linked-Data Semantic Web Services
SADI: A design-pattern for “native” Linked-Data Semantic Web Services
Ioan Toma
 
CPP02 - The Structure of a Program
CPP02 - The Structure of a ProgramCPP02 - The Structure of a Program
CPP02 - The Structure of a Program
Michael Heron
 
The Inclusive Web: hands-on with HTML5 and jQuery
The Inclusive Web: hands-on with HTML5 and jQueryThe Inclusive Web: hands-on with HTML5 and jQuery
The Inclusive Web: hands-on with HTML5 and jQuery
colinbdclark
 
Easy javascript
Easy javascriptEasy javascript
Easy javascript
Bui Kiet
 
Eurosport's Kodakademi #1
Eurosport's Kodakademi #1Eurosport's Kodakademi #1
Eurosport's Kodakademi #1
Benjamin Baumann
 
JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript Workshop
Pamela Fox
 
JavaScript!
JavaScript!JavaScript!
JavaScript!
RTigger
 
JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery Basics
Kaloyan Kosev
 
Getting Started with Web
Getting Started with WebGetting Started with Web
Getting Started with Web
Akshay Mathur
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery Essentials
Mark Rackley
 
Php melb cqrs-ddd-predaddy
Php melb cqrs-ddd-predaddyPhp melb cqrs-ddd-predaddy
Php melb cqrs-ddd-predaddy
Douglas Reith
 
Fewd week4 slides
Fewd week4 slidesFewd week4 slides
Fewd week4 slides
William Myers
 
Implementing the Genetic Algorithm in XSLT: PoC
Implementing the Genetic Algorithm in XSLT: PoCImplementing the Genetic Algorithm in XSLT: PoC
Implementing the Genetic Algorithm in XSLT: PoC
jimfuller2009
 
Javascript Best Practices
Javascript Best PracticesJavascript Best Practices
Javascript Best Practices
Christian Heilmann
 
Backbone
BackboneBackbone
Backbone
Ynon Perek
 
Perl Teach-In (part 2)
Perl Teach-In (part 2)Perl Teach-In (part 2)
Perl Teach-In (part 2)
Dave Cross
 
Smalltalk and Business
Smalltalk and BusinessSmalltalk and Business
Smalltalk and Business
Mariano Martínez Peck
 

What's hot (20)

Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Web Development with Smalltalk
Web Development with SmalltalkWeb Development with Smalltalk
Web Development with Smalltalk
 
SADI: A design-pattern for “native” Linked-Data Semantic Web Services
SADI: A design-pattern for “native” Linked-Data Semantic Web ServicesSADI: A design-pattern for “native” Linked-Data Semantic Web Services
SADI: A design-pattern for “native” Linked-Data Semantic Web Services
 
CPP02 - The Structure of a Program
CPP02 - The Structure of a ProgramCPP02 - The Structure of a Program
CPP02 - The Structure of a Program
 
The Inclusive Web: hands-on with HTML5 and jQuery
The Inclusive Web: hands-on with HTML5 and jQueryThe Inclusive Web: hands-on with HTML5 and jQuery
The Inclusive Web: hands-on with HTML5 and jQuery
 
Easy javascript
Easy javascriptEasy javascript
Easy javascript
 
Eurosport's Kodakademi #1
Eurosport's Kodakademi #1Eurosport's Kodakademi #1
Eurosport's Kodakademi #1
 
JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript Workshop
 
JavaScript!
JavaScript!JavaScript!
JavaScript!
 
JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery Basics
 
Getting Started with Web
Getting Started with WebGetting Started with Web
Getting Started with Web
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery Essentials
 
Php melb cqrs-ddd-predaddy
Php melb cqrs-ddd-predaddyPhp melb cqrs-ddd-predaddy
Php melb cqrs-ddd-predaddy
 
Fewd week4 slides
Fewd week4 slidesFewd week4 slides
Fewd week4 slides
 
Implementing the Genetic Algorithm in XSLT: PoC
Implementing the Genetic Algorithm in XSLT: PoCImplementing the Genetic Algorithm in XSLT: PoC
Implementing the Genetic Algorithm in XSLT: PoC
 
Javascript Best Practices
Javascript Best PracticesJavascript Best Practices
Javascript Best Practices
 
Backbone
BackboneBackbone
Backbone
 
Perl Teach-In (part 2)
Perl Teach-In (part 2)Perl Teach-In (part 2)
Perl Teach-In (part 2)
 
Smalltalk and Business
Smalltalk and BusinessSmalltalk and Business
Smalltalk and Business
 

Similar to Speaking 'Development Language' (Or, how to get your hands dirty with technical stuff.)

Introduction to Programming (well, kind of.)
Introduction to Programming (well, kind of.)Introduction to Programming (well, kind of.)
Introduction to Programming (well, kind of.)
Julie Meloni
 
Build a virtual pet with javascript (april 2017)
Build a virtual pet with javascript (april 2017)Build a virtual pet with javascript (april 2017)
Build a virtual pet with javascript (april 2017)
Thinkful
 
Java Building Blocks
Java Building BlocksJava Building Blocks
Java Building Blocks
Cate Huston
 
James Coplien - Trygve - October 17, 2016
James Coplien - Trygve - October 17, 2016James Coplien - Trygve - October 17, 2016
James Coplien - Trygve - October 17, 2016
Foo Café Copenhagen
 
Build a Virtual Pet with JavaScript (May 2017, Santa Monica)
Build a Virtual Pet with JavaScript (May 2017, Santa Monica) Build a Virtual Pet with JavaScript (May 2017, Santa Monica)
Build a Virtual Pet with JavaScript (May 2017, Santa Monica)
Thinkful
 
An Introduction to Processing
An Introduction to ProcessingAn Introduction to Processing
An Introduction to Processing
Cate Huston
 
Build a virtual pet with javascript (may 2017)
Build a virtual pet with javascript (may 2017)Build a virtual pet with javascript (may 2017)
Build a virtual pet with javascript (may 2017)
Thinkful
 
Domain-Driven Design: The "What" and the "Why"
Domain-Driven Design: The "What" and the "Why"Domain-Driven Design: The "What" and the "Why"
Domain-Driven Design: The "What" and the "Why"
bincangteknologi
 
Python_Introduction&DataType.pptx
Python_Introduction&DataType.pptxPython_Introduction&DataType.pptx
Python_Introduction&DataType.pptx
HaythamBarakeh1
 
Rubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDDRubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDD
Rodrigo Urubatan
 
Agile Data: Building Hadoop Analytics Applications
Agile Data: Building Hadoop Analytics ApplicationsAgile Data: Building Hadoop Analytics Applications
Agile Data: Building Hadoop Analytics Applications
DataWorks Summit
 
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Fwdays
 
Agile Data Science by Russell Jurney_ The Hive_Janruary 29 2014
Agile Data Science by Russell Jurney_ The Hive_Janruary 29 2014Agile Data Science by Russell Jurney_ The Hive_Janruary 29 2014
Agile Data Science by Russell Jurney_ The Hive_Janruary 29 2014
The Hive
 
Data weave 2.0 language fundamentals
Data weave 2.0 language fundamentalsData weave 2.0 language fundamentals
Data weave 2.0 language fundamentals
ManjuKumara GH
 
Dapper: the microORM that will change your life
Dapper: the microORM that will change your lifeDapper: the microORM that will change your life
Dapper: the microORM that will change your life
Davide Mauri
 
Test First Teaching
Test First TeachingTest First Teaching
Test First Teaching
Sarah Allen
 
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
Mike Harris
 
Systems Monitoring with Prometheus (Devops Ireland April 2015)
Systems Monitoring with Prometheus (Devops Ireland April 2015)Systems Monitoring with Prometheus (Devops Ireland April 2015)
Systems Monitoring with Prometheus (Devops Ireland April 2015)
Brian Brazil
 
Drupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandDrupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the island
Angela Byron
 
Don't get blamed for your choices - Techorama 2019
Don't get blamed for your choices - Techorama 2019Don't get blamed for your choices - Techorama 2019
Don't get blamed for your choices - Techorama 2019
Hannes Lowette
 

Similar to Speaking 'Development Language' (Or, how to get your hands dirty with technical stuff.) (20)

Introduction to Programming (well, kind of.)
Introduction to Programming (well, kind of.)Introduction to Programming (well, kind of.)
Introduction to Programming (well, kind of.)
 
Build a virtual pet with javascript (april 2017)
Build a virtual pet with javascript (april 2017)Build a virtual pet with javascript (april 2017)
Build a virtual pet with javascript (april 2017)
 
Java Building Blocks
Java Building BlocksJava Building Blocks
Java Building Blocks
 
James Coplien - Trygve - October 17, 2016
James Coplien - Trygve - October 17, 2016James Coplien - Trygve - October 17, 2016
James Coplien - Trygve - October 17, 2016
 
Build a Virtual Pet with JavaScript (May 2017, Santa Monica)
Build a Virtual Pet with JavaScript (May 2017, Santa Monica) Build a Virtual Pet with JavaScript (May 2017, Santa Monica)
Build a Virtual Pet with JavaScript (May 2017, Santa Monica)
 
An Introduction to Processing
An Introduction to ProcessingAn Introduction to Processing
An Introduction to Processing
 
Build a virtual pet with javascript (may 2017)
Build a virtual pet with javascript (may 2017)Build a virtual pet with javascript (may 2017)
Build a virtual pet with javascript (may 2017)
 
Domain-Driven Design: The "What" and the "Why"
Domain-Driven Design: The "What" and the "Why"Domain-Driven Design: The "What" and the "Why"
Domain-Driven Design: The "What" and the "Why"
 
Python_Introduction&DataType.pptx
Python_Introduction&DataType.pptxPython_Introduction&DataType.pptx
Python_Introduction&DataType.pptx
 
Rubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDDRubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDD
 
Agile Data: Building Hadoop Analytics Applications
Agile Data: Building Hadoop Analytics ApplicationsAgile Data: Building Hadoop Analytics Applications
Agile Data: Building Hadoop Analytics Applications
 
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
 
Agile Data Science by Russell Jurney_ The Hive_Janruary 29 2014
Agile Data Science by Russell Jurney_ The Hive_Janruary 29 2014Agile Data Science by Russell Jurney_ The Hive_Janruary 29 2014
Agile Data Science by Russell Jurney_ The Hive_Janruary 29 2014
 
Data weave 2.0 language fundamentals
Data weave 2.0 language fundamentalsData weave 2.0 language fundamentals
Data weave 2.0 language fundamentals
 
Dapper: the microORM that will change your life
Dapper: the microORM that will change your lifeDapper: the microORM that will change your life
Dapper: the microORM that will change your life
 
Test First Teaching
Test First TeachingTest First Teaching
Test First Teaching
 
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
 
Systems Monitoring with Prometheus (Devops Ireland April 2015)
Systems Monitoring with Prometheus (Devops Ireland April 2015)Systems Monitoring with Prometheus (Devops Ireland April 2015)
Systems Monitoring with Prometheus (Devops Ireland April 2015)
 
Drupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandDrupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the island
 
Don't get blamed for your choices - Techorama 2019
Don't get blamed for your choices - Techorama 2019Don't get blamed for your choices - Techorama 2019
Don't get blamed for your choices - Techorama 2019
 

More from Julie Meloni

Everything I learned about a diverse workforce in tech, I learned…in the gove...
Everything I learned about a diverse workforce in tech, I learned…in the gove...Everything I learned about a diverse workforce in tech, I learned…in the gove...
Everything I learned about a diverse workforce in tech, I learned…in the gove...
Julie Meloni
 
Learning About JavaScript (…and its little buddy, JQuery!)
Learning About JavaScript (…and its little buddy, JQuery!)Learning About JavaScript (…and its little buddy, JQuery!)
Learning About JavaScript (…and its little buddy, JQuery!)
Julie Meloni
 
Developing and Deploying Open Source in the Library: Hydra, Blacklight, and B...
Developing and Deploying Open Source in the Library: Hydra, Blacklight, and B...Developing and Deploying Open Source in the Library: Hydra, Blacklight, and B...
Developing and Deploying Open Source in the Library: Hydra, Blacklight, and B...
Julie Meloni
 
Libra: An Unmediated, Self-Deposit, Institutional Repository at the Universit...
Libra: An Unmediated, Self-Deposit, Institutional Repository at the Universit...Libra: An Unmediated, Self-Deposit, Institutional Repository at the Universit...
Libra: An Unmediated, Self-Deposit, Institutional Repository at the Universit...
Julie Meloni
 
Development Lifecycle: From Requirement to Release
Development Lifecycle: From Requirement to ReleaseDevelopment Lifecycle: From Requirement to Release
Development Lifecycle: From Requirement to Release
Julie Meloni
 
Everyone's a Coder Now: Reading and Writing Technical Code
Everyone's a Coder Now: Reading and Writing Technical CodeEveryone's a Coder Now: Reading and Writing Technical Code
Everyone's a Coder Now: Reading and Writing Technical Code
Julie Meloni
 
Community, Cohesion, and Commitment
Community, Cohesion, and CommitmentCommunity, Cohesion, and Commitment
Community, Cohesion, and Commitment
Julie Meloni
 
Residential Learning Communities and Common Reading Programs
Residential Learning Communities and Common Reading ProgramsResidential Learning Communities and Common Reading Programs
Residential Learning Communities and Common Reading Programs
Julie Meloni
 
Managing Your (DH) Project: Setting the Foundation for Working Collaborativel...
Managing Your (DH) Project: Setting the Foundation for Working Collaborativel...Managing Your (DH) Project: Setting the Foundation for Working Collaborativel...
Managing Your (DH) Project: Setting the Foundation for Working Collaborativel...
Julie Meloni
 
Let's Remediate!
Let's Remediate!Let's Remediate!
Let's Remediate!
Julie Meloni
 
Entering the Conversation
Entering the ConversationEntering the Conversation
Entering the Conversation
Julie Meloni
 
Mavericks: The Ultra-Collaborative Composition Classroom
Mavericks: The Ultra-Collaborative Composition ClassroomMavericks: The Ultra-Collaborative Composition Classroom
Mavericks: The Ultra-Collaborative Composition Classroom
Julie Meloni
 

More from Julie Meloni (12)

Everything I learned about a diverse workforce in tech, I learned…in the gove...
Everything I learned about a diverse workforce in tech, I learned…in the gove...Everything I learned about a diverse workforce in tech, I learned…in the gove...
Everything I learned about a diverse workforce in tech, I learned…in the gove...
 
Learning About JavaScript (…and its little buddy, JQuery!)
Learning About JavaScript (…and its little buddy, JQuery!)Learning About JavaScript (…and its little buddy, JQuery!)
Learning About JavaScript (…and its little buddy, JQuery!)
 
Developing and Deploying Open Source in the Library: Hydra, Blacklight, and B...
Developing and Deploying Open Source in the Library: Hydra, Blacklight, and B...Developing and Deploying Open Source in the Library: Hydra, Blacklight, and B...
Developing and Deploying Open Source in the Library: Hydra, Blacklight, and B...
 
Libra: An Unmediated, Self-Deposit, Institutional Repository at the Universit...
Libra: An Unmediated, Self-Deposit, Institutional Repository at the Universit...Libra: An Unmediated, Self-Deposit, Institutional Repository at the Universit...
Libra: An Unmediated, Self-Deposit, Institutional Repository at the Universit...
 
Development Lifecycle: From Requirement to Release
Development Lifecycle: From Requirement to ReleaseDevelopment Lifecycle: From Requirement to Release
Development Lifecycle: From Requirement to Release
 
Everyone's a Coder Now: Reading and Writing Technical Code
Everyone's a Coder Now: Reading and Writing Technical CodeEveryone's a Coder Now: Reading and Writing Technical Code
Everyone's a Coder Now: Reading and Writing Technical Code
 
Community, Cohesion, and Commitment
Community, Cohesion, and CommitmentCommunity, Cohesion, and Commitment
Community, Cohesion, and Commitment
 
Residential Learning Communities and Common Reading Programs
Residential Learning Communities and Common Reading ProgramsResidential Learning Communities and Common Reading Programs
Residential Learning Communities and Common Reading Programs
 
Managing Your (DH) Project: Setting the Foundation for Working Collaborativel...
Managing Your (DH) Project: Setting the Foundation for Working Collaborativel...Managing Your (DH) Project: Setting the Foundation for Working Collaborativel...
Managing Your (DH) Project: Setting the Foundation for Working Collaborativel...
 
Let's Remediate!
Let's Remediate!Let's Remediate!
Let's Remediate!
 
Entering the Conversation
Entering the ConversationEntering the Conversation
Entering the Conversation
 
Mavericks: The Ultra-Collaborative Composition Classroom
Mavericks: The Ultra-Collaborative Composition ClassroomMavericks: The Ultra-Collaborative Composition Classroom
Mavericks: The Ultra-Collaborative Composition Classroom
 

Recently uploaded

Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
Finale of the Year: Apply for Next One!
Finale of the Year: Apply for Next One!Finale of the Year: Apply for Next One!
Finale of the Year: Apply for Next One!
GDSC PJATK
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 

Recently uploaded (20)

Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
Finale of the Year: Apply for Next One!
Finale of the Year: Apply for Next One!Finale of the Year: Apply for Next One!
Finale of the Year: Apply for Next One!
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 

Speaking 'Development Language' (Or, how to get your hands dirty with technical stuff.)

  • 1. Speaking “Development Language” Or, how to get your hands dirty with technical stuff. GWU Libraries ● 12 June 2012 Julie Meloni // @jcmeloni // jcmeloni@gmail.com
  • 2. Today’s Goal • To increase the number of people who can “work” on technical issues in the library • Technical “work” in the future come from the needs of the present: your needs. ▫ When you can articulate them to someone who can do the codework, we all win. ▫ If YOU can do the codework, you win even more.
  • 3. Today’s General Outline • Development Lifecycle & Where You Fit In • Computer Programming Basics • Python in Particular • Where to Learn More
  • 4. and Where You Fit In…
  • 5. General Software Development Lifecycle • Define ▫ What you want to do • Design ▫ How you want to do it • Implement ▫ Actually do it • Test ▫ Did what you do actually work • Deploy ▫ Send it off into the wild • Maintain ▫ Don‟t forget about it!
  • 6. Design Phase Needs Domain Knowledge • Functional requirements define the functionality of the system, in terms of inputs, behaviors, outputs. ▫ What is the system supposed to accomplish? • Functional requirements come from stakeholders (users), not (necessarily) developers. ▫ stakeholder request -> feature -> use case -> business rule
  • 7. Example Functional Requirement • Example functionality: representation and manipulation of hierarchy • Description: The GUI should allow users to view and interact with hierarchical structures representing the intellectual arrangement and the original arrangement of files and directories within ingested accessions. For each component level in the intellectual arrangement, the user interface should present associated digital assets and an interface to view and edit descriptive metadata elements. • Specific Components: collapse and expand record nodes for viewing (applies to both the original ingest and the intellectual arrangement), add new child record, add new sibling record, copy all or part of the existing structure to the intellectual arrangement, delete a record in intellectual arrangement.
  • 8. • An epic is a long story that can be broken into smaller stories. • It is a narrative; it describes interactions between people and a system ▫ WHO the actors are ▫ WHAT the actors are trying to accomplish ▫ The OUTPUT at the end • Narrative should: ▫ Be chronological ▫ Be complete (the who, what, AND the why) ▫ NOT reference specific software or other tools ▫ NOT describe a user interface Writing Use Cases (or Epics)
  • 9. • Stories are the pieces of an epic that begin to get to the heart of the matter. • Still written in non-technical language, but move toward a technical structure. • Given/When/Then scenarios ▫ GIVEN the system is in a known state WHEN an action is performed THEN these outcomes should exist ▫ EXAMPLE:  GIVEN one thing  AND an other thing  AND yet an other thing  WHEN I open my eyes  THEN I see something  But I don't see something else Writing User Stories
  • 10. • Scenario: User attempting to add an object ▫ GIVEN I am logged in  AND I have selected the “add” form  AND I am attempting to upload a file ▫ WHEN I invoke the file upload button ▫ THEN validate file type on client side  AND return alert message if not valid  AND continue if is valid ▫ THEN validate file type on server side  AND return alert message if not valid  AND finish process if is valid Actual Story Example
  • 11. Now You Do One! • Think of a problem you want to solve (a batch process, something displayed in the OPAC, etc) • Think of the use case: ▫ WHO is doing WHAT to achieve OUTPUT • Break it down into a story: ▫ GIVEN something WHEN something happens THEN do something else
  • 12. That Was the Define Phase… • From a set of stories, developers begin to DESIGN a way to bring the stories to life. • At some point, programming begins and the stories are IMPLEMENTED in code. • During the coding process, TESTS are written and code is TESTED. • When the tests pass, the code is DEPLOYED. • As time goes on, the code is MAINTAINED.
  • 13.
  • 14. Why Program? • Express complex logic and perform computations. ▫ We make the computer do what we want it to do. ▫ These behaviors come from our imaginations. ▫ The processes come from our needs and desires. • Do things that take a long time or are difficult for humans to do (counting, comparing, repeating)
  • 15. What is a “Programming Language”? • An artificial language with a limited purpose • A means of expressing computations (math) and algorithms (logic)
  • 16. What Does a Programming Language Look Like? • ...a lot like human language, as it has: ▫ Syntax (form) ▫ Semantics (meaning)  signs/words (variables, symbols, numbers, strings)  expressions  flow control (decisions, conditions, loops, narrative)  complex entities (methods, structures, & objects)
  • 17. A Few Basic Programming Components • Variables & Arrays • Operators • Flow Control • Functions Putting together these pieces adds up to programming (or scripting, or in general “writing some stuff to tell the computer what to do”)
  • 18. Variables & Arrays • A variable is a bucket that holds one piece of information. • Examples: ▫ $string_variable = “The Library”; ▫ $numeric_variable= 4; ▫ $myname = “Julie”;
  • 19. Variables & Arrays • An array is a type of variable (or bucket) that holds many pieces of information. • Example: ▫ $rainbow = array(“red”, “orange”, “yellow”, “green”, “blue”, “indigo”, “violet”)  $rainbow[0] holds “red”  $rainbow[1] holds “orange”
  • 20. Operators • Arithmetic ▫ +, -, *, / (add, subtract, multiply, divide) • Assignment ▫ = (“Assign the value of 4 to the variable called a”)  $a = 4; ▫ += (“Add the value of 5 to the variable that already holds 4”)  $a += 5; // $a now holds 9 ▫ .= (“Attach the value „World‟ to the end of „Hello‟ to make a new value for the string variable”)  $string = “Hello”;  $string .= “World”; // would print “HelloWorld” (no space because we didn‟t add that!)
  • 21. Operators • Comparison ▫ == (“when I compare the value in variable a to the value in variable be, that comparison is true”)  $a == $b ▫ != (“when I compare the value in variable a to the value in variable be, that comparison is not true”)  $a != $b ▫ >, >= (“the value of variable a is greater than (or greater than or equal to) the value of variable b”)  $a > $b ▫ <, <= (“the value of variable a is less than (or less than or equal to) the value of variable b”)  $a < b
  • 22. Operators • Concatenation • + (string + string = stringstring) • Logical • && (and) • || (or) • ! (not)
  • 23. Flow Control • if if (something is true) { do something here } • if ... else ... else if if (something is true) { do something here } else if (something is true) { do something here } else { do something here }
  • 24. Flow Control • while while (something is true) { do something here } • for for (something is true) { do something here }
  • 25. Procedures and Functions • Scripts can contain linear, procedural code. • Scripts can also contain references to reusable bits of code, called functions. ▫ Built-in language functions ▫ Functions you write yourself.
  • 26.
  • 27. Why Python? • It is a general-purpose language • It has been around for a long time (20+ years) • It has a strong developer community • It includes a large built-in library of functionality • It is readable • It is expressive (you can do a lot with a little)
  • 28. Uncluttered Layout • Less punctuation ▫ While some languages use $ to indicate variables, or brackets around logical constructs, Python does not. • More whitespace ▫ Instead of brackets to set off blocks, indentation means something in Python.
  • 29. Variables in Python • Do not begin with a symbol and do not end with terminating punctuation. • Examples: ▫ string_variable = “The Library” ▫ numeric_variable= 4 ▫ myname = “Julie”
  • 30. Set and Print Variables # set up the variables string_variable = "The Library"; numeric_variable = 4; myname = "Julie"; # print the variables print string_variable print numeric_variable print myname
  • 31. Arrays in Python • …are called lists. • Example: ▫ rainbow = [“red”, “orange”, “yellow”, “green”, “blue”, “indigo”, “violet”]  print rainbow[0] shows “red”  print rainbow[1] shows “orange”
  • 32. Operators in Python (are not terribly special) • Arithmetic ▫ +, -, *, / • Assignment ▫ = ▫ +=, -=, *=, /= • Comparison ▫ >, <, >=, <= • Logical ▫ and, or, not
  • 33. Flow Control in Python • if if something is true: INDENT and do something here # here’s an example people = 20 space_aliens = 30 if people < space_aliens: print "Oh no! The world is doomed" if people > space_aliens: print "We're cool."
  • 34. Flow Control • if ... elif ... else if something is true: INDENT and do something here elif something is true: INDENT and do something here else: INDENT and do something here
  • 35. Flow Control • EXAMPLE people = 30 cars = 40 if cars > people: print "We should take the cars." elif cars < people: print "We should not take the cars." else: print "We can't decide."
  • 36. Flow Control • while while something is true: INDENT and do something here # here’s an example count = 0 while (count < 9): print 'The count is:', count count = count + 1 print "...and we're done!"
  • 37. Flow Control The count is: 0 The count is: 1 The count is: 2 The count is: 3 The count is: 4 The count is: 5 The count is: 6 The count is: 7 The count is: 8 ...and we're done!
  • 38. Flow Control • for for there are things in a sequence: INDENT and do something here #here’s an example rainbow = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"] for color in rainbow: print color
  • 40. Functions in Python • Start with the keyword def • Accepts parameters • There‟s indentation • You get something in return
  • 41. Functions in Python def fibonacci(n): a, b = 0, 1 while a < n: print a, a, b = b, a+b fibonacci(1000) ///////////////////////////////////////////////// 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
  • 42. So How Does Your Group Use Python? • As batch scripts, with or without a web interface ▫ One-offs, utilities, etc • Using a Web Framework (Django) ▫ Frameworks allow you to write web applications quickly because they include, well, a framework for doing so.  Reusable libraries common to web applications  Coding standards  Template and templating processes
  • 43. Sample Utility (pymarc) • For manipulation of MARC records ▫ In GitHub at https://github.com/edsu/pymarc/ ▫ From command-line or wrapped within an app • Example 1: from pymarc import MARCReader reader = MARCReader(open('marc.txt')) for record in reader: print record['245']['a']
  • 44. Sample Utility (pymarc) • Example 2: from pymarc import Record, Field record = Record() record.addField( Field( tag = '245', indicators = ['0','1'], subfields = [ 'a', 'The pragmatic programmer : ', 'b', 'from journeyman to master /', 'c', 'Andrew Hunt, David Thomas.' ])) out = open('file.dat', 'w') out.write(record.asMARC21()) out.close()
  • 45. Launchpad • Works within a Django framework • Has a directory structure you can follow to find how things are pieced together • Even in a framework, it is still readable code
  • 46. Launchpad (example from a template) {% extends "base.html" %} {% load launchpad_extras %} {% block title %}{{ bib.TITLE }}{% endblock title %} … {% if bib.ISBN|clean_isbn %} ISBN: <a href='{% url isbn bib.ISBN|clean_isbn %}'>{% url isbn bib.ISBN|clean_isbn %}</a> {% endif %}
  • 47. Launchpad (example from a template) def clean_isbn(value): isbn,sep,remainder = value.strip().partition('') if len(isbn) < 10: return '' isbn = isbn.replace('-', '') isbn = isbn.replace(':', '') return isbn
  • 48.
  • 49. Additional Resources • Learn Python the Hard Way ▫ http://learnpythonthehardway.org/book/ • The Python Tutorial ▫ http://docs.python.org/tutorial/index.html • Django ▫ https://www.djangoproject.com/ • GWU Libraries GitHub repositories ▫ https://github.com/gwu-libraries/