SlideShare a Scribd company logo
TDD
RED
 GREEN
REFACTOR
Effect?
More code
More simple code
More simple code,
 delivered faster
Cleaner
interfaces
Better
understanding
 of codebase
Fast & precise
  regression
   discovery
Easy
refactoring
Case
study
Things come together.




    Semantic social
collaboration platform
Things come together.


Python/Django
PostgreSQL
Apache Solr
Custom Java backend
RDF-based APIs

Graphs of linked data
URIs as identifiers
Subject-Predicate-Object
triples
<_:me>   <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
<_:me>   <http://xmlns.com/foaf/0.1/family_name> "Pasternacki" .
<_:me>   <http://xmlns.com/foaf/0.1/givenname> "Maciej" .
<_:me>   <http://xmlns.com/foaf/0.1/homepage> <http://www.pasternacki.net/> .
<_:me>   <http://xmlns.com/foaf/0.1/mbox> <mailto:maciej@pasternacki.net> .
<_:me>   <http://xmlns.com/foaf/0.1/name> "Maciej Pasternacki" .
<_:me>   <http://xmlns.com/foaf/0.1/nick> "japhy" .
<_:me>   <http://xmlns.com/foaf/0.1/workplaceHomepage> <http://www.gnowsis.com/> .




  @prefix : <#> .
  @prefix foaf: <http://xmlns.com/foaf/0.1/> .

  :me     a foaf:Person .
  :me     foaf:family_name "Pasternacki" .
  :me     foaf:givenname "Maciej" .
  :me     foaf:homepage <http://www.pasternacki.net/> .
  :me     foaf:mbox <mailto:maciej@pasternacki.net> .
  :me     foaf:name "Maciej Pasternacki" .
  :me     foaf:nick "japhy" .
  :me     foaf:workplaceHomepage <http://www.gnowsis.com/> .
Item                                  Relation
                              uuid : uuid                                    type : uri
                              rdf_type : URI                             *
                              label : string
                              created : dateTime
                              lastModified: dateTime                        Description
                                                                         text : string
                                 target (1)
                         Thing                 Annotation                      Rating
                                                                      value : normalizedFloat


                     InformationElement                                             Wiki
                                                                             text : string
                                                     Property
         File
                                               type : uri
path : string
                                               lexicalForm : string
mimeType : string
...                          Webpage
                        url : string
                        summary : string        StringProperty
      Email
  subject : string                             value : string
  ...                                               IntProperty
                                                  value : integer
         Blogpost                 Tweet               DatetimeProperty
 timestamp : dateTime        author : string          value : datetime
 author : string             text : string
 ...                         ...
def promote(self):
         if not hasattr(self, '_promoted'):
             if isinstance(self, self.get_class()):
                 self._promoted = self
             else:
                 self._promoted = getattr(
                     self, getattr( self.get_class(),
                                    self._root_class_name + '_ptr'
                                    ).field.related_query_name() )
         return self._promoted



SELECT … FROM "pim_annotation"
LEFT OUTER JOIN "pim_related"
ON ("pim_annotation"."id" = "pim_related"."annotation_ptr_id")
WHERE ( "pim_annotation"."thing_id" = E'∴'
        OR "pim_related"."related_to_id" = E'∴' )
ORDER BY "pim_annotation"."lastModified" DESC;
Test-driven development: a case study
NoSQL?
NoSQL?
“How FriendFeed
uses MySQL to store
 schema-less data”
-- http://bret.appspot.com/entry/how-friendfeed-uses-mysql
Use PostgreSQL
as RDF document-
oriented database
Single Thing class

Many concrete
Annotation classes

