SlideShare a Scribd company logo
Programming Production Code
 as if writing Natural Language




      Kazuya NUMATA
         @kaznum
Self-introduction
                        (Kazuya NUMATA)
  •
  •                          �


  •
  •
  •
      ���������������


  •
My favorite


•
    •
    •
Agile
Communication with team members
     including stakeholder
                &
        Iterative Testing
Behavior Driven Development
             BDD
Tools
to make BDD effective
•   RSpec (Ruby)

•   NSpec (.NET)

•   CppSpec (C++)

•   JBehave (Java)

•   instinct (Java)

•   PHPSpec (PHP)

•   and more....
Question
Question




   Have you ever experienced *Spec?


*Spec                                 ?
RSpec example:



describe "A new chess board" do

   before(:each) do
     @board = Chess::Board.new
   end

   it "should have 32 pieces" do
     @board.should have(32).pieces
   end

end
                               D. Chelimsky. The RSpec Book
                          Section 13.7 Generated Descriptions
RSpec example:



describe "A new chess board" do

   before(:each) do
     @board = Chess::Board.new
   end

   it "should have 32 pieces" do
     @board.should have(32).pieces
   end

end
                               D. Chelimsky. The RSpec Book
                          Section 13.7 Generated Descriptions
RSpec example:



$ rspec -fd board_spec.rb

(Output is...)

A new chess board
  should have 32 pieces

                       D. Chelimsky. The RSpec Book
                  Section 13.7 Generated Descriptions
It is just Natural Language!
�
The reality is that it’s hard for the Japanese.
Cucumber

(              )
Cucumber Example:


         :

         :


         "           "    "                 "
         "       "   "        Cucumber"
         "       "
             "           Cucumber"

                                                                   ( ∀ )o   sasata299's blog
                                     http://blog.livedoor.jp/sasata299/archives/51278697.html
/Spec




Before
 BDD


After    Spec    Spec
BDD
Before
 BDD


After
BDD
?
Uncle Bob

   Complex fulcrumPoint = Complex.FromRealNumber(23.0);

is generally better than

   Complex fulcrumPoint = new Complex(23.0);

Consider enforcing their use by making the corresponding constructors private.



                           (   )
by Masayoshi Son
Person
         name
                        true
                false
Ruby Example:   name   1

ex1


class Person
  attr_accessor :name
  def initialize(name = nil)
    @name = name
  end
end

