SlideShare une entreprise Scribd logo
1  sur  49
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/

Contenu connexe

Tendances

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 2014Christian Lilley
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structureselliando dias
 
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 ServicesIoan Toma
 
CPP02 - The Structure of a Program
CPP02 - The Structure of a ProgramCPP02 - The Structure of a Program
CPP02 - The Structure of a ProgramMichael 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 jQuerycolinbdclark
 
Easy javascript
Easy javascriptEasy javascript
Easy javascriptBui Kiet
 
JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript WorkshopPamela Fox
 
JavaScript!
JavaScript!JavaScript!
JavaScript!RTigger
 
JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery BasicsKaloyan Kosev
 
Getting Started with Web
Getting Started with WebGetting Started with Web
Getting Started with WebAkshay Mathur
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery EssentialsMark Rackley
 
Php melb cqrs-ddd-predaddy
Php melb cqrs-ddd-predaddyPhp melb cqrs-ddd-predaddy
Php melb cqrs-ddd-predaddyDouglas Reith
 
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: PoCjimfuller2009
 
Perl Teach-In (part 2)
Perl Teach-In (part 2)Perl Teach-In (part 2)
Perl Teach-In (part 2)Dave Cross
 

Tendances (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
 

Similaire à 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 BlocksCate Huston
 
James Coplien - Trygve - October 17, 2016
James Coplien - Trygve - October 17, 2016James Coplien - Trygve - October 17, 2016
James Coplien - Trygve - October 17, 2016Foo 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 ProcessingCate 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.pptxHaythamBarakeh1
 
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 BDDRodrigo Urubatan
 
Agile Data: Building Hadoop Analytics Applications
Agile Data: Building Hadoop Analytics ApplicationsAgile Data: Building Hadoop Analytics Applications
Agile Data: Building Hadoop Analytics ApplicationsDataWorks 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 2014The Hive
 
Data weave 2.0 language fundamentals
Data weave 2.0 language fundamentalsData weave 2.0 language fundamentals
Data weave 2.0 language fundamentalsManjuKumara 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 lifeDavide Mauri
 
Test First Teaching
Test First TeachingTest First Teaching
Test First TeachingSarah 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 2018Mike 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 islandAngela 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 2019Hannes Lowette
 

Similaire à 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
 

Plus de 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 ReleaseJulie 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 CodeJulie Meloni
 
Community, Cohesion, and Commitment
Community, Cohesion, and CommitmentCommunity, Cohesion, and Commitment
Community, Cohesion, and CommitmentJulie 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 ProgramsJulie 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
 
Entering the Conversation
Entering the ConversationEntering the Conversation
Entering the ConversationJulie Meloni
 
Mavericks: The Ultra-Collaborative Composition Classroom
Mavericks: The Ultra-Collaborative Composition ClassroomMavericks: The Ultra-Collaborative Composition Classroom
Mavericks: The Ultra-Collaborative Composition ClassroomJulie Meloni
 

Plus de 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
 

Dernier

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 

Dernier (20)

DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 

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/