Test First Teaching and the path to TDDSarah Allen
Test First Teaching background and methodology for teaching programming using automated test frameworks, how this relates to (and can lead to learning) test-driven development
Fast as C: How to Write Really Terrible JavaCharles Nutter
For years we’ve been told that the JVM’s amazing optimizers can take your running code and make it “fast” or “as fast as C++” or “as fast as C”…or sometimes “faster than C”. And yet we don’t often see this happen in practice, due in large part to (good and bad) development patterns that have taken hold in the Java world.
In this talk, we’ll explore the main reasons why Java code rarely runs as fast as C or C++ and how you can write really bad Java code that the JVM will do a better job of optimizing. We’ll take some popular microbenchmarks and burn them to the ground, monitoring JIT logs and assembly dumps along the way.
Everything is Permitted: Extending Built-insAndrew Dupont
Adding methods to built-in objects: it’s one of JavaScript’s most powerful features. It’s also a great way to offend the sensibilities of your colleagues. We all hear that it’s irresponsible, that it’s sloppy, that it’s flat-out bad practice and should be avoided.
I’m tired of this one-sided battle. In this talk, I’m going to push back against whatever blog post you read that told you that extending built-ins was unconditionally and universally bad. I’m gonna go all Howard Beale on your asses.
Test First Teaching and the path to TDDSarah Allen
Test First Teaching background and methodology for teaching programming using automated test frameworks, how this relates to (and can lead to learning) test-driven development
Fast as C: How to Write Really Terrible JavaCharles Nutter
For years we’ve been told that the JVM’s amazing optimizers can take your running code and make it “fast” or “as fast as C++” or “as fast as C”…or sometimes “faster than C”. And yet we don’t often see this happen in practice, due in large part to (good and bad) development patterns that have taken hold in the Java world.
In this talk, we’ll explore the main reasons why Java code rarely runs as fast as C or C++ and how you can write really bad Java code that the JVM will do a better job of optimizing. We’ll take some popular microbenchmarks and burn them to the ground, monitoring JIT logs and assembly dumps along the way.
Everything is Permitted: Extending Built-insAndrew Dupont
Adding methods to built-in objects: it’s one of JavaScript’s most powerful features. It’s also a great way to offend the sensibilities of your colleagues. We all hear that it’s irresponsible, that it’s sloppy, that it’s flat-out bad practice and should be avoided.
I’m tired of this one-sided battle. In this talk, I’m going to push back against whatever blog post you read that told you that extending built-ins was unconditionally and universally bad. I’m gonna go all Howard Beale on your asses.
“PostgreSQL, Python and Squid” (otherwise known as, “using Python in PostgreSQL and PostgreSQL from Python”) presented at PyPgDay 2013 at PyCon 2013-Christophe Pettus
JRuby 9000 introduced a new intermediate representation that allows us to use classic compiler strategies to optimize Ruby. This talk describes what we're doing with this new IR and why current JVM capabilities are not sufficient.
Understanding bytecode and what bytecode is likely to be generated by a Java compiler helps the Java programmer in the same way that knowledge of assembler helps the C or C++ programmer. Java bytecode is the form of instructions that Java virtual machine executes. This knowledge is crucial when debugging and doing performance and memory usage tuning. The presenter will share his knowledge on what bytecode means for your platform and how to create compiler while using some awesome tools.
It's happened to all of us: we ran away from some conversation or library because it kept on using those "weird" phrases. You know, like "type classes", "semigroups", "monoids", "applicatives". Yikes! They all seem so academic, so pointlessly detached from real-world problems. But then again, given how frequently we run into them in functional programming, are they REALLY irrelevant, or do they have real-world applications? This talk will go beyond giving you raw definitions of these terms, and show you real-world motivations behind the concepts. By attending, you'll be able to keep your skills relevant to an ever-changing industry, confuse your significant other ("You know, honey, a monad is just a monoid in the category of endofunctors!"), and sound extra smart on the next job interview!
Slides from Ajax Experience 2009. In this session:
- Object creation patterns
- Code reuse patterns
- Functional patterns
- More on object creation
- Design patterns
Some example patterns: object creation with literals and constructos, prototypes, inheritance and other code reuse patterns, lazy definition, callbacks, singleton, factory, classical and prototypal inheritance, namespaces, chaining, modules, static methods, private and privileged members
For more information, see:
http://jspatterns.com
My column in the JavaScript Magazine (http://jsmag.com)
Blog: http://phpied.com
“PostgreSQL, Python and Squid” (otherwise known as, “using Python in PostgreSQL and PostgreSQL from Python”) presented at PyPgDay 2013 at PyCon 2013-Christophe Pettus
JRuby 9000 introduced a new intermediate representation that allows us to use classic compiler strategies to optimize Ruby. This talk describes what we're doing with this new IR and why current JVM capabilities are not sufficient.
Understanding bytecode and what bytecode is likely to be generated by a Java compiler helps the Java programmer in the same way that knowledge of assembler helps the C or C++ programmer. Java bytecode is the form of instructions that Java virtual machine executes. This knowledge is crucial when debugging and doing performance and memory usage tuning. The presenter will share his knowledge on what bytecode means for your platform and how to create compiler while using some awesome tools.
It's happened to all of us: we ran away from some conversation or library because it kept on using those "weird" phrases. You know, like "type classes", "semigroups", "monoids", "applicatives". Yikes! They all seem so academic, so pointlessly detached from real-world problems. But then again, given how frequently we run into them in functional programming, are they REALLY irrelevant, or do they have real-world applications? This talk will go beyond giving you raw definitions of these terms, and show you real-world motivations behind the concepts. By attending, you'll be able to keep your skills relevant to an ever-changing industry, confuse your significant other ("You know, honey, a monad is just a monoid in the category of endofunctors!"), and sound extra smart on the next job interview!
Slides from Ajax Experience 2009. In this session:
- Object creation patterns
- Code reuse patterns
- Functional patterns
- More on object creation
- Design patterns
Some example patterns: object creation with literals and constructos, prototypes, inheritance and other code reuse patterns, lazy definition, callbacks, singleton, factory, classical and prototypal inheritance, namespaces, chaining, modules, static methods, private and privileged members
For more information, see:
http://jspatterns.com
My column in the JavaScript Magazine (http://jsmag.com)
Blog: http://phpied.com
Internet security: a landscape of unintended consequencesSarah Allen
Increasingly, software is connected to the internet. How do we design software that will do what it was designed to do without making humans and connected systems vulnerable?
Sarah Allen shares lessons learned from Shockwave and Flash, and the kinds of modern exploits that ought to keep you up at night, along with both modern and time-tested techniques that every developer should know.
Code Mesh LDN 2019
RTMP: how did we get to now? (Demuxed 2019)Sarah Allen
RTMP: web video innovation or Web 1.0 hack… how did we get to now? (Demuxed 2019)
One of the creators of RTMP will take you back to a time before Firefox, Safari, and Chrome, when Internet Explorer was used by the majority of people on the Web, and over 98% of browsers had Flash installed. RTMP was first prototyped in late 2000 and released in July 2002. Sarah Allen shares the untold story of the origins of this protocol — careful design choices and unexpected hacks that led to a de-facto standard that still drives the majority of live web video today.
Rocky Mountain Ruby 9/30/2016
I share stories and examples from open source, business and community organizing: how communication about what we do is as important as the work itself. I'll also dive into coding as communication with an example of good API design highlighting the expressiveness of the Ruby language.
Feb 2016, Government Transformation conference
Sarah will tell the story about how innovation was inspired at the Federal Government. She will explore what 18F is and how this internal digital agency was formed within government. She will highlight a specific project that has been incredibly successful at encouraging collaboration between federal government employees from different agencies around task sharing. Sarah will also discuss how Open Source software is used by 18F and what impact that has had.
Transparency is a powerful means of making change. Open source increases the speed of software development and leads to higher quality code. These patterns of how we make software are changing how we do business and how our governments work. These aren’t just patterns of how we write code; these are patterns of how we interact with each other, teach and learn new skills, and experiment with new ideas. When we make our work visible, we expand its potential, and increase the chances of dramatic, unexpected impact.
Ruby Conf Taiwan, Sept 12, 2015
July 2015, Brighton Ruby
Sarah Allen introduces some theories of play and how to apply these and other ideas from games to making other kinds of software fun, and then how our work can be influenced by ideas of play.
Sarah Allen, Magma Conf 2015
This talk explores power of transparency to create with higher quality at lower cost, looking at open source community process, code and documentation, as well as lean startup open business, customer, and product development processes.
Sarah Allen, Mightyverse @mightyverse, AltConf, June 2015
Making your app fun to use requires more than sprinkling a little gamification on top. It requires thoughtful imagination and experimentation. In this talk, I highlight some expert perspectives on theories of play and behavioral psychology, and and how we can apply these ideas in mobile app design. I also share prototyping techniques and how to validate whether a design will actually be fun.
Ruby in the US Government for Ruby World ConferenceSarah Allen
In the United States, Ruby is a common technology choice for startups and is also gaining popularity in large companies. In contrast, Ruby is rarely used for US Government projects. Why do startups favor Ruby while the government makes other choices?
I have been both a startup founder and government employee. After developing a Ruby on Rails web app for my startup Mightyverse from 2009, I worked as a Presidential Innovation Fellow within the Obama administration. I will discuss work in both spheres, and highlight the common themes in the development process.
Playing is simple, even a child can do it, but designing something simple is hard. How can we combine prototyping with production software to get our ideas in front of real people? How can we evolve our software over time? How do we measure if something is fun?
I will talk about how Ruby’s flexibility and a strong testing ethos can bring some sanity to this uncertain world. And when I say testing, I’m not just talking about RSpec, Cucumber or Capybara, I’ll share stories from Mightyverse about how we test whether our software actually “works” for the people who use it — sharing failures, I mean, learning, as well as success.
I love Ruby, but last year I found myself at the Smithsonian Institution coding in, of all things, PHP & Drupal. And I realized that despite my ambivalence towards those technologies, I had no compelling-enough reason to propose Ruby as an alternative. How did we get to this point? I’ll tell 3 reasons we didn't use Ruby, and reflect on whether these are things we want, or problems we should solve.
Sarah Allen talks about her experience as a Presidential Innovation Fellow at the Smithsonian, then poses the question: why was Drupal a good fit for her project, and how did Ruby and Rails fall short?
This is a review of the Transcription projects outside of the Smithsonian. This presentation is not comprehensive. It focuses on looking at the breath of user experience choices for engaging with volunteers.
An overview of video for the mobile web with a "lean startup" case study about how supporting web video on mobile had both expected and unexpected positive effects on Mightyverse metrics.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
2. Why should you care?
• you want to learn Ruby
• you want to improve your Ruby skills
• you have a friend or colleague who wants to
learn Ruby
• you want to help us improve our materials
• by teaching, you learn...
3. No, seriously:
by teaching, you learn!
• the best engineers are good teachers
• we live and work in collaborative
environments
• it is not enough to know any thing well
• we must teach in order to effectively produce
software
4. What is
Test-First Teaching?
• teacher provides microtests
• student makes them pass
• one test at a time
• can be used guided (in classroom) or solo
• or with a pair
6. Pairing in the classroom
• students learn together and teach each other
• each pair can proceed through exercises at
their own pace
• teacher is freed to wander the room
7. How do we know it's a
good idea?
2002 Alex Chaffee
jGuru Java curriculum
2005 Mike Clark
many Ruby Learning Tests
independent 2006 ara.t.howard
inventors Ruby Quiz #67
"Metakoans"
2008 Yehuda Katz
& Matt Aimonetti
Ruby on Rails training
Who else?
http://www.flickr.com/photos/annais/9335897/sizes/z/
9. Learning Ruby via Tests
• [Test-First Teaching](http://testfirst.org)
by Sarah Allen and Alex Chaffee
• [Ruby Koans](http://rubykoans.com)
by Jim Weirich and Joe O’Brien
• [Metakoans](http://rubyquiz.com/quiz67.html)
by ara.t.howard
10. Other Guided Learning
• [ruby-warrior](http://github.com/ryanb/ruby-warrior) by Ryan
Bates - a game written in Ruby for learning Ruby
• [Try Ruby](http://tryruby.org) runs a Ruby interpreter in your
browser, with hints and advice
• [Growing OO Software In Ruby](http://www.exampler.com/
blog/2009/12/17/growing-object-oriented-software-in-ruby/) by
Brian Marick
• Ruby version of [Growing Object-Oriented Software
Guided by Tests](http://www.growing-object-oriented-
software.com/)
11. Created by:
Sarah Allen
Alex Chaffee
Liah Hansen
and friends
Test-First Teaching....
http://testfirst.org
Maybe we should call it Test-First Learning
http://github.com/ultrasaurus/test-first-teaching
12. Traditional Professional
Programming Classes
Big, Boring Lecture
Followed by Exercises
• multiple choice
• fill in the blanks with words
or pseudocode
• skeleton code - big program
with chunks excised and
replaced with comments
• large task - soup to nuts
without feedback
.flickr.com/photos/chasephotography/3890300709/
14. Methodology
• Run the test
• Watch it fail
• Write code to fix the first failure
• See it pass
• Refactor
Sound familiar?
15.
16. Why TFT?
• makes the assignment very clear
• student gets immediate feedback on progress
(or lack thereof)
• removes the magic
• leads the student through all the steps to
writing the code
• teaches student to read errors
18. Embrace Failure
• start from a point of failure
• it feels like it's not your fault
• people learn better when they're not stressed
• playfulness enhances learning
19. In a classroom setting,
do more...
• Conceptual Overview
• Experimentation (Play, irb)
• Live Coding a Real-World Example
• Simple hands-on exercise
• Name what they learned
21. Arithmetic
require "calculator"
describe Calculator do
before do
@calculator = Calculator.new
end
it "adds 0 and 0" do
@calculator.add(0,0).should == 0
end
it "adds 2 and 2" do
@calculator.add(2,2).should == 4
end
it "adds positive numbers" do
@calculator.add(2,6).should == 8
end
it "subtracts numbers" do
@calculator.subtract(10,4).should == 6
end
end
22.
23. require "pig_latin"
describe "#translate" do
Strings
include PigLatinTranslator
it "should translate a simple word" do
s = translate("nix")
s.should == "ixnay"
end
it "should translate a word beginning with a vowel" do
s = translate("apple")
s.should == "appleay"
end
it "should translate a word with two consonants" do
s = translate("stupid")
s.should == "upidstay"
end
it "should translate two words" do
s = translate("eat pie")
s.should == "eatay iepay"
end
it "should translate many words" do
s = translate("the quick brown fox")
s.should == "ethay ickquay ownbray oxfay"
end
end
24. Pig Latin Solution
module PigLatinTranslator
def translate(s)
s.split.map do |word|
v = first_vowel(word)
word.slice(v..-1) + word[0,v] + "ay"
end.join(" ")
end
def first_vowel(word)
if word =~ /^qu/
2
else
word.gsub(/[aeiou].*$/, '').size
end
end
end
25. Another
Pig Latin Solution
module PigLatinTranslator
def translate(s)
words = s.split
s = words.map do |s|
l = s.length
if /^[aeiou]/ .match(s)
s + "ay"
elsif /^qu/ .match(s[0..1])
s[2..(l+1)] + s[0..1] + "ay"
elsif /[aeiou]/ .match(s[1..1])
s[1..(l+1)] + s[0..0] + "ay"
else
s[2..(l+1)] + s[0..1] + "ay"
end
end
s = s.join(" ")
end
end
26. And Another
Pig Latin Solution
module PigLatinTranslator
def translate(word)
words = word.split(" ")
arrResult = []
words.each do |word|
m = word.match(/^(qu)*[^aeiou]*/)
if(m.nil?)
arrResult << add_ay(word)
else
arrResult << add_ay(m.post_match + m.to_s)
end
end
arrResult.join(" ")
end
def add_ay(word)
word + "ay"
end
end
27. Iterators
describe Calculator do
before do
@calculator = Calculator.new
end
describe "#sum" do
it "computes the sum of an empty array" do
@calculator.sum([]).should == 0
end
it "computes the sum of an array of one number" do
@calculator.sum([7]).should == 7
end
it "computes the sum of an array of two numbers" do
@calculator.sum([7,11]).should == 18
end
it "computes the sum of an array of many numbers" do
@calculator.sum([1,3,5,7,9]).should == 25
end
end
28. Iterators
require "array_extension"
describe Array do
describe "#sum" do
it "should be 0 for an empty array" do
[].sum.should == 0
end
it "should add all of the elements" do
[1,2,4].sum.should == 7
end
end
end
(and open classes)
29. TDD Extra Credit!
# Test-Driving Bonus: once the above tests pass,
# write tests and code for the following:
it "multiplies two numbers"
it "multiplies an array of numbers"
it "raises one number to the power of another number"
# http://en.wikipedia.org/wiki/Factorial
describe "#factorial" do
it "computes the factorial of 0"
it "computes the factorial of 1"
it "computes the factorial of 2"
it "computes the factorial of 5"
it "computes the factorial of 10"
end
end
32. Blocks
require "performance_monitor"
(and mocks) it "takes exactly 1 second to run a block that
describe PerformanceMonitor do sleeps for 1 second (with stubs)" do
before do fake_time = 100
@monitor = PerformanceMonitor.new Time.stub!(:now).and_return {fake_time}
end @monitor.run do
fake_time += 1
it "takes about 0 seconds to run an empty block" do end.should == 1
@monitor.run do end
end.should be_close(0, 0.1)
end it "runs a block N times" do
n = 0
it "takes exactly 0 seconds to run an empty block @monitor.run(4) do
(with stubs)" do n += 1
Time.stub!(:now).and_return(100) end
@monitor.run do n.should == 4
end.should == 0 end
end
it "returns the average time, not the total time,
it "takes about 1 second to run a block that sleeps when running multiple times" do
for 1 second" do run_times = [8,6,5,7]
@monitor.run do run_index = 0
sleep 1 fake_time = 100
end.should be_close(1, 0.1) Time.stub(:now).and_return { fake_time }
end @monitor.run(4) do
fake_time += run_times[run_index]
run_index += 1
end.should == 6
end
end
33. method_missing, nested
closures, and the builder pattern
require "xml_document"
it "nests several levels" do
describe XmlDocument do @xml.hello do
before do @xml.goodbye do
@xml = XmlDocument.new @xml.come_back do
end @xml.ok_fine(:be => "that_way")
end
it "renders an empty tag" do end
@xml.hello.should == "<hello/>" end.should ==
end "<hello><goodbye><come_back><ok_fine be='that_way'/
></come_back></goodbye></hello>"
it "renders a tag with attributes" do end
@xml.hello(:name => 'dolly').should == "<hello
name='dolly'/>" it "indents" do
end @xml = XmlDocument.new(true)
@xml.hello do
it "renders a randomly named tag" do @xml.goodbye do
tag_name = (1..8).map{|i| @xml.come_back do
('a'..'z').to_a[rand(26)]}.join @xml.ok_fine(:be => "that_way")
@xml.send(tag_name).should == "<#{tag_name}/>" end
end end
end.should ==
it "renders block with text inside" do "<hello>n" +
@xml.hello do " <goodbye>n" +
"dolly" " <come_back>n" +
end.should == "<hello>dolly</hello>" " <ok_fine be='that_way'/>n" +
end " </come_back>n" +
" </goodbye>n" +
it "nests one level" do "</hello>n"
@xml.hello do end
@xml.goodbye end
end.should == "<hello><goodbye/></hello>"
end
34. threads
(sorry for the Java)
public void testThreadSafe() throws InterruptedException
{
int DEPOSITORS = 50;
int AMOUNT = 2;
// note: increase this value until it *fails* on your CPU.
// Then fix it.
int REPS = 25000;
Account account = new Account("Joe", 0);
Thread[] depositors = new Thread[DEPOSITORS];
for (int i=0; i< DEPOSITORS; ++i) {
depositors[i] = new Depositor(account, AMOUNT, REPS);
depositors[i].start();
}
for (int i=0; i< DEPOSITORS; ++i) {
depositors[i].join();
}
assertEquals(REPS * DEPOSITORS * AMOUNT, account.getBalance());
}
35. ruby koans
• self-guided, test-driven
• Ruby language basics
• very fun, whimsical and elegant
36. ruby koans example
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
class AboutStrings < EdgeCase::Koan
def test_double_quoted_strings_are_strings
string = "Hello, World"
usually self-
assert_equal __, string.is_a?(String)
end contained
def test_single_quoted_strings_are_also_strings
just tests and fixtures,
string = 'Goodbye, World' with no class declaration
assert_equal __, string.is_a?(String)
end
def test_use_single_quotes_to_create_string_with_double_quotes
“fill in the
string = 'He said, "Go Away."'
assert_equal __, string blanks”
end
technique
def test_use_double_quotes_to_create_strings_with_single_quotes
string = "Don't"
assert_equal __, string
end
teaching through
def test_use_backslash_for_those_hard_cases practice and
a = "He said, "Don't""
b = 'He said, "Don't"' challenge
assert_equal __, a == b
end
37. TFT != TDD
• Mechanics of testing are hard to learn
• TFT teaches programming; TDD is design
• At the end of some modules,
students write their own tests for “extra
credit”
• doesn’t really flex the creative muscles
required for software design
38. What about TDD?
• easier to learn TDD, post-TFT
• know the language
• know the test framework
• used to the rhythm of test-first
• study design patterns, or check out [GOOS]
(http://www.exampler.com/blog/2009/12/17/
growing-object-oriented-software-in-ruby).
39. Credits
• Mr. Clean® is a registered trademark of Procter &
Gamble, used without permission
• Parody is fair use!
• Fail Whale illustrated by Yiying Lu (http://
www.yiyinglu.com/)
• Pair Programming photos by Lee Lundrigan
• Thank you Flickr and Creative Commons
(see slides for attribution)