shimada = Person.new(“Shimada”)
if shimada.name.split(//)[0] == “S”
  puts “Match”
end
Ruby Example: name   1

ex2


class Person
  attr_accessor :name
  def initialize(name = nil)
    @name = name
  end

  def has_a_name_that_begins_with?(expected)
    @name.split(//)[0] == expected
  end
end

shimada = Person.new(“Shimada”)
if shimada.has_a_name_that_begins_with?(“S”)
  puts “Match”
end
Ruby Example: name    1

ex3

class Person
  attr_accessor :name
  def initialize(name = nil)
    @name = name
  end

  def has_a_name_that_begins_with?(expected)
    @name.split(//)[0] == expected
  end

  def method_missing(m, *args, &block)
    if m.to_s =~ /has_(a|the)_name_(that|which)_begins_with?/
      has_a_name_that_begins_with?(args)
    else
      super
    end
  end
end

shimada = Person.new(“Shimada”)
puts “Match” if shimada.has_a_name_that_begins_with?(“S”)
puts “Match” if shimada.has_the_name_that_begins_with?(“S”)
puts “Match” if shimada.has_a_name_which_begins_with?(“S”)
puts “Match” if shimada.has_the_name_which_begins_with?(“S”)
Ruby Example: name                           1
ex4      name                                                                                     String
                                                                   has_(a|the)_(.+)_(which|that)_begins_with?
Dynamic                    setter
             undef                         Singleton Method
class Person
  def initialize(args)
    args.each do |key, value|
      self.class.send(:attr_accessor, :"#{key}") unless instance_variables.include?(:"@#{key}")
      instance_variable_set(:"@#{key}", value)
    end
  end

  def self.undef_has_a_var_which_begins_with(var)
    method_name = "has_a_#{var}_which_begins_with?"
    send("undef_method", method_name) if method_defined? method_name
  end

  def self.define_has_a_var_which_begins_with(var)
    method_name = "has_a_#{var}_which_begins_with?"
    define_method(method_name) do |expectation|
      value = instance_variable_get(:"@#{var}")
      if value.is_a?(String)
        value.split(//)[0].downcase == expectation.downcase
      else
        self.class.undef_has_a_var_which_begins_with(var)
        method_missing(method_name.to_sym)
      end
    end
  end

  def method_missing(m, *args, &block)
    if m.to_s =~ /has_(a|the)_(.+)_(which|that)_begins_with?/ &&
         instance_variables.include?(:"@#{Regexp.last_match[2]}") &&
         instance_variable_get(:"@#{Regexp.last_match[2]}").is_a?(String)
      var_name = Regexp.last_match[2]
      self.class.define_has_a_var_which_begins_with(var_name)
      send("has_a_#{var_name}_which_begins_with?".to_sym, *args, &block)
    else
      super(m, *args, &block)
    end
  end
end

#### sample #####
shimada = Person.new(:name => "Shimada", :age => 18, :sex => :half, :fuga => "bababa")
p shimada.has_a_name_which_begins_with?("S") ? "Good" : "Suck"
p shimada.has_the_name_which_begins_with?("S") ? "Good" : "Suck"
shimada.name = 5
p shimada.has_the_name_which_begins_with?("5") ? "Good" : "Suck" #=> undefined method
if air_plane.is_created_by? :bowing
    if he.is_eligible_to_get? reward
    if selected_value.is_valid?


→
    can_..., is_,
is does was did
module Kernel
  def is(expected)
    expected
  end

 alias_method :does, :is
 alias_method :was, :is
 alias_method :were, :is
 alias_method :did, :is
 # alias_method :do, :is       × do
end

is air_plane.created_by?(bowing)
does [1,2,3].include?
is he.eligible_to_get?(bonus)
does [1,2,3].include?
is "h".included_in?("hello")
is she, nancy   # ?
Conclusion & Impression

•   Spec



•

•
      •                                                                          Receiver
                                                                            Array#sort


      •            Ruby Standard Library         if obj.instance_of?(exp)   be
                                           (Is                  Object#is   Is#method_missing
           self   return...)


      •
      •
      •
thank you :)

More Related Content

What's hot

Ruby - Uma Introdução
Ruby - Uma IntroduçãoRuby - Uma Introdução
Ruby - Uma Introdução
Ígor Bonadio
 
CodeFest 2010. Иноземцев И. — Fantom. Cross-VM Language
CodeFest 2010. Иноземцев И. — Fantom. Cross-VM LanguageCodeFest 2010. Иноземцев И. — Fantom. Cross-VM Language
CodeFest 2010. Иноземцев И. — Fantom. Cross-VM Language
CodeFest
 
Coffee Script
Coffee ScriptCoffee Script
Coffee Script
Michal Taberski
 
Exhibition of Atrocity
Exhibition of AtrocityExhibition of Atrocity
Exhibition of Atrocity
Michael Pirnat
 
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
hwilming
 
Rapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and RailsRapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and Rails
elliando dias
 
Slides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammersSlides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammers
Giovanni924
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手
Wen-Tien Chang
 
Real world gobbledygook
Real world gobbledygookReal world gobbledygook
Real world gobbledygook
Pawel Szulc
 
Coffeescript: No really, it's just Javascript
Coffeescript: No really, it's just JavascriptCoffeescript: No really, it's just Javascript
Coffeescript: No really, it's just Javascript
Brian Mann
 
Ruby from zero to hero
Ruby from zero to heroRuby from zero to hero
Ruby from zero to hero
Diego Lemos
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
Donald Sipe
 
1 the ruby way
1   the ruby way1   the ruby way
1 the ruby way
Luis Doubrava
 
Descobrindo a linguagem Perl
Descobrindo a linguagem PerlDescobrindo a linguagem Perl
Descobrindo a linguagem Perl
garux
 
Everything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-insEverything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-ins
Andrew Dupont
 
Introduction to Ruby Programming Language
Introduction to Ruby Programming LanguageIntroduction to Ruby Programming Language
Introduction to Ruby Programming Language
Nicolò Calcavecchia
 
Hacker 101/102 - Introduction to Programming w/Processing
Hacker 101/102 - Introduction to Programming w/ProcessingHacker 101/102 - Introduction to Programming w/Processing
Hacker 101/102 - Introduction to Programming w/Processing
Dan Chudnov
 
Beginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScriptBeginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScript
Stoyan Stefanov
 
purely_functional_play_framework_application
purely_functional_play_framework_applicationpurely_functional_play_framework_application
purely_functional_play_framework_application
Naoki Aoyama
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.Vim
Lin Yo-An
 

What's hot (20)

Ruby - Uma Introdução
Ruby - Uma IntroduçãoRuby - Uma Introdução
Ruby - Uma Introdução
 
CodeFest 2010. Иноземцев И. — Fantom. Cross-VM Language
CodeFest 2010. Иноземцев И. — Fantom. Cross-VM LanguageCodeFest 2010. Иноземцев И. — Fantom. Cross-VM Language
CodeFest 2010. Иноземцев И. — Fantom. Cross-VM Language
 
Coffee Script
Coffee ScriptCoffee Script
Coffee Script
 
Exhibition of Atrocity
Exhibition of AtrocityExhibition of Atrocity
Exhibition of Atrocity
 
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
 
Rapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and RailsRapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and Rails
 
Slides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammersSlides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammers
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手
 
Real world gobbledygook
Real world gobbledygookReal world gobbledygook
Real world gobbledygook
 
Coffeescript: No really, it's just Javascript
Coffeescript: No really, it's just JavascriptCoffeescript: No really, it's just Javascript
Coffeescript: No really, it's just Javascript
 
Ruby from zero to hero
Ruby from zero to heroRuby from zero to hero
Ruby from zero to hero
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 
1 the ruby way
1   the ruby way1   the ruby way
1 the ruby way
 
Descobrindo a linguagem Perl
Descobrindo a linguagem PerlDescobrindo a linguagem Perl
Descobrindo a linguagem Perl
 
Everything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-insEverything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-ins
 
Introduction to Ruby Programming Language
Introduction to Ruby Programming LanguageIntroduction to Ruby Programming Language
Introduction to Ruby Programming Language
 
Hacker 101/102 - Introduction to Programming w/Processing
Hacker 101/102 - Introduction to Programming w/ProcessingHacker 101/102 - Introduction to Programming w/Processing
Hacker 101/102 - Introduction to Programming w/Processing
 
Beginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScriptBeginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScript
 
purely_functional_play_framework_application
purely_functional_play_framework_applicationpurely_functional_play_framework_application
purely_functional_play_framework_application
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.Vim
 

Similar to あたかも自然言語を書くようにコーディングしてみる

Language supports it
Language supports itLanguage supports it
Language supports it
Niranjan Paranjape
 
Petitparser at the Deep into Smalltalk School 2011
Petitparser at the Deep into Smalltalk School 2011Petitparser at the Deep into Smalltalk School 2011
Petitparser at the Deep into Smalltalk School 2011
Tudor Girba
 
Threequals - Case Equality in Ruby
Threequals - Case Equality in RubyThreequals - Case Equality in Ruby
Threequals - Case Equality in Ruby
Louis Scoras
 
Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)
jeffz
 
Crystal presentation in NY
Crystal presentation in NYCrystal presentation in NY
Crystal presentation in NY
Crystal Language
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
Marc Chung
 
A limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced RubyA limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced Ruby
Vysakh Sreenivasan
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
Aslak Hellesøy
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
Aslak Hellesøy
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
Aslak Hellesøy
 
Tork03 LT
Tork03 LT Tork03 LT
Tork03 LT
Masaya TARUI
 
Making JavaScript Libraries More Approachable
Making JavaScript Libraries More ApproachableMaking JavaScript Libraries More Approachable
Making JavaScript Libraries More Approachable
Pamela Fox
 
jRuby: The best of both worlds
jRuby: The best of both worldsjRuby: The best of both worlds
jRuby: The best of both worlds
Christopher Spring
 
Uses & Abuses of Mocks & Stubs
Uses & Abuses of Mocks & StubsUses & Abuses of Mocks & Stubs
Uses & Abuses of Mocks & Stubs
PatchSpace Ltd
 
Postobjektové programovanie v Ruby
Postobjektové programovanie v RubyPostobjektové programovanie v Ruby
Postobjektové programovanie v Ruby
Jano Suchal
 
Playfulness at Work
Playfulness at WorkPlayfulness at Work
Playfulness at Work
Erin Dees
 
RSpec 3.0: Under the Covers
RSpec 3.0: Under the CoversRSpec 3.0: Under the Covers
RSpec 3.0: Under the Covers
Brian Gesiak
 
Write Your Own JVM Compiler
Write Your Own JVM CompilerWrite Your Own JVM Compiler
Write Your Own JVM Compiler
Erin Dees
 
Attributes Unwrapped: Lessons under the surface of active record
Attributes Unwrapped: Lessons under the surface of active recordAttributes Unwrapped: Lessons under the surface of active record
Attributes Unwrapped: Lessons under the surface of active record
.toster
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScript
Ingvar Stepanyan
 

Similar to あたかも自然言語を書くようにコーディングしてみる (20)

Language supports it
Language supports itLanguage supports it
Language supports it
 
Petitparser at the Deep into Smalltalk School 2011
Petitparser at the Deep into Smalltalk School 2011Petitparser at the Deep into Smalltalk School 2011
Petitparser at the Deep into Smalltalk School 2011
 
Threequals - Case Equality in Ruby
Threequals - Case Equality in RubyThreequals - Case Equality in Ruby
Threequals - Case Equality in Ruby
 
Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)
 
Crystal presentation in NY
Crystal presentation in NYCrystal presentation in NY
Crystal presentation in NY
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
A limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced RubyA limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced Ruby
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
 
Tork03 LT
Tork03 LT Tork03 LT
Tork03 LT
 
Making JavaScript Libraries More Approachable
Making JavaScript Libraries More ApproachableMaking JavaScript Libraries More Approachable
Making JavaScript Libraries More Approachable
 
jRuby: The best of both worlds
jRuby: The best of both worldsjRuby: The best of both worlds
jRuby: The best of both worlds
 
Uses & Abuses of Mocks & Stubs
Uses & Abuses of Mocks & StubsUses & Abuses of Mocks & Stubs
Uses & Abuses of Mocks & Stubs
 
Postobjektové programovanie v Ruby
Postobjektové programovanie v RubyPostobjektové programovanie v Ruby
Postobjektové programovanie v Ruby
 
Playfulness at Work
Playfulness at WorkPlayfulness at Work
Playfulness at Work
 
RSpec 3.0: Under the Covers
RSpec 3.0: Under the CoversRSpec 3.0: Under the Covers
RSpec 3.0: Under the Covers
 
Write Your Own JVM Compiler
Write Your Own JVM CompilerWrite Your Own JVM Compiler
Write Your Own JVM Compiler
 
Attributes Unwrapped: Lessons under the surface of active record
Attributes Unwrapped: Lessons under the surface of active recordAttributes Unwrapped: Lessons under the surface of active record
Attributes Unwrapped: Lessons under the surface of active record
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScript
 

Recently uploaded

Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 

Recently uploaded (20)

Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 

あたかも自然言語を書くようにコーディングしてみる

  • 1. Programming Production Code as if writing Natural Language Kazuya NUMATA @kaznum
  • 2. Self-introduction (Kazuya NUMATA) • • � • • • ��������������� •
  • 3. My favorite • • •
  • 5. Communication with team members including stakeholder & Iterative Testing
  • 7. Tools to make BDD effective
  • 8. RSpec (Ruby) • NSpec (.NET) • CppSpec (C++) • JBehave (Java) • instinct (Java) • PHPSpec (PHP) • and more....
  • 10. Question Have you ever experienced *Spec? *Spec ?
  • 11. RSpec example: describe "A new chess board" do before(:each) do @board = Chess::Board.new end it "should have 32 pieces" do @board.should have(32).pieces end end D. Chelimsky. The RSpec Book Section 13.7 Generated Descriptions
  • 12. RSpec example: describe "A new chess board" do before(:each) do @board = Chess::Board.new end it "should have 32 pieces" do @board.should have(32).pieces end end D. Chelimsky. The RSpec Book Section 13.7 Generated Descriptions
  • 13. RSpec example: $ rspec -fd board_spec.rb (Output is...) A new chess board should have 32 pieces D. Chelimsky. The RSpec Book Section 13.7 Generated Descriptions
  • 14. It is just Natural Language!
  • 15.
  • 16. The reality is that it’s hard for the Japanese.
  • 17. Cucumber (
  • 18. Cucumber Example: : : " " " " " " " Cucumber" " " " Cucumber" ( ∀ )o sasata299's blog http://blog.livedoor.jp/sasata299/archives/51278697.html
  • 19.
  • 20. /Spec Before BDD After Spec Spec BDD
  • 22.
  • 23.
  • 24.
  • 25. Uncle Bob Complex fulcrumPoint = Complex.FromRealNumber(23.0); is generally better than Complex fulcrumPoint = new Complex(23.0); Consider enforcing their use by making the corresponding constructors private. ( )
  • 27. Person name true false
  • 28. Ruby Example: name 1 ex1 class Person attr_accessor :name def initialize(name = nil) @name = name end end shimada = Person.new(“Shimada”) if shimada.name.split(//)[0] == “S” puts “Match” end
  • 29. Ruby Example: name 1 ex2 class Person attr_accessor :name def initialize(name = nil) @name = name end def has_a_name_that_begins_with?(expected) @name.split(//)[0] == expected end end shimada = Person.new(“Shimada”) if shimada.has_a_name_that_begins_with?(“S”) puts “Match” end
  • 30. Ruby Example: name 1 ex3 class Person attr_accessor :name def initialize(name = nil) @name = name end def has_a_name_that_begins_with?(expected) @name.split(//)[0] == expected end def method_missing(m, *args, &block) if m.to_s =~ /has_(a|the)_name_(that|which)_begins_with?/ has_a_name_that_begins_with?(args) else super end end end shimada = Person.new(“Shimada”) puts “Match” if shimada.has_a_name_that_begins_with?(“S”) puts “Match” if shimada.has_the_name_that_begins_with?(“S”) puts “Match” if shimada.has_a_name_which_begins_with?(“S”) puts “Match” if shimada.has_the_name_which_begins_with?(“S”)
  • 31. Ruby Example: name 1 ex4 name String has_(a|the)_(.+)_(which|that)_begins_with? Dynamic setter undef Singleton Method class Person def initialize(args) args.each do |key, value| self.class.send(:attr_accessor, :"#{key}") unless instance_variables.include?(:"@#{key}") instance_variable_set(:"@#{key}", value) end end def self.undef_has_a_var_which_begins_with(var) method_name = "has_a_#{var}_which_begins_with?" send("undef_method", method_name) if method_defined? method_name end def self.define_has_a_var_which_begins_with(var) method_name = "has_a_#{var}_which_begins_with?" define_method(method_name) do |expectation| value = instance_variable_get(:"@#{var}") if value.is_a?(String) value.split(//)[0].downcase == expectation.downcase else self.class.undef_has_a_var_which_begins_with(var) method_missing(method_name.to_sym) end end end def method_missing(m, *args, &block) if m.to_s =~ /has_(a|the)_(.+)_(which|that)_begins_with?/ && instance_variables.include?(:"@#{Regexp.last_match[2]}") && instance_variable_get(:"@#{Regexp.last_match[2]}").is_a?(String) var_name = Regexp.last_match[2] self.class.define_has_a_var_which_begins_with(var_name) send("has_a_#{var_name}_which_begins_with?".to_sym, *args, &block) else super(m, *args, &block) end end end #### sample ##### shimada = Person.new(:name => "Shimada", :age => 18, :sex => :half, :fuga => "bababa") p shimada.has_a_name_which_begins_with?("S") ? "Good" : "Suck" p shimada.has_the_name_which_begins_with?("S") ? "Good" : "Suck" shimada.name = 5 p shimada.has_the_name_which_begins_with?("5") ? "Good" : "Suck" #=> undefined method
  • 32.
  • 33. if air_plane.is_created_by? :bowing if he.is_eligible_to_get? reward if selected_value.is_valid? → can_..., is_,
  • 34. is does was did module Kernel def is(expected) expected end alias_method :does, :is alias_method :was, :is alias_method :were, :is alias_method :did, :is # alias_method :do, :is × do end is air_plane.created_by?(bowing) does [1,2,3].include? is he.eligible_to_get?(bonus) does [1,2,3].include? is "h".included_in?("hello") is she, nancy # ?
  • 35. Conclusion & Impression • Spec • • • Receiver Array#sort • Ruby Standard Library if obj.instance_of?(exp) be (Is Object#is Is#method_missing self return...) • • •

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n