SlideShare ist ein Scribd-Unternehmen logo
1 von 51
Journey's Diary
        Developing
       a framework
         using TDD



        Eduardo Guerra
Case Study
The Framework
+ name conventions
 INTERFACE   + anotations
             + entity class structure

                    Query
                    Builder

Dynamic
INTERFACE
 Proxy         Framework
+ name conventions
INTERFACE   + anotations
            + entity class structure




     DSL
QueryBuilder JPA




                 QueryBuilder MongoDB




                  QueryBuilder Neo4J
QueryBuilder
    Core
               QueryBuilder JDBC
For a good
understander, the
 method name is
    enough!
public List<Person>
getPersonByNameOrAge
  (String name, int age);


  Using a simple naming
pattern, you can define the
entity and the properties to
     be used as filters.
public List<Person>
 getPersonByNameOrAge
   (String name, int age);

  The return type indicates if you
expect a single or multiple results.
 public Person
 getPersonByNameOrAge
   (String name, int age);
public List<Person>
getPersonByNameOrAge
  (String name, int age);


    It is verified if the
parameter types matches
   the property types.
public List<Order>
getOrderPendingByDateGreater
  (Date date);

Anotations or conventions can
be used to define the filter type.

public List<Order>
getOrderPendingByDate
  (@Greater Date date);
You can define new domain
 terms and use them on the
       method names.
@DomainTerm(term=“pending“
  conditions = @Condition(
  property=”status”, value=”P”))

public List<Order>
getOrderPendingByDate
  (@Greater Date date);
public List<Person> getPerson
  (@QueryObject PersonSearch p);


For complex queries, you
  can define a class with
 the filters and metadata
about how they should be
          handled.
public List<Person>
  getPersonByNameAndLastName
  (@CompareToNull String name,
  @IgnoreWhenNull String lastname);


 You can configure the
query to compare to null
 or to ignore when the
   parameter is null.
Tests
       They
 consume my
development
       time?
YES
on the begining...
In the first tests, you
usually need more effort to
create scenarios and verify
the expect results.
● Create mocks
● Handle external


  resources
● Do complex


  verifications
On the next tests, the code
      created is reused and the
  time to introduce a new test
for the TDD cycle is very small.
Tips
Put common things in setup
Create helper methods
Create test superclasses
Search for the right framework
QueryBuilder


          MethodParser




Some MethodParser mocks
were defined on setup and
used on all tests.
QueryBuilder


 ClassMock
 Framework



ClassMock were used to
generate classes in
runtime to test reflection.
To mock or
               not to
               mock?

That is the question!
What should I do when
I have things that are
   hard to test, like
  external resources?




MOCK
Why?
  It can make the test slow

  It will make the test difficult

  Test will be coupled with
  external APIs
But should I mock
 the external APIs
   themselves?



MOCK
Why not?        Create a class that
                 encapsulates the
                access to this API!
  Decouple the class from the API
  It is a perfect match on the
  class needs
  The API can be hard to mock
What should I do when
I have classes that are
  not exposed to the
     class clients?



MOCK
Why not?
  Test will be coupled to the
  solution

  The solution can't be refactored
  without changing the test

  Class don't need to be exposed
What should I do when my
class have a hotspot or a
dependence with variable
        behavior?




MOCK
Why?
  Mock can be used to design the
  dependence API
  Mock can explore all possibilities,
  such possible errors

  Mock can be used to divide class
  responsibilities
Visitor that
                     generates the query
                    was mocked because
QueryBuilder              it is a hotspot.


                               MOCK
 MethodParser
                               MOCK
               A composite to store query
            parameters was not mocked
       because it is an internal solution.
Unit or Integration ?




Can I use both on TDD?
Unit Test
                     =
             decoupling
          Creating unit tests you are
dividing responsibilities and defining
  the interaction among the classes.
Integration Test
= box
black
black box
You are having feedback on your
implementation, but it is not
helping to define your design.
If I'm defining my
design using tests,
  when can I use
integration tests?
Easy question!
  When your
design is already
    defined!