TEXT field `attributes’
for free-form RDF
No JOINs
Rules

Keep existing code
(when possible)

Keep existing behaviour
Keep magic localized
I. New code


RDFField & URIRefField using
rdflib
Customized RDF serialization
II. Analysis

Extract existing schema from
model code
Declare schema in RDF
Glue code for attribute access to
RDF data
nfo:Bookmark rdfs:subClassOf pimo:Thing ;
             grfs:className "Bookmark" ;
             grfs:label "nfo:Bookmark" ;
             grfs:pluralLabel "nfo:Bookmarks" ;
             grfs:isGuiCreatable "true"^^xsd:boolean ;
             grfs:labelProperties ( dct:title rdfs:label nfo:bookmarks ) ;
             grfs:shortSummaryInfoProperties ( nfo:bookmarks ) .

nao:description a rdfs:Property ;
           rdfs:domain pimo:Thing, pimo:Person, pimo:Event, nfo:Bookmark,
pimo:Project, pimo:Person, nfo:FileDataObject, pimo:Topic, pimo:Location,
pimo:Task, nmo:Email, pimo:Question, pimo:Organization, pimo:Note,
pimo:Collection;
           grfs:attributeName "description" ;
           grfs:ftsFullText "true"^^xsd:boolean ;
           grfs:additionalShortSummaryInfo "false"^^xsd:boolean .

nfo:bookmarks a rdfs:Property ;
              rdfs:domain nfo:Bookmark ;
              grfs:attributeName "bookmarks" ;
              grfs:ftsFullText "true"^^xsd:boolean ;
              grfs:additionalShortSummaryInfo "true"^^xsd:boolean .
SELF_URI = URIRef('self:#')
def __getattr__(self, attr):
    property_uri = attribute_uri(attr)
    oo = list(self.attributes.objects(
                self.SELF_URI,
                property_uri))
    if not oo:
        raise AttributeError(attr)
    if len(oo) == 1:
        return oo[0].toPython()
    return set([o.toPython() for o in oo])
III. Details

Run test suite
Find most common error
Adapt test or change code
Repeat for three weeks
IV. Tweaking


Data migration
Refactor APIs
Optimize
Success!
Things come together.


http://www.getrefinder.com/

More Related Content

PDF
One BSON to Rule Them
David Golden
 
PDF
Apache AVRO (Boston HUG, Jan 19, 2010)
Cloudera, Inc.
 
KEY
T3dallas typoscript
zdavis
 
PPTX
MongoDB Advanced Schema Design - Inboxes
Jared Rosoff
 
PPT
Schema design short
MongoDB
 
PPTX
SWT Lecture Session 2 - RDF
Mariano Rodriguez-Muro
 
PPT
Reversing JavaScript
Roberto Suggi Liverani
 
PDF
Jsonsaga 100605143125-phpapp02
Ramamohan Chokkam
 
One BSON to Rule Them
David Golden
 
Apache AVRO (Boston HUG, Jan 19, 2010)
Cloudera, Inc.
 
T3dallas typoscript
zdavis
 
MongoDB Advanced Schema Design - Inboxes
Jared Rosoff
 
Schema design short
MongoDB
 
SWT Lecture Session 2 - RDF
Mariano Rodriguez-Muro
 
Reversing JavaScript
Roberto Suggi Liverani
 
Jsonsaga 100605143125-phpapp02
Ramamohan Chokkam
 

What's hot (12)

PPTX
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
MongoDB
 
PDF
Euroscipy SemNews 2011
Logilab
 
PPTX
Data Modeling for the Real World
Mike Friedman
 
PPT
J s-o-n-120219575328402-3
Ramamohan Chokkam
 
PDF
Mongo DB schema design patterns
joergreichert
 
PPT
Building web applications with mongo db presentation
Murat Çakal
 
PPTX
SWT Lecture Session 8 - Rules
Mariano Rodriguez-Muro
 
KEY
Schema Design with MongoDB
rogerbodamer
 
KEY
Schema Design by Example ~ MongoSF 2012
hungarianhc
 
PDF
Elastic search 검색
HyeonSeok Choi
 
PPTX
RDF data validation 2017 SHACL
Jean-Paul Calbimonte
 
PPTX
Data Modeling Deep Dive
MongoDB
 
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
MongoDB
 
Euroscipy SemNews 2011
Logilab
 
Data Modeling for the Real World
Mike Friedman
 
J s-o-n-120219575328402-3
Ramamohan Chokkam
 
Mongo DB schema design patterns
joergreichert
 
Building web applications with mongo db presentation
Murat Çakal
 
SWT Lecture Session 8 - Rules
Mariano Rodriguez-Muro
 
Schema Design with MongoDB
rogerbodamer
 
Schema Design by Example ~ MongoSF 2012
hungarianhc
 
Elastic search 검색
HyeonSeok Choi
 
RDF data validation 2017 SHACL
Jean-Paul Calbimonte
 
Data Modeling Deep Dive
MongoDB
 
Ad

Similar to Test-driven development: a case study (20)

PDF
Transition from relational to NoSQL Philly DAMA Day
Dipti Borkar
 
PDF
Navigating the Transition from relational to NoSQL - CloudCon Expo 2012
Dipti Borkar
 
PDF
Introduction to NoSQL and Couchbase
Dipti Borkar
 
PDF
The LEMO Annotation Framework
Bernhard Haslhofer
 
PDF
SPARQL and the Open Linked Data initiative
Fulvio Corno
 
PDF
DataMapper
Yehuda Katz
 
PDF
Alfresco Custom Model
Andrea Leo
 
PDF
Couchbase Korea User Group 2nd Meetup #2
won min jang
 
PDF
Mysql to mongo
Alex Sharp
 
PDF
Going beyond Django ORM limitations with Postgres
Craig Kerstiens
 
PDF
To infinity and beyond
clintongormley
 
PPTX
Java and Mongo
Marcio Mangar
 
KEY
Linked data: spreading data over the web
shellac
 
PDF
NoSQL @ CodeMash 2010
Ben Scofield
 
PDF
George Thiruvathukal, User Experiences with Plone Content Management
webcontent2007
 
KEY
Refactor like a boss
gsterndale
 
PDF
CouchDB
King Huang
 
PDF
Sfmodelsecondpartrefcard
Maksim Kotlyar
 
PDF
The DataTank: an Open Data adapter with semantic output
Miel Vander Sande
 
Transition from relational to NoSQL Philly DAMA Day
Dipti Borkar
 
Navigating the Transition from relational to NoSQL - CloudCon Expo 2012
Dipti Borkar
 
Introduction to NoSQL and Couchbase
Dipti Borkar
 
The LEMO Annotation Framework
Bernhard Haslhofer
 
SPARQL and the Open Linked Data initiative
Fulvio Corno
 
DataMapper
Yehuda Katz
 
Alfresco Custom Model
Andrea Leo
 
Couchbase Korea User Group 2nd Meetup #2
won min jang
 
Mysql to mongo
Alex Sharp
 
Going beyond Django ORM limitations with Postgres
Craig Kerstiens
 
To infinity and beyond
clintongormley
 
Java and Mongo
Marcio Mangar
 
Linked data: spreading data over the web
shellac
 
NoSQL @ CodeMash 2010
Ben Scofield
 
George Thiruvathukal, User Experiences with Plone Content Management
webcontent2007
 
Refactor like a boss
gsterndale
 
CouchDB
King Huang
 
Sfmodelsecondpartrefcard
Maksim Kotlyar
 
The DataTank: an Open Data adapter with semantic output
Miel Vander Sande
 
Ad

More from Maciej Pasternacki (6)

PDF
A Continuous Packaging Pipeline
Maciej Pasternacki
 
KEY
Odin Authenticator
Maciej Pasternacki
 
KEY
Why do we fail? (And how do we stop doing that?
Maciej Pasternacki
 
KEY
Monitoringsucks
Maciej Pasternacki
 
KEY
Amazon Web Services (cloud: is it good for anything?)
Maciej Pasternacki
 
PDF
Devops lightning talk
Maciej Pasternacki
 
A Continuous Packaging Pipeline
Maciej Pasternacki
 
Odin Authenticator
Maciej Pasternacki
 
Why do we fail? (And how do we stop doing that?
Maciej Pasternacki
 
Monitoringsucks
Maciej Pasternacki
 
Amazon Web Services (cloud: is it good for anything?)
Maciej Pasternacki
 
Devops lightning talk
Maciej Pasternacki
 

Recently uploaded (20)

PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Doc9.....................................
SofiaCollazos
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 

Test-driven development: a case study

  • 1. TDD
  • 6. More simple code, delivered faster
  • 9. Fast & precise regression discovery
  • 12. Things come together. Semantic social collaboration platform
  • 14. RDF-based APIs Graphs of linked data URIs as identifiers Subject-Predicate-Object triples
  • 15. <_:me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . <_:me> <http://xmlns.com/foaf/0.1/family_name> "Pasternacki" . <_:me> <http://xmlns.com/foaf/0.1/givenname> "Maciej" . <_:me> <http://xmlns.com/foaf/0.1/homepage> <http://www.pasternacki.net/> . <_:me> <http://xmlns.com/foaf/0.1/mbox> <mailto:[email protected]> . <_:me> <http://xmlns.com/foaf/0.1/name> "Maciej Pasternacki" . <_:me> <http://xmlns.com/foaf/0.1/nick> "japhy" . <_:me> <http://xmlns.com/foaf/0.1/workplaceHomepage> <http://www.gnowsis.com/> . @prefix : <#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . :me a foaf:Person . :me foaf:family_name "Pasternacki" . :me foaf:givenname "Maciej" . :me foaf:homepage <http://www.pasternacki.net/> . :me foaf:mbox <mailto:[email protected]> . :me foaf:name "Maciej Pasternacki" . :me foaf:nick "japhy" . :me foaf:workplaceHomepage <http://www.gnowsis.com/> .
  • 16. Item Relation uuid : uuid type : uri rdf_type : URI * label : string created : dateTime lastModified: dateTime Description text : string target (1) Thing Annotation Rating value : normalizedFloat InformationElement Wiki text : string Property File type : uri path : string lexicalForm : string mimeType : string ... Webpage url : string summary : string StringProperty Email subject : string value : string ... IntProperty value : integer Blogpost Tweet DatetimeProperty timestamp : dateTime author : string value : datetime author : string text : string ... ...
  • 17. def promote(self): if not hasattr(self, '_promoted'): if isinstance(self, self.get_class()): self._promoted = self else: self._promoted = getattr( self, getattr( self.get_class(), self._root_class_name + '_ptr' ).field.related_query_name() ) return self._promoted SELECT … FROM "pim_annotation" LEFT OUTER JOIN "pim_related" ON ("pim_annotation"."id" = "pim_related"."annotation_ptr_id") WHERE ( "pim_annotation"."thing_id" = E'∴' OR "pim_related"."related_to_id" = E'∴' ) ORDER BY "pim_annotation"."lastModified" DESC;
  • 21. “How FriendFeed uses MySQL to store schema-less data” -- http://bret.appspot.com/entry/how-friendfeed-uses-mysql
  • 22. Use PostgreSQL as RDF document- oriented database
  • 23. Single Thing class Many concrete Annotation classes TEXT field `attributes’ for free-form RDF
  • 25. Rules Keep existing code (when possible) Keep existing behaviour Keep magic localized
  • 26. I. New code RDFField & URIRefField using rdflib Customized RDF serialization
  • 27. II. Analysis Extract existing schema from model code Declare schema in RDF Glue code for attribute access to RDF data
  • 28. nfo:Bookmark rdfs:subClassOf pimo:Thing ; grfs:className "Bookmark" ; grfs:label "nfo:Bookmark" ; grfs:pluralLabel "nfo:Bookmarks" ; grfs:isGuiCreatable "true"^^xsd:boolean ; grfs:labelProperties ( dct:title rdfs:label nfo:bookmarks ) ; grfs:shortSummaryInfoProperties ( nfo:bookmarks ) . nao:description a rdfs:Property ; rdfs:domain pimo:Thing, pimo:Person, pimo:Event, nfo:Bookmark, pimo:Project, pimo:Person, nfo:FileDataObject, pimo:Topic, pimo:Location, pimo:Task, nmo:Email, pimo:Question, pimo:Organization, pimo:Note, pimo:Collection; grfs:attributeName "description" ; grfs:ftsFullText "true"^^xsd:boolean ; grfs:additionalShortSummaryInfo "false"^^xsd:boolean . nfo:bookmarks a rdfs:Property ; rdfs:domain nfo:Bookmark ; grfs:attributeName "bookmarks" ; grfs:ftsFullText "true"^^xsd:boolean ; grfs:additionalShortSummaryInfo "true"^^xsd:boolean .
  • 29. SELF_URI = URIRef('self:#') def __getattr__(self, attr): property_uri = attribute_uri(attr) oo = list(self.attributes.objects( self.SELF_URI, property_uri)) if not oo: raise AttributeError(attr) if len(oo) == 1: return oo[0].toPython() return set([o.toPython() for o in oo])
  • 30. III. Details Run test suite Find most common error Adapt test or change code Repeat for three weeks

Editor's Notes