SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Bring the FUN back to Java development Set of tools, making development easier Illarion Kovalchuk © 2011
<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <web-app id=&quot;WebApp_9&quot; version=&quot;2.4&quot; xmlns=&quot;http://java.sun.com/xml/ns/j2ee&quot;  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;  xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot;> <display-name>Servlet 2.4 application</display-name> <filter> <filter-name>ServletMappedDoFilter_Filter</filter-name> <filter-class>tests.Filter.DoFilter_Filter</filter-class> <init-param> <param-name>attribute</param-name> <param-value>tests.Filter.DoFilter_Filter.SERVLET_MAPPED</param-value> </init-param> </filter> <filter-mapping> <filter-name>ServletMappedDoFilter_Filter</filter-name> <url-pattern>/DoFilterTest</url-pattern> <dispatcher>REQUEST</dispatcher> </filter-mapping> <filter-mapping> <filter-name>ServletMappedDoFilter_Filter</filter-name> <url-pattern>/IncludedServlet</url-pattern> <dispatcher>INCLUDE</dispatcher> </filter-mapping> ... Problem ,[object Object]
Problem I have no solution. If you're bored of Java, you are. ,[object Object],But Java still rocks ;)
Approach Use the right tools! Keep It Simple Write less code, write clean code Always consider the context
Overview – the stuff I'd like  to talk about
Useful Libraries ,[object Object]
Guice
Guava
Useful Libraries http://code.google.com/p/mockito/ Mockito is a mocking framework that tastes really good. It lets you write beautiful tests with clean & simple API. Mockito doesn't give you  hangover  because the tests are very readable and they produce clean verification errors.
Useful Libraries - Mockito
Useful Libraries - Mockito
Useful Libraries - Mockito
Useful Libraries - Mockito SLIDE FOR THOSE, WHO CAN READ SO MUCH CODE
Useful Libraries Put simply, Guice alleviates the need for factories and the use of new in your Java code. Think of Guice's  @Inject  as the new new http://code.google.com/p/google-guice/ google-guice
Useful Libraries – google-guice public class   BillingModule   extends   AbstractModule  { @Override   protected void  configure ()  { bind( TransactionLog .class).to( Database TransactionLog .class); bind( CreditCardProcessor .class).to( Paypal CreditCardProcessor .class); bind( BillingService .class).to( Real BillingService .class); } } Setup
Useful Libraries – google-guice public class   BillingModule   extends   AbstractModule  { @Override   protected void  configure ()  { bind( TransactionLog .class).to( Database TransactionLog .class); bind( CreditCardProcessor .class).to( Paypal CreditCardProcessor .class); bind( BillingService .class).to( Real BillingService .class); } } Setup @Inject public   RealBillingService ( CreditCardProcessor  processor,  TransactionLog  log ) { this .processor = processor; this .log = log; } Inject
Useful Libraries – google-guice public class   BillingModule   extends   AbstractModule  { @Override   protected void  configure ()  { bind( TransactionLog .class).to( Database TransactionLog .class); bind( CreditCardProcessor .class).to( Paypal CreditCardProcessor .class); bind( BillingService .class).to( Real BillingService .class); } } Setup @Inject public   RealBillingService ( CreditCardProcessor  processor,  TransactionLog  log ) { this .processor = processor; this .log = log; } Inject public static void  main( String [] args) { Injector  injector =  Guice .createInjector(new  BillingModule ()); BillingService  billingService = injector.getInstance( BillingService .class); ... } Launch!
Useful Libraries The Guava project contains several of Google's core libraries that we rely on in our Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so forth. guava-libraries http://code.google.com/p/guava-libraries/
Useful Libraries - guava-libraries Example 1: Objects public class   Person  { final  String  name, nickname; final  Movie  favMovie; @Override   public  boolean equals(Object object) { if (object instanceof Person) { Person  that = ( Person ) object; return  Objects .equal(this.name, that.name) &&  Objects .equal(this.nickname, that.nickname) &&  Objects .equal(this.favMovie, that.favMovie); } return false; } @Override public  int hashCode() { return  Objects .hashCode(name, nickname, favMovie); }
Useful Libraries - guava-libraries Example 2: Other useful things Preconditions .checkState(state ==  State .PLAYABLE,  &quot;Can't play movie; state is %s&quot; , state); //will throw ISE with message … this.rating  = Preconditio ns.checkNotNull(rating); //will throw  NPE … //CharMatcher matcher = CharMatcher.is('x'); //CharMatcher matcher = CharMatcher.isNot('_'); //CharMatcher matcher = CharMatcher.oneOf(&quot;aeiou&quot;).negate(); CharMatcher  matcher =  CharMatcher .inRange('a', 'z').or(inRange('A', 'Z')); matcher.matchesAllOf(“some string”); matcher.matchesAnyOf(“other string”);  … String s = Joiner.on(&quot;, &quot;).join(episodesOnDisc); … StringBuilder  sb = ...; Joiner .on(&quot;|&quot;).skipNulls().appendTo(sb, episodesOnDisc);
Useful Libraries - guava-libraries Example 3: Collections2 List < Integer > integers = ... Collection < String > results; results =  Collections2 . transform (integers, new  Function < Integer ,  String >() { public  String apply(Integer input) { return  Integer.toString(input*2); } }); Collection < Integer > evens; evens =  Collections2 . filter (integers, new  Predicate < Integer >() { public  boolean apply( Integer  input) { return  0 == input % 2; } });
Useful Tools ,[object Object]
ecl Emma
XMind
Useful Tools - moreUnit ,[object Object]
Marks methods under test.
Jump to a test via the menu or Ctrl+J
Run a test from the class via the menu or Ctrl-R
Rename classes/methods.
Move classes and MoreUnit will move the corresponding test cases.
Generate a test class/method. http://moreunit.sourceforge.net/
Useful Tools - eclEmma ,[object Object]

Weitere ähnliche Inhalte

Was ist angesagt?

Adam Peller Interoperable Ajax Tools And Mashups
Adam Peller Interoperable Ajax Tools And MashupsAdam Peller Interoperable Ajax Tools And Mashups
Adam Peller Interoperable Ajax Tools And MashupsAjax Experience 2009
 
DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)Hendrik Ebbers
 
What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8javafxpert
 
PHP 7 Crash Course
PHP 7 Crash CoursePHP 7 Crash Course
PHP 7 Crash CourseColin O'Dell
 
Swiss army knife Spring
Swiss army knife SpringSwiss army knife Spring
Swiss army knife SpringMario Fusco
 
Dependency Injection Smells
Dependency Injection SmellsDependency Injection Smells
Dependency Injection SmellsMatthias Noback
 
Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipseanshunjain
 
DRYing to Monad in Java8
DRYing to Monad in Java8DRYing to Monad in Java8
DRYing to Monad in Java8Dhaval Dalal
 
Object Oriented PHP - PART-2
Object Oriented PHP - PART-2Object Oriented PHP - PART-2
Object Oriented PHP - PART-2Jalpesh Vasa
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsJeff Durta
 
Testing persistence in PHP with DbUnit
Testing persistence in PHP with DbUnitTesting persistence in PHP with DbUnit
Testing persistence in PHP with DbUnitPeter Wilcsinszky
 
Javaslang Talk @ Javaland 2017
Javaslang Talk @ Javaland 2017Javaslang Talk @ Javaland 2017
Javaslang Talk @ Javaland 2017David Schmitz
 
What's Coming in Spring 3.0
What's Coming in Spring 3.0What's Coming in Spring 3.0
What's Coming in Spring 3.0Matt Raible
 
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)DevelopIntelligence
 