Class A   Class B      Class C




               Imagine that an
                  architecture
               with these three
                       classes
Developing Class A, the services needed
from Class B were defined.


                 Class A
   UNIT TEST                    MOCK
Class C interface were defined on its
own TDD session.


                 Class C
  UNIT TEST
Class A      Class B       Class C



                 Now that everything
                   is defined, you can
                 use integration tests
                    to develop Class B
INTEGRATION
    TEST                    using TDD.
If you designed everything upfront, you
 don't need TDD as a design technique!
ESTED
                        T
QueryBuilder                  QueryBuilder

Since the other
classes are already
tested, QueryExecutor        QueryExecutor
was developed using
integration tests.
                          ESTED
                         T
                              QueryVisitor
Big Refactorings
They will happen!
When you always search for the
 simplest solution, sometimes
    you reach a dead end!
However, most of the time these
problems are concentrated on a single
  class and isolated from the others.
If that happens,
    STOP and
  refactor your
     solution!
method call


QueryBuilder
   method call      refactor         store


                 When appear
                 a requirement
   process                          process
                 where the
                 processing
                 depends on
                 the next call...
   write query                      write query
Final Considerations


What is
missing?
You still have to know patterns to
understand the solution that you are
driving through the tests.
You can use TDD only for
development, or also as a
    design technique.

If you choose design you
 can not avoid mocking!
Refactoring is a
 very important
    design tool!
Using TDD you
finish the
session very
proud of your
work!
@Test
public void presentationEnd(){
   Presentation p = new Presentation();
   Audience a = new Audience();
   p.setAudience(a);
   p.perform();
   p.end();
   p.thanksEveryone();
   assertTrue(a.isApplauding());
}

Weitere ähnliche Inhalte

Was ist angesagt?

Solit 2012, TDD и отдельные аспекты тестирования в Java, Антонина Шафранская
Solit 2012, TDD и отдельные аспекты тестирования в Java, Антонина ШафранскаяSolit 2012, TDD и отдельные аспекты тестирования в Java, Антонина Шафранская
Solit 2012, TDD и отдельные аспекты тестирования в Java, Антонина Шафранскаяsolit
 
Working Effectively with Legacy Code: Lessons in Practice
Working Effectively with Legacy Code: Lessons in PracticeWorking Effectively with Legacy Code: Lessons in Practice
Working Effectively with Legacy Code: Lessons in PracticeAmar Shah
 
TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019Paulo Clavijo
 
Design pattern application
Design pattern applicationDesign pattern application
Design pattern applicationgayatri thakur
 
TDD and Simple Design Workshop - Session 1 - November 2018
TDD and Simple Design Workshop - Session 1 - November 2018TDD and Simple Design Workshop - Session 1 - November 2018
TDD and Simple Design Workshop - Session 1 - November 2018Paulo Clavijo
 
Most Asked Java Interview Question and Answer
Most Asked Java Interview Question and AnswerMost Asked Java Interview Question and Answer
Most Asked Java Interview Question and AnswerTOPS Technologies
 
Java/J2EE interview Qestions
Java/J2EE interview QestionsJava/J2EE interview Qestions
Java/J2EE interview QestionsArun Vasanth
 
Refactoring - An Introduction
Refactoring - An IntroductionRefactoring - An Introduction
Refactoring - An IntroductionGiorgio Vespucci
 
Java design pattern tutorial
Java design pattern tutorialJava design pattern tutorial
Java design pattern tutorialAshoka Vanjare
 
Working Effectively with Legacy Code
Working Effectively with Legacy CodeWorking Effectively with Legacy Code
Working Effectively with Legacy Codeslicklash
 
Java interview questions 2
Java interview questions 2Java interview questions 2
Java interview questions 2Sherihan Anver
 
Basic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobBasic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobGaruda Trainings
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy CodeNaresh Jain
 
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007Arun Kumar
 
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012Pietro Di Bello
 
New Ideas for Old Code - Greach
New Ideas for Old Code - GreachNew Ideas for Old Code - Greach
New Ideas for Old Code - GreachHamletDRC
 
201 core java interview questions oo ps interview questions - javatpoint
201 core java interview questions   oo ps interview questions - javatpoint201 core java interview questions   oo ps interview questions - javatpoint
201 core java interview questions oo ps interview questions - javatpointravi tyagi
 

Was ist angesagt? (20)

Java scjp-part1
Java scjp-part1Java scjp-part1
Java scjp-part1
 
Solit 2012, TDD и отдельные аспекты тестирования в Java, Антонина Шафранская
Solit 2012, TDD и отдельные аспекты тестирования в Java, Антонина ШафранскаяSolit 2012, TDD и отдельные аспекты тестирования в Java, Антонина Шафранская
Solit 2012, TDD и отдельные аспекты тестирования в Java, Антонина Шафранская
 
Working Effectively with Legacy Code: Lessons in Practice
Working Effectively with Legacy Code: Lessons in PracticeWorking Effectively with Legacy Code: Lessons in Practice
Working Effectively with Legacy Code: Lessons in Practice
 
TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019
 
Design pattern application
Design pattern applicationDesign pattern application
Design pattern application
 
TDD and Simple Design Workshop - Session 1 - November 2018
TDD and Simple Design Workshop - Session 1 - November 2018TDD and Simple Design Workshop - Session 1 - November 2018
TDD and Simple Design Workshop - Session 1 - November 2018
 
Most Asked Java Interview Question and Answer
Most Asked Java Interview Question and AnswerMost Asked Java Interview Question and Answer
Most Asked Java Interview Question and Answer
 
Java/J2EE interview Qestions
Java/J2EE interview QestionsJava/J2EE interview Qestions
Java/J2EE interview Qestions
 
Refactoring - An Introduction
Refactoring - An IntroductionRefactoring - An Introduction
Refactoring - An Introduction
 
Java design pattern tutorial
Java design pattern tutorialJava design pattern tutorial
Java design pattern tutorial
 
Working Effectively with Legacy Code
Working Effectively with Legacy CodeWorking Effectively with Legacy Code
Working Effectively with Legacy Code
 
Java interview questions 2
Java interview questions 2Java interview questions 2
Java interview questions 2
 
Basic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobBasic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a job
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Code
 
클린 테스트
클린 테스트클린 테스트
클린 테스트
 
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
 
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012
 
New Ideas for Old Code - Greach
New Ideas for Old Code - GreachNew Ideas for Old Code - Greach
New Ideas for Old Code - Greach
 
Introduction to TDD and Mocking
Introduction to TDD and MockingIntroduction to TDD and Mocking
Introduction to TDD and Mocking
 
201 core java interview questions oo ps interview questions - javatpoint
201 core java interview questions   oo ps interview questions - javatpoint201 core java interview questions   oo ps interview questions - javatpoint
201 core java interview questions oo ps interview questions - javatpoint
 

Andere mochten auch

TDD step patterns
TDD step patternsTDD step patterns
TDD step patternseduardomg23
 
Refactoring test code
Refactoring test codeRefactoring test code
Refactoring test codeeduardomg23
 
An Architectural Model for Adapting Domain-Specific AOM Applications
An Architectural Model for Adapting Domain-Specific AOM ApplicationsAn Architectural Model for Adapting Domain-Specific AOM Applications
An Architectural Model for Adapting Domain-Specific AOM Applicationseduardomg23
 
Agile Software Design
Agile Software DesignAgile Software Design
Agile Software Designeduardomg23
 
IoT 개발자를 위한 Embedded C에서 TDD를 해보자
IoT 개발자를 위한 Embedded C에서 TDD를 해보자IoT 개발자를 위한 Embedded C에서 TDD를 해보자
IoT 개발자를 위한 Embedded C에서 TDD를 해보자Taeyeop Kim
 

Andere mochten auch (6)

TDD step patterns
TDD step patternsTDD step patterns
TDD step patterns
 
Refactoring test code
Refactoring test codeRefactoring test code
Refactoring test code
 
An Architectural Model for Adapting Domain-Specific AOM Applications
An Architectural Model for Adapting Domain-Specific AOM ApplicationsAn Architectural Model for Adapting Domain-Specific AOM Applications
An Architectural Model for Adapting Domain-Specific AOM Applications
 
Agile Software Design
Agile Software DesignAgile Software Design
Agile Software Design
 
IoT 개발자를 위한 Embedded C에서 TDD를 해보자
IoT 개발자를 위한 Embedded C에서 TDD를 해보자IoT 개발자를 위한 Embedded C에서 TDD를 해보자
IoT 개발자를 위한 Embedded C에서 TDD를 해보자
 
Testing In Java
Testing In JavaTesting In Java
Testing In Java
 

Ähnlich wie Journey's diary developing a framework using tdd

Tdd and-design-draft
Tdd and-design-draftTdd and-design-draft
Tdd and-design-draftPrabudhGupta1
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionDionatan default
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0Ganesh Kondal
 
Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010guest5639fa9
 
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose presoTest Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose presoElad Elrom
 
Reduce Development Cost with Test Driven Development
Reduce Development Cost with Test Driven DevelopmentReduce Development Cost with Test Driven Development
Reduce Development Cost with Test Driven Developmentsthicks14
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven DevelopmentMichael Denomy
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven DevelopmentTung Nguyen Thanh
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@Alex Borsuk
 
C# Interview Questions | Edureka
C# Interview Questions | EdurekaC# Interview Questions | Edureka
C# Interview Questions | EdurekaEdureka!
 
Test Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionTest Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionPyxis Technologies
 
Design Patterns
Design PatternsDesign Patterns
Design Patternsimedo.de
 

Ähnlich wie Journey's diary developing a framework using tdd (20)

Tdd and-design-draft
Tdd and-design-draftTdd and-design-draft
Tdd and-design-draft
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in Action
 
JavaScript Unit Testing
JavaScript Unit TestingJavaScript Unit Testing
JavaScript Unit Testing
 
TDD - Agile
TDD - Agile TDD - Agile
TDD - Agile
 
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
Ian Cooper webinar for DDD Iran: Kent beck style tdd   seven years afterIan Cooper webinar for DDD Iran: Kent beck style tdd   seven years after
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0
 
Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010
 
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose presoTest Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
 
Reduce Development Cost with Test Driven Development
Reduce Development Cost with Test Driven DevelopmentReduce Development Cost with Test Driven Development
Reduce Development Cost with Test Driven Development
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven Development
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Code Quality
Code QualityCode Quality
Code Quality
 
Code quality
Code qualityCode quality
Code quality
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
C# Interview Questions | Edureka
C# Interview Questions | EdurekaC# Interview Questions | Edureka
C# Interview Questions | Edureka
 
Continuous Testing
Continuous TestingContinuous Testing
Continuous Testing
 
Test Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionTest Driven Development - Overview and Adoption
Test Driven Development - Overview and Adoption
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 

Kürzlich hochgeladen

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Kürzlich hochgeladen (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Journey's diary developing a framework using tdd

  • 1. Journey's Diary Developing a framework using TDD Eduardo Guerra
  • 3. + name conventions INTERFACE + anotations + entity class structure Query Builder Dynamic INTERFACE Proxy Framework
  • 4. + name conventions INTERFACE + anotations + entity class structure DSL
  • 5. QueryBuilder JPA QueryBuilder MongoDB QueryBuilder Neo4J QueryBuilder Core QueryBuilder JDBC
  • 6. For a good understander, the method name is enough!
  • 7. public List<Person> getPersonByNameOrAge (String name, int age); Using a simple naming pattern, you can define the entity and the properties to be used as filters.
  • 8. public List<Person> getPersonByNameOrAge (String name, int age); The return type indicates if you expect a single or multiple results. public Person getPersonByNameOrAge (String name, int age);
  • 9. public List<Person> getPersonByNameOrAge (String name, int age); It is verified if the parameter types matches the property types.
  • 10. public List<Order> getOrderPendingByDateGreater (Date date); Anotations or conventions can be used to define the filter type. public List<Order> getOrderPendingByDate (@Greater Date date);
  • 11. You can define new domain terms and use them on the method names. @DomainTerm(term=“pending“ conditions = @Condition( property=”status”, value=”P”)) public List<Order> getOrderPendingByDate (@Greater Date date);
  • 12. public List<Person> getPerson (@QueryObject PersonSearch p); For complex queries, you can define a class with the filters and metadata about how they should be handled.
  • 13. public List<Person> getPersonByNameAndLastName (@CompareToNull String name, @IgnoreWhenNull String lastname); You can configure the query to compare to null or to ignore when the parameter is null.
  • 14. Tests They consume my development time?
  • 16. In the first tests, you usually need more effort to create scenarios and verify the expect results. ● Create mocks ● Handle external resources ● Do complex verifications
  • 17. On the next tests, the code created is reused and the time to introduce a new test for the TDD cycle is very small.
  • 18. Tips Put common things in setup Create helper methods Create test superclasses Search for the right framework
  • 19. QueryBuilder MethodParser Some MethodParser mocks were defined on setup and used on all tests.
  • 20. QueryBuilder ClassMock Framework ClassMock were used to generate classes in runtime to test reflection.
  • 21. To mock or not to mock? That is the question!
  • 22. What should I do when I have things that are hard to test, like external resources? MOCK
  • 23. Why? It can make the test slow It will make the test difficult Test will be coupled with external APIs
  • 24. But should I mock the external APIs themselves? MOCK
  • 25. Why not? Create a class that encapsulates the access to this API! Decouple the class from the API It is a perfect match on the class needs The API can be hard to mock
  • 26. What should I do when I have classes that are not exposed to the class clients? MOCK
  • 27. Why not? Test will be coupled to the solution The solution can't be refactored without changing the test Class don't need to be exposed
  • 28. What should I do when my class have a hotspot or a dependence with variable behavior? MOCK
  • 29. Why? Mock can be used to design the dependence API Mock can explore all possibilities, such possible errors Mock can be used to divide class responsibilities
  • 30. Visitor that generates the query was mocked because QueryBuilder it is a hotspot. MOCK MethodParser MOCK A composite to store query parameters was not mocked because it is an internal solution.
  • 31. Unit or Integration ? Can I use both on TDD?
  • 32. Unit Test = decoupling Creating unit tests you are dividing responsibilities and defining the interaction among the classes.
  • 33. Integration Test = box black black box You are having feedback on your implementation, but it is not helping to define your design.
  • 34. If I'm defining my design using tests, when can I use integration tests?
  • 35. Easy question! When your design is already defined!
  • 36. Class A Class B Class C Imagine that an architecture with these three classes
  • 37. Developing Class A, the services needed from Class B were defined. Class A UNIT TEST MOCK Class C interface were defined on its own TDD session. Class C UNIT TEST
  • 38. Class A Class B Class C Now that everything is defined, you can use integration tests to develop Class B INTEGRATION TEST using TDD.
  • 39. If you designed everything upfront, you don't need TDD as a design technique!
  • 40. ESTED T QueryBuilder QueryBuilder Since the other classes are already tested, QueryExecutor QueryExecutor was developed using integration tests. ESTED T QueryVisitor
  • 42. When you always search for the simplest solution, sometimes you reach a dead end!
  • 43. However, most of the time these problems are concentrated on a single class and isolated from the others.
  • 44. If that happens, STOP and refactor your solution!
  • 45. method call QueryBuilder method call refactor store When appear a requirement process process where the processing depends on the next call... write query write query
  • 47. You still have to know patterns to understand the solution that you are driving through the tests.
  • 48. You can use TDD only for development, or also as a design technique. If you choose design you can not avoid mocking!
  • 49. Refactoring is a very important design tool!
  • 50. Using TDD you finish the session very proud of your work!
  • 51. @Test public void presentationEnd(){ Presentation p = new Presentation(); Audience a = new Audience(); p.setAudience(a); p.perform(); p.end(); p.thanksEveryone(); assertTrue(a.isApplauding()); }