SlideShare a Scribd company logo
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 1@CoverosGene #CodeMash
Creative Solutions to
Already Solved Problems
Gene Gotimer
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 2@CoverosGene #CodeMash
Let us help you
Please think before you code
Your IDE will warn you
Analysis will point out problems
It’s dangerous to go alone. Ask for help
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 3@CoverosGene #CodeMash
Make sure it is imported
import java.util.Date;
import java.lang.Boolean;
import java.lang.Boolean;
import java.sql.Timestamp;
import java.lang.Boolean;
import java.lang.Boolean;
import java.lang.Boolean;
import java.util.Date;
1
2
1
2
3
4
5
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 4@CoverosGene #CodeMash
Make sure it is really a String
ArrayList<String> xqueries = new ArrayList<String>();
xqueries.add("/EnrollReq/SenderID/text()");
xqueries.add("/EnrollReq/TransInfo/CurrentTime/text()");
List<String> forMap = execXPath(xqueries.get(0).toString());
if(forMap.size() > 0){
retMap.put("SenderID", forMap.get(0).toString());
}else{
retMap.put("SenderID", "");
}
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 5@CoverosGene #CodeMash
Trust issues with version control
LinkUsers.java
LinkUsers.javaold
LoginAccountImpl.java
ManageAcctImpl.java
ManageAcctImpl.java_OLD
AppDaoImpl.javanew
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 6@CoverosGene #CodeMash
Concrete Strategy Factory Pattern
public class EnrollStrategyFactory {
private static EnrollStrategyFactory strtgyFctry = null;
private EnrollStrategy strtgy = new EnrollStrategy();
…
public EnrollStrategy getStrategy() {
return strtgy;
}
}
public class EnrollStrategy {…}
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 7@CoverosGene #CodeMash
That darned ternary operator
boolean srcReuseData;
srcReuseData = (true ? this.isReuseData():false);
So when true is true,
srcReuseData = this.isReuseData().
If true is not true,
srcReuseData = false and maybe chaos?
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 8@CoverosGene #CodeMash
Spell it all out
boolean boolResult = false;
if (hashResult > 0)
boolResult = true;
else
boolResult = false;
assertEquals("HashCode returned was not returned",
true, boolResult);
as opposed to
assertTrue("HashCode should be a positive integer",
hashResult > 0);
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 9@CoverosGene #CodeMash
Never don’t be not clear
fail("Did not throw a configuration exception when MyParser
was not configured with mappings");
fail("Did not throw a configuration exception when the
configuration property for MyParser had an
invalid value");
fail("Did not throw a configuration exception when MyParser
configuration referenced a role that does
not exist");
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 10@CoverosGene #CodeMash
Always check for blank. Always.
if (!(retrievedList == null
|| "".equals(retrievedList))) {
if (person.getBirthDate() != null
&& !person.getBirthDate().equals("")) {
if (person.getGender() != null
&& !person.getGender().equals("")) {
if (org.getPeriodEndDate() != null
&& !org.getPeriodEndDate().equals("")) {
String[]
java.util.Date
pkg.Gender
java.util.Date
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 11@CoverosGene #CodeMash
Just snuck over the limit
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 12@CoverosGene #CodeMash
Strive to be #1
3004 public static MemberEvent memberEventMapper(
3005 MemberEventDTO memberEventDto) {
3006 MemberEvent memberEvent = new MemberEvent();
…
4336 return memberEvent;
4337 }
Method lines of code: 1,334 (top is 1,793)
Method complexity: 256 #1
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 13@CoverosGene #CodeMash
Just a simple DTO
1 …
comments and annotations
1346 public class PersonResultsDTO
1347 {
…
43734 }
43735
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 14@CoverosGene #CodeMash
Test all the things, literally
for (Method method : object.getClass().getMethods()) {
if (method.getName.startsWith("set")) {
if (method.getParameterTypes().length > 0) {
Class paramClass = method.getParameterTypes()[0];
if (paramClass.getName.equals("java.lang.String")) {
method.invoke(object, "JUNIT TEST");
} else if (paramClass.getName.equals("java.lang.Object")) {
method.invoke(object, new Object());
} else if (paramClass.getName.equals("java.util.Date")) {
method.invoke(object, new java.util.Date());
} else if (paramClass.getName.equals("java.math.BigDecimal")) {
method.invoke(object, new BigDecimal(100));
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 15@CoverosGene #CodeMash
Well, I can’t just leave it empty
try {
…
} catch (Exception e) {
e.getMessage();
}
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 16@CoverosGene #CodeMash
Exception inception
try {
…
} catch (Exception e) {
try {
throw e;
} catch (Exception e1) {
e1.printStackTrace();
}
}
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 17@CoverosGene #CodeMash
Tests have exceptions, too
public Member generateTestMember(){
Member member = new Member();
…
return null;
}
@Test(expected = RuntimeException.class)
public void testAddTaxCreditSuccess() throws Exception {
Member person = generateTestMember();
String spouseId = person.findSpouseId();
assertNotNull(service.addTaxCredit(person, spouseId));
}
2
1
3
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 18@CoverosGene #CodeMash
I’d like to buy a constant
public static final String DASH = "-";
public static final String MANAGE_ACTION_0 = "0";
public static final String MANAGE_ACTION_1 = "1";
public static final String MANAGE_ACTION_2 = "2";
public static final String MANAGE_ACTION_3 = "3";
public static final String MANAGE_ACTION_4 = "4";
…
public static final String MANAGE_ACTION_17 = "17";
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 19@CoverosGene #CodeMash
Just give them descriptive names
// BigInteger ONE
public static final BigInteger BIGINTEGER_ONE = BigInteger.ONE;
// BigInteger ZERO
public static final BigInteger BIGINTEGER_ZERO = BigInteger.ZERO;
// BIGDECIMAL ZERO
public static final BigDecimal BIGDECIMAL_ZERO = BigDecimal.ZERO;
/** The Constant Y_INDICATOR. */
protected static final String Y_INDICATOR = "Y";
/** The Constant N_INDICATOR. */
protected static final String N_INDICATOR = "N";
© COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 20@CoverosGene #CodeMash
What if the values change?
public static final boolean BOOL_TRUE = true;
public static final boolean BOOL_FALSE = false;

More Related Content

Similar to Creative Solutions to Already Solved Problems

Java Puzzlers NG S02: Down the Rabbit Hole as presented at DevNexus 2017
Java Puzzlers NG S02: Down the Rabbit Hole as presented at DevNexus 2017Java Puzzlers NG S02: Down the Rabbit Hole as presented at DevNexus 2017
Java Puzzlers NG S02: Down the Rabbit Hole as presented at DevNexus 2017
Baruch Sadogursky
 
A Definition of Done for DevSecOps
A Definition of Done for DevSecOpsA Definition of Done for DevSecOps
A Definition of Done for DevSecOps
Gene Gotimer
 
Finding bugs that matter with Findbugs
Finding bugs that matter with FindbugsFinding bugs that matter with Findbugs
Finding bugs that matter with FindbugsCarol McDonald
 
Build a Chatbot with TensorFlow.js and Twilio
Build a Chatbot with TensorFlow.js and TwilioBuild a Chatbot with TensorFlow.js and Twilio
Build a Chatbot with TensorFlow.js and Twilio
Elizabeth (Lizzie) Siegle
 
Getting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with ThymeleafGetting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with Thymeleaf
Masatoshi Tada
 
Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)
Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)
Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)
Gáspár Nagy
 
DevConfZA 2020 : Automating your cloud: What are the building blocks
DevConfZA 2020 : Automating your cloud: What are the building blocksDevConfZA 2020 : Automating your cloud: What are the building blocks
DevConfZA 2020 : Automating your cloud: What are the building blocks
Cobus Bernard
 
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (Qualit...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (Qualit...Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (Qualit...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (Qualit...
Gáspár Nagy
 
Keeping Up with Java: Look at All These New Features!
Keeping Up with Java: Look at All These New Features!Keeping Up with Java: Look at All These New Features!
Keeping Up with Java: Look at All These New Features!
VMware Tanzu
 
Face detection myriad_批次檔
Face detection myriad_批次檔Face detection myriad_批次檔
Face detection myriad_批次檔
MAKERPRO.cc
 
BDD in iOS with Cedar
BDD in iOS with CedarBDD in iOS with Cedar
BDD in iOS with Cedar
Jason McCreary
 
Java Puzzlers NG S02: Down the Rabbit Hole as presented at Devoxx US 2017
Java Puzzlers NG S02: Down the Rabbit Hole as presented at Devoxx US 2017Java Puzzlers NG S02: Down the Rabbit Hole as presented at Devoxx US 2017
Java Puzzlers NG S02: Down the Rabbit Hole as presented at Devoxx US 2017
Baruch Sadogursky
 
Clean Unit Tests
Clean Unit Tests Clean Unit Tests
Clean Unit Tests
Manana Koberidze
 
.NET Coding Standards For The Real World (2012)
.NET Coding Standards For The Real World (2012).NET Coding Standards For The Real World (2012)
.NET Coding Standards For The Real World (2012)
David McCarter
 
SCULPT! YOUR! TESTS!
SCULPT! YOUR! TESTS!SCULPT! YOUR! TESTS!
SCULPT! YOUR! TESTS!
Taras Oleksyn
 
Test Infected Presentation
Test Infected PresentationTest Infected Presentation
Test Infected Presentation
willmation
 
Priming Java for Speed at Market Open
Priming Java for Speed at Market OpenPriming Java for Speed at Market Open
Priming Java for Speed at Market Open
Azul Systems Inc.
 
2022 APIsecure_API Security Testing: The Next Step in Modernizing AppSec
2022 APIsecure_API Security Testing: The Next Step in Modernizing AppSec2022 APIsecure_API Security Testing: The Next Step in Modernizing AppSec
2022 APIsecure_API Security Testing: The Next Step in Modernizing AppSec
APIsecure_ Official
 
DevOpsDays Baltimore 2018: A Definition of Done for DevSecOps - Gene Gotimer
DevOpsDays Baltimore 2018: A Definition of Done for DevSecOps - Gene GotimerDevOpsDays Baltimore 2018: A Definition of Done for DevSecOps - Gene Gotimer
DevOpsDays Baltimore 2018: A Definition of Done for DevSecOps - Gene Gotimer
DevOpsDays Baltimore
 

Similar to Creative Solutions to Already Solved Problems (20)

Java Puzzlers NG S02: Down the Rabbit Hole as presented at DevNexus 2017
Java Puzzlers NG S02: Down the Rabbit Hole as presented at DevNexus 2017Java Puzzlers NG S02: Down the Rabbit Hole as presented at DevNexus 2017
Java Puzzlers NG S02: Down the Rabbit Hole as presented at DevNexus 2017
 
A Definition of Done for DevSecOps
A Definition of Done for DevSecOpsA Definition of Done for DevSecOps
A Definition of Done for DevSecOps
 
Finding bugs that matter with Findbugs
Finding bugs that matter with FindbugsFinding bugs that matter with Findbugs
Finding bugs that matter with Findbugs
 
Build a Chatbot with TensorFlow.js and Twilio
Build a Chatbot with TensorFlow.js and TwilioBuild a Chatbot with TensorFlow.js and Twilio
Build a Chatbot with TensorFlow.js and Twilio
 
Getting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with ThymeleafGetting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with Thymeleaf
 
Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)
Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)
Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
DevConfZA 2020 : Automating your cloud: What are the building blocks
DevConfZA 2020 : Automating your cloud: What are the building blocksDevConfZA 2020 : Automating your cloud: What are the building blocks
DevConfZA 2020 : Automating your cloud: What are the building blocks
 
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (Qualit...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (Qualit...Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (Qualit...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (Qualit...
 
Keeping Up with Java: Look at All These New Features!
Keeping Up with Java: Look at All These New Features!Keeping Up with Java: Look at All These New Features!
Keeping Up with Java: Look at All These New Features!
 
Face detection myriad_批次檔
Face detection myriad_批次檔Face detection myriad_批次檔
Face detection myriad_批次檔
 
BDD in iOS with Cedar
BDD in iOS with CedarBDD in iOS with Cedar
BDD in iOS with Cedar
 
Java Puzzlers NG S02: Down the Rabbit Hole as presented at Devoxx US 2017
Java Puzzlers NG S02: Down the Rabbit Hole as presented at Devoxx US 2017Java Puzzlers NG S02: Down the Rabbit Hole as presented at Devoxx US 2017
Java Puzzlers NG S02: Down the Rabbit Hole as presented at Devoxx US 2017
 
Clean Unit Tests
Clean Unit Tests Clean Unit Tests
Clean Unit Tests
 
.NET Coding Standards For The Real World (2012)
.NET Coding Standards For The Real World (2012).NET Coding Standards For The Real World (2012)
.NET Coding Standards For The Real World (2012)
 
SCULPT! YOUR! TESTS!
SCULPT! YOUR! TESTS!SCULPT! YOUR! TESTS!
SCULPT! YOUR! TESTS!
 
Test Infected Presentation
Test Infected PresentationTest Infected Presentation
Test Infected Presentation
 
Priming Java for Speed at Market Open
Priming Java for Speed at Market OpenPriming Java for Speed at Market Open
Priming Java for Speed at Market Open
 
2022 APIsecure_API Security Testing: The Next Step in Modernizing AppSec
2022 APIsecure_API Security Testing: The Next Step in Modernizing AppSec2022 APIsecure_API Security Testing: The Next Step in Modernizing AppSec
2022 APIsecure_API Security Testing: The Next Step in Modernizing AppSec
 
DevOpsDays Baltimore 2018: A Definition of Done for DevSecOps - Gene Gotimer
DevOpsDays Baltimore 2018: A Definition of Done for DevSecOps - Gene GotimerDevOpsDays Baltimore 2018: A Definition of Done for DevSecOps - Gene Gotimer
DevOpsDays Baltimore 2018: A Definition of Done for DevSecOps - Gene Gotimer
 

More from Gene Gotimer

A Developer’s Guide to Kubernetes Security
A Developer’s Guide to Kubernetes SecurityA Developer’s Guide to Kubernetes Security
A Developer’s Guide to Kubernetes Security
Gene Gotimer
 
How I Learned to Stop Worrying and Love Legacy Code
How I Learned to Stop Worrying and Love Legacy CodeHow I Learned to Stop Worrying and Love Legacy Code
How I Learned to Stop Worrying and Love Legacy Code
Gene Gotimer
 
Ten Ways To Doom Your DevOps
Ten Ways To Doom Your DevOpsTen Ways To Doom Your DevOps
Ten Ways To Doom Your DevOps
Gene Gotimer
 
Keeping Your Kubernetes Cluster Secure
Keeping Your Kubernetes Cluster SecureKeeping Your Kubernetes Cluster Secure
Keeping Your Kubernetes Cluster Secure
Gene Gotimer
 
Keeping your Kubernetes Cluster Secure
Keeping your Kubernetes Cluster SecureKeeping your Kubernetes Cluster Secure
Keeping your Kubernetes Cluster Secure
Gene Gotimer
 
Explain DevOps To Me Like I’m Five: DevOps for Managers
Explain DevOps To Me Like I’m Five: DevOps for ManagersExplain DevOps To Me Like I’m Five: DevOps for Managers
Explain DevOps To Me Like I’m Five: DevOps for Managers
Gene Gotimer
 
Keeping your Kubernetes Cluster Secure
Keeping your Kubernetes Cluster SecureKeeping your Kubernetes Cluster Secure
Keeping your Kubernetes Cluster Secure
Gene Gotimer
 
DevOps for Leadership
DevOps for LeadershipDevOps for Leadership
DevOps for Leadership
Gene Gotimer
 
Pyramid Discussion: DevOps Adoption in Large, Slow Organizations
Pyramid Discussion: DevOps Adoption in Large, Slow OrganizationsPyramid Discussion: DevOps Adoption in Large, Slow Organizations
Pyramid Discussion: DevOps Adoption in Large, Slow Organizations
Gene Gotimer
 
A better faster pipeline for software delivery, even in the government
A better faster pipeline for software delivery, even in the governmentA better faster pipeline for software delivery, even in the government
A better faster pipeline for software delivery, even in the government
Gene Gotimer
 
Building the Pipeline of My Dreams
Building the Pipeline of My DreamsBuilding the Pipeline of My Dreams
Building the Pipeline of My Dreams
Gene Gotimer
 
Tests Your Pipeline Might Be Missing
Tests Your Pipeline Might Be MissingTests Your Pipeline Might Be Missing
Tests Your Pipeline Might Be Missing
Gene Gotimer
 
A Better, Faster Pipeline for Software Delivery
A Better, Faster Pipeline for Software DeliveryA Better, Faster Pipeline for Software Delivery
A Better, Faster Pipeline for Software Delivery
Gene Gotimer
 
Open Source Security Tools for the Pipeline
Open Source Security Tools for the PipelineOpen Source Security Tools for the Pipeline
Open Source Security Tools for the Pipeline
Gene Gotimer
 
Which Development Metrics Should I Watch?
Which Development Metrics Should I Watch?Which Development Metrics Should I Watch?
Which Development Metrics Should I Watch?
Gene Gotimer
 
Add Security Testing Tools to Your Delivery Pipeline
Add Security Testing Tools to Your Delivery PipelineAdd Security Testing Tools to Your Delivery Pipeline
Add Security Testing Tools to Your Delivery Pipeline
Gene Gotimer
 
Testing in a Continuous Delivery Pipeline - Better, Faster, Cheaper
Testing in a Continuous Delivery Pipeline - Better, Faster, CheaperTesting in a Continuous Delivery Pipeline - Better, Faster, Cheaper
Testing in a Continuous Delivery Pipeline - Better, Faster, Cheaper
Gene Gotimer
 
Experiences Bringing CD to a DoD Project
Experiences Bringing CD to a DoD ProjectExperiences Bringing CD to a DoD Project
Experiences Bringing CD to a DoD Project
Gene Gotimer
 
Bringing CD to the DoD
Bringing CD to the DoDBringing CD to the DoD
Bringing CD to the DoD
Gene Gotimer
 
Tests your pipeline might be missing
Tests your pipeline might be missingTests your pipeline might be missing
Tests your pipeline might be missing
Gene Gotimer
 

More from Gene Gotimer (20)

A Developer’s Guide to Kubernetes Security
A Developer’s Guide to Kubernetes SecurityA Developer’s Guide to Kubernetes Security
A Developer’s Guide to Kubernetes Security
 
How I Learned to Stop Worrying and Love Legacy Code
How I Learned to Stop Worrying and Love Legacy CodeHow I Learned to Stop Worrying and Love Legacy Code
How I Learned to Stop Worrying and Love Legacy Code
 
Ten Ways To Doom Your DevOps
Ten Ways To Doom Your DevOpsTen Ways To Doom Your DevOps
Ten Ways To Doom Your DevOps
 
Keeping Your Kubernetes Cluster Secure
Keeping Your Kubernetes Cluster SecureKeeping Your Kubernetes Cluster Secure
Keeping Your Kubernetes Cluster Secure
 
Keeping your Kubernetes Cluster Secure
Keeping your Kubernetes Cluster SecureKeeping your Kubernetes Cluster Secure
Keeping your Kubernetes Cluster Secure
 
Explain DevOps To Me Like I’m Five: DevOps for Managers
Explain DevOps To Me Like I’m Five: DevOps for ManagersExplain DevOps To Me Like I’m Five: DevOps for Managers
Explain DevOps To Me Like I’m Five: DevOps for Managers
 
Keeping your Kubernetes Cluster Secure
Keeping your Kubernetes Cluster SecureKeeping your Kubernetes Cluster Secure
Keeping your Kubernetes Cluster Secure
 
DevOps for Leadership
DevOps for LeadershipDevOps for Leadership
DevOps for Leadership
 
Pyramid Discussion: DevOps Adoption in Large, Slow Organizations
Pyramid Discussion: DevOps Adoption in Large, Slow OrganizationsPyramid Discussion: DevOps Adoption in Large, Slow Organizations
Pyramid Discussion: DevOps Adoption in Large, Slow Organizations
 
A better faster pipeline for software delivery, even in the government
A better faster pipeline for software delivery, even in the governmentA better faster pipeline for software delivery, even in the government
A better faster pipeline for software delivery, even in the government
 
Building the Pipeline of My Dreams
Building the Pipeline of My DreamsBuilding the Pipeline of My Dreams
Building the Pipeline of My Dreams
 
Tests Your Pipeline Might Be Missing
Tests Your Pipeline Might Be MissingTests Your Pipeline Might Be Missing
Tests Your Pipeline Might Be Missing
 
A Better, Faster Pipeline for Software Delivery
A Better, Faster Pipeline for Software DeliveryA Better, Faster Pipeline for Software Delivery
A Better, Faster Pipeline for Software Delivery
 
Open Source Security Tools for the Pipeline
Open Source Security Tools for the PipelineOpen Source Security Tools for the Pipeline
Open Source Security Tools for the Pipeline
 
Which Development Metrics Should I Watch?
Which Development Metrics Should I Watch?Which Development Metrics Should I Watch?
Which Development Metrics Should I Watch?
 
Add Security Testing Tools to Your Delivery Pipeline
Add Security Testing Tools to Your Delivery PipelineAdd Security Testing Tools to Your Delivery Pipeline
Add Security Testing Tools to Your Delivery Pipeline
 
Testing in a Continuous Delivery Pipeline - Better, Faster, Cheaper
Testing in a Continuous Delivery Pipeline - Better, Faster, CheaperTesting in a Continuous Delivery Pipeline - Better, Faster, Cheaper
Testing in a Continuous Delivery Pipeline - Better, Faster, Cheaper
 
Experiences Bringing CD to a DoD Project
Experiences Bringing CD to a DoD ProjectExperiences Bringing CD to a DoD Project
Experiences Bringing CD to a DoD Project
 
Bringing CD to the DoD
Bringing CD to the DoDBringing CD to the DoD
Bringing CD to the DoD
 
Tests your pipeline might be missing
Tests your pipeline might be missingTests your pipeline might be missing
Tests your pipeline might be missing
 

Recently uploaded

Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
Google
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 

Recently uploaded (20)

Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 

Creative Solutions to Already Solved Problems

  • 1. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 1@CoverosGene #CodeMash Creative Solutions to Already Solved Problems Gene Gotimer
  • 2. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 2@CoverosGene #CodeMash Let us help you Please think before you code Your IDE will warn you Analysis will point out problems It’s dangerous to go alone. Ask for help
  • 3. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 3@CoverosGene #CodeMash Make sure it is imported import java.util.Date; import java.lang.Boolean; import java.lang.Boolean; import java.sql.Timestamp; import java.lang.Boolean; import java.lang.Boolean; import java.lang.Boolean; import java.util.Date; 1 2 1 2 3 4 5
  • 4. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 4@CoverosGene #CodeMash Make sure it is really a String ArrayList<String> xqueries = new ArrayList<String>(); xqueries.add("/EnrollReq/SenderID/text()"); xqueries.add("/EnrollReq/TransInfo/CurrentTime/text()"); List<String> forMap = execXPath(xqueries.get(0).toString()); if(forMap.size() > 0){ retMap.put("SenderID", forMap.get(0).toString()); }else{ retMap.put("SenderID", ""); }
  • 5. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 5@CoverosGene #CodeMash Trust issues with version control LinkUsers.java LinkUsers.javaold LoginAccountImpl.java ManageAcctImpl.java ManageAcctImpl.java_OLD AppDaoImpl.javanew
  • 6. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 6@CoverosGene #CodeMash Concrete Strategy Factory Pattern public class EnrollStrategyFactory { private static EnrollStrategyFactory strtgyFctry = null; private EnrollStrategy strtgy = new EnrollStrategy(); … public EnrollStrategy getStrategy() { return strtgy; } } public class EnrollStrategy {…}
  • 7. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 7@CoverosGene #CodeMash That darned ternary operator boolean srcReuseData; srcReuseData = (true ? this.isReuseData():false); So when true is true, srcReuseData = this.isReuseData(). If true is not true, srcReuseData = false and maybe chaos?
  • 8. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 8@CoverosGene #CodeMash Spell it all out boolean boolResult = false; if (hashResult > 0) boolResult = true; else boolResult = false; assertEquals("HashCode returned was not returned", true, boolResult); as opposed to assertTrue("HashCode should be a positive integer", hashResult > 0);
  • 9. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 9@CoverosGene #CodeMash Never don’t be not clear fail("Did not throw a configuration exception when MyParser was not configured with mappings"); fail("Did not throw a configuration exception when the configuration property for MyParser had an invalid value"); fail("Did not throw a configuration exception when MyParser configuration referenced a role that does not exist");
  • 10. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 10@CoverosGene #CodeMash Always check for blank. Always. if (!(retrievedList == null || "".equals(retrievedList))) { if (person.getBirthDate() != null && !person.getBirthDate().equals("")) { if (person.getGender() != null && !person.getGender().equals("")) { if (org.getPeriodEndDate() != null && !org.getPeriodEndDate().equals("")) { String[] java.util.Date pkg.Gender java.util.Date
  • 11. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 11@CoverosGene #CodeMash Just snuck over the limit
  • 12. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 12@CoverosGene #CodeMash Strive to be #1 3004 public static MemberEvent memberEventMapper( 3005 MemberEventDTO memberEventDto) { 3006 MemberEvent memberEvent = new MemberEvent(); … 4336 return memberEvent; 4337 } Method lines of code: 1,334 (top is 1,793) Method complexity: 256 #1
  • 13. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 13@CoverosGene #CodeMash Just a simple DTO 1 … comments and annotations 1346 public class PersonResultsDTO 1347 { … 43734 } 43735
  • 14. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 14@CoverosGene #CodeMash Test all the things, literally for (Method method : object.getClass().getMethods()) { if (method.getName.startsWith("set")) { if (method.getParameterTypes().length > 0) { Class paramClass = method.getParameterTypes()[0]; if (paramClass.getName.equals("java.lang.String")) { method.invoke(object, "JUNIT TEST"); } else if (paramClass.getName.equals("java.lang.Object")) { method.invoke(object, new Object()); } else if (paramClass.getName.equals("java.util.Date")) { method.invoke(object, new java.util.Date()); } else if (paramClass.getName.equals("java.math.BigDecimal")) { method.invoke(object, new BigDecimal(100));
  • 15. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 15@CoverosGene #CodeMash Well, I can’t just leave it empty try { … } catch (Exception e) { e.getMessage(); }
  • 16. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 16@CoverosGene #CodeMash Exception inception try { … } catch (Exception e) { try { throw e; } catch (Exception e1) { e1.printStackTrace(); } }
  • 17. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 17@CoverosGene #CodeMash Tests have exceptions, too public Member generateTestMember(){ Member member = new Member(); … return null; } @Test(expected = RuntimeException.class) public void testAddTaxCreditSuccess() throws Exception { Member person = generateTestMember(); String spouseId = person.findSpouseId(); assertNotNull(service.addTaxCredit(person, spouseId)); } 2 1 3
  • 18. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 18@CoverosGene #CodeMash I’d like to buy a constant public static final String DASH = "-"; public static final String MANAGE_ACTION_0 = "0"; public static final String MANAGE_ACTION_1 = "1"; public static final String MANAGE_ACTION_2 = "2"; public static final String MANAGE_ACTION_3 = "3"; public static final String MANAGE_ACTION_4 = "4"; … public static final String MANAGE_ACTION_17 = "17";
  • 19. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 19@CoverosGene #CodeMash Just give them descriptive names // BigInteger ONE public static final BigInteger BIGINTEGER_ONE = BigInteger.ONE; // BigInteger ZERO public static final BigInteger BIGINTEGER_ZERO = BigInteger.ZERO; // BIGDECIMAL ZERO public static final BigDecimal BIGDECIMAL_ZERO = BigDecimal.ZERO; /** The Constant Y_INDICATOR. */ protected static final String Y_INDICATOR = "Y"; /** The Constant N_INDICATOR. */ protected static final String N_INDICATOR = "N";
  • 20. © COPYRIGHT 2019 COVEROS, INC. ALL RIGHTS RESERVED. 20@CoverosGene #CodeMash What if the values change? public static final boolean BOOL_TRUE = true; public static final boolean BOOL_FALSE = false;