Web注入+http漏洞等描述
Web注入+http漏洞等描述Web注入+http漏洞等描述
Web注入+http漏洞等描述fangjiafu
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadDavid Gómez García
 
PHP: 4 Design Patterns to Make Better Code
PHP: 4 Design Patterns to Make Better CodePHP: 4 Design Patterns to Make Better Code
PHP: 4 Design Patterns to Make Better CodeSWIFTotter Solutions
 

Was ist angesagt? (19)

Adam Peller Interoperable Ajax Tools And Mashups
Adam Peller Interoperable Ajax Tools And MashupsAdam Peller Interoperable Ajax Tools And Mashups
Adam Peller Interoperable Ajax Tools And Mashups
 
DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)
 
What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8
 
PHP 7 Crash Course
PHP 7 Crash CoursePHP 7 Crash Course
PHP 7 Crash Course
 
Swiss army knife Spring
Swiss army knife SpringSwiss army knife Spring
Swiss army knife Spring
 
Dependency Injection Smells
Dependency Injection SmellsDependency Injection Smells
Dependency Injection Smells
 
Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipse
 
Pragmatic sbt
Pragmatic sbtPragmatic sbt
Pragmatic sbt
 
DRYing to Monad in Java8
DRYing to Monad in Java8DRYing to Monad in Java8
DRYing to Monad in Java8
 
Object Oriented PHP - PART-2
Object Oriented PHP - PART-2Object Oriented PHP - PART-2
Object Oriented PHP - PART-2
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
Testing persistence in PHP with DbUnit
Testing persistence in PHP with DbUnitTesting persistence in PHP with DbUnit
Testing persistence in PHP with DbUnit
 
Phpunit testing
Phpunit testingPhpunit testing
Phpunit testing
 
Javaslang Talk @ Javaland 2017
Javaslang Talk @ Javaland 2017Javaslang Talk @ Javaland 2017
Javaslang Talk @ Javaland 2017
 
What's Coming in Spring 3.0
What's Coming in Spring 3.0What's Coming in Spring 3.0
What's Coming in Spring 3.0
 
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
 
Web注入+http漏洞等描述
Web注入+http漏洞等描述Web注入+http漏洞等描述
Web注入+http漏洞等描述
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidad
 
PHP: 4 Design Patterns to Make Better Code
PHP: 4 Design Patterns to Make Better CodePHP: 4 Design Patterns to Make Better Code
PHP: 4 Design Patterns to Make Better Code
 

Ähnlich wie Bring the fun back to java

Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)David McCarter
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentationipolevoy
 
Jquery Plugin
Jquery PluginJquery Plugin
Jquery PluginRavi Mone
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestSeb Rose
 
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Iakiv Kramarenko
 
Functional Testing Swing Applications with Frankenstein
Functional Testing Swing Applications with FrankensteinFunctional Testing Swing Applications with Frankenstein
Functional Testing Swing Applications with Frankensteinvivek_prahlad
 
Xopus Application Framework
Xopus Application FrameworkXopus Application Framework
Xopus Application FrameworkJady Yang
 
"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James NelsonGWTcon
 
SystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features SummarySystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features SummaryAmal Khailtash
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Mastering the Sling Rewriter by Justin Edelson
Mastering the Sling Rewriter by Justin EdelsonMastering the Sling Rewriter by Justin Edelson
Mastering the Sling Rewriter by Justin EdelsonAEM HUB
 
Mastering the Sling Rewriter
Mastering the Sling RewriterMastering the Sling Rewriter
Mastering the Sling RewriterJustin Edelson
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptdavejohnson
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Guillaume Laforge
 
Working Effectively With Legacy Perl Code
Working Effectively With Legacy Perl CodeWorking Effectively With Legacy Perl Code
Working Effectively With Legacy Perl Codeerikmsp
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to JavaSMIJava
 

Ähnlich wie Bring the fun back to java (20)

Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)
 
J Unit
J UnitJ Unit
J Unit
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
 
Jquery Plugin
Jquery PluginJquery Plugin
Jquery Plugin
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
 
Functional Testing Swing Applications with Frankenstein
Functional Testing Swing Applications with FrankensteinFunctional Testing Swing Applications with Frankenstein
Functional Testing Swing Applications with Frankenstein
 
Xopus Application Framework
Xopus Application FrameworkXopus Application Framework
Xopus Application Framework
 
"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson
 
SystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features SummarySystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features Summary
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Mastering the Sling Rewriter by Justin Edelson
Mastering the Sling Rewriter by Justin EdelsonMastering the Sling Rewriter by Justin Edelson
Mastering the Sling Rewriter by Justin Edelson
 
Mastering the Sling Rewriter
Mastering the Sling RewriterMastering the Sling Rewriter
Mastering the Sling Rewriter
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
Working Effectively With Legacy Perl Code
Working Effectively With Legacy Perl CodeWorking Effectively With Legacy Perl Code
Working Effectively With Legacy Perl Code
 
Javascript Best Practices
Javascript Best PracticesJavascript Best Practices
Javascript Best Practices
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to Java
 

Kürzlich hochgeladen

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Kürzlich hochgeladen (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Bring the fun back to java

  • 1. Bring the FUN back to Java development Set of tools, making development easier Illarion Kovalchuk © 2011
  • 2.
  • 3.
  • 4. Approach Use the right tools! Keep It Simple Write less code, write clean code Always consider the context
  • 5. Overview – the stuff I'd like to talk about
  • 6.
  • 9. Useful Libraries http://code.google.com/p/mockito/ Mockito is a mocking framework that tastes really good. It lets you write beautiful tests with clean & simple API. Mockito doesn't give you hangover because the tests are very readable and they produce clean verification errors.
  • 13. Useful Libraries - Mockito SLIDE FOR THOSE, WHO CAN READ SO MUCH CODE
  • 14. Useful Libraries Put simply, Guice alleviates the need for factories and the use of new in your Java code. Think of Guice's  @Inject  as the new new http://code.google.com/p/google-guice/ google-guice
  • 15. Useful Libraries – google-guice public class BillingModule extends AbstractModule { @Override protected void configure () { bind( TransactionLog .class).to( Database TransactionLog .class); bind( CreditCardProcessor .class).to( Paypal CreditCardProcessor .class); bind( BillingService .class).to( Real BillingService .class); } } Setup
  • 16. Useful Libraries – google-guice public class BillingModule extends AbstractModule { @Override protected void configure () { bind( TransactionLog .class).to( Database TransactionLog .class); bind( CreditCardProcessor .class).to( Paypal CreditCardProcessor .class); bind( BillingService .class).to( Real BillingService .class); } } Setup @Inject public RealBillingService ( CreditCardProcessor processor, TransactionLog log ) { this .processor = processor; this .log = log; } Inject
  • 17. Useful Libraries – google-guice public class BillingModule extends AbstractModule { @Override protected void configure () { bind( TransactionLog .class).to( Database TransactionLog .class); bind( CreditCardProcessor .class).to( Paypal CreditCardProcessor .class); bind( BillingService .class).to( Real BillingService .class); } } Setup @Inject public RealBillingService ( CreditCardProcessor processor, TransactionLog log ) { this .processor = processor; this .log = log; } Inject public static void main( String [] args) { Injector injector = Guice .createInjector(new BillingModule ()); BillingService billingService = injector.getInstance( BillingService .class); ... } Launch!
  • 18. Useful Libraries The Guava project contains several of Google's core libraries that we rely on in our Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so forth. guava-libraries http://code.google.com/p/guava-libraries/
  • 19. Useful Libraries - guava-libraries Example 1: Objects public class Person { final String name, nickname; final Movie favMovie; @Override public boolean equals(Object object) { if (object instanceof Person) { Person that = ( Person ) object; return Objects .equal(this.name, that.name) && Objects .equal(this.nickname, that.nickname) && Objects .equal(this.favMovie, that.favMovie); } return false; } @Override public int hashCode() { return Objects .hashCode(name, nickname, favMovie); }
  • 20. Useful Libraries - guava-libraries Example 2: Other useful things Preconditions .checkState(state == State .PLAYABLE, &quot;Can't play movie; state is %s&quot; , state); //will throw ISE with message … this.rating = Preconditio ns.checkNotNull(rating); //will throw NPE … //CharMatcher matcher = CharMatcher.is('x'); //CharMatcher matcher = CharMatcher.isNot('_'); //CharMatcher matcher = CharMatcher.oneOf(&quot;aeiou&quot;).negate(); CharMatcher matcher = CharMatcher .inRange('a', 'z').or(inRange('A', 'Z')); matcher.matchesAllOf(“some string”); matcher.matchesAnyOf(“other string”); … String s = Joiner.on(&quot;, &quot;).join(episodesOnDisc); … StringBuilder sb = ...; Joiner .on(&quot;|&quot;).skipNulls().appendTo(sb, episodesOnDisc);
  • 21. Useful Libraries - guava-libraries Example 3: Collections2 List < Integer > integers = ... Collection < String > results; results = Collections2 . transform (integers, new Function < Integer , String >() { public String apply(Integer input) { return Integer.toString(input*2); } }); Collection < Integer > evens; evens = Collections2 . filter (integers, new Predicate < Integer >() { public boolean apply( Integer input) { return 0 == input % 2; } });
  • 22.
  • 24. XMind
  • 25.
  • 27. Jump to a test via the menu or Ctrl+J
  • 28. Run a test from the class via the menu or Ctrl-R
  • 30. Move classes and MoreUnit will move the corresponding test cases.
  • 31. Generate a test class/method. http://moreunit.sourceforge.net/
  • 32.
  • 33. Coverage results are immediately summarized and highlighted.
  • 34. Does not require modifying projects or performing any other setup. EclEmma is a free Java code coverage tool for  Eclipse http://www.eclemma.org/index.html http://emma.sourceforge.net/
  • 35.
  • 36. Powerful tool to organize your thoughts XMind is your friend! http://www.xmind.net/
  • 37.
  • 39. Do not write so many unit tests, as they tell you!
  • 41.
  • 42. Hard to read – what is that null parameter for, or what's 5?
  • 43.
  • 44.
  • 46. Can have checks in build(), to ensure the result correctness.
  • 47. Result can have no setters or modifiers – safe to work with.
  • 48. Coding techniques Verbose unit tests @Test public void testProcess(){ … } @Test public void testRegister(){ … } …
  • 49. Coding techniques Verbose unit tests @Test public void process Should FailOnNull(){…} @Test public void process Should WorkOnEmptyString(){…} @Test public void process Should CheckSemicolons(){…} … @Test public void register Should FailOnNull(){…} @Test public void register Should CallProcess (){…} … Friend of you the “ SHOULD ” is @Test public void testProcess(){ … } @Test public void testRegister(){ … } …
  • 50. Coding techniques Do not write so many unit tests as they tell you “ Cargo cult programming is a style of  computer programming  that is characterized by the ritual inclusion of code or program structures that serve no real purpose. ” Wikipedia Wikipedia 100% code coverage
  • 51.
  • 52. Tests quantity != tests quality
  • 53. The fact that the line of code was called is just a “smoke test”
  • 54. Unit tests cannot replace other tests
  • 55. Coding techniques Avoid String-typing public class User { … public User(String login, String password, String home, String shell) { … } … } String login = … String password = … String home = … String shell = … User user = new User(login, password, home, shell); User user = new User(password, home, login, “ “);
  • 56. Coding techniques Avoid String-typing public class User { … public User(Login login, Password password, Home home, Shell shell) { … } … } Login login = … Password password = … Home home = … Shell shell = … User user = new User(login, password, home, shell); User user = new User(password, home, login, “ “); // – will not compile Or use a builder pattern, keeping String as type of all these parameters