SlideShare a Scribd company logo
How to Improve Problem Solving
Skills
- JefferyYuan
Disclaimer
Just try to summarize what I have learned.
Why Problem-solving skills matters
Problem Solving and troubleshooting
»Is fun
»Is part of daily work
»Make us solve problem
• More efficiently
• With more confidence
• Less pressure
• Go home earlier
Why Problem-solving skills matters
»Solve the problem when needed
• no matter whether its not related with you
• It’s your responsibility if it blocks your or the team’s
work
Understand the problem/environment first
Understand the problem before google search otherwise it
may just lead you to totally wrong directions.
Find related log/data
Copy logs/info that maybe related
Check the Log and Error Message
Read/Understand the error message
Where to find log
Common places: /var/log
From command line:
-Dcassandra.logdir=/var/log/cassandra
Case Study – The Log and Error Message
Problem:
Failed to talk Cassandra server: 10.10.10.10
- Where 10.10.10.10 comes from?
gfind . -iname '*.jar' -printf "unzip -c %p | grep -q
10.10.10.10' && echo %pn" | sh
-It comes from commons2, what’s the current settings in
Github
-Now the problem and solution is clear: Just upgrade
commons2 to latest version
Source code is always the ultimate truth
Find related code in Github
Find examples/working code
Understand how/why the code works by running and
debug the code
Check the log with the code
- Most problems can be solved by checking log and source
code
Reproduce the problem
Find easier way to reproduce them
- main method, unit test, mock
Simplify the suspect code
- Find the code related, remove things not realtedUse
Reproduce locally
Connect to the remote data in local dev
Remote debug
- Last resort, slow
Solving Problem from Different Angles
Sometime we find problem in production and we need
code change to fix it
-Try to find whether we can fix a workaround by changing
database/Solr or other configuration
-We can fix code later
Find Information Effectively
Google search: error message, exception
Search source code in Github/Eclipse
Search log
Search in IDE
-- Cmd+alt+h, cmd+h
Search command history
-- history | grep git | grep erase
-- history | grep ssh | grep 9042
Know company’s internal resource – where to find them
Know some experts (in company) you can ask help from
Ask for help
From coworkers
Stackoverflow
Specific forums
http://lucene.472066.n3.nabble.com/Solr-f472067.html
- Provide context and info you find
- Ask help for same/similar things once, then you know
how to do it
- Learn the knowledge itself
- But also learn their thinking process
Fix same/similar/related problems in other places
We make mistakes in one place
It's very likely we make same/similar/related in other places
GetMapping(value = "/config/{name:.+}")
Knowledge
Be prepared
Know what problem may happen, the difference etc
Know the services/libraries you are using
Apache/Tomcat configuration
How to manage/troubleshoot Cassandra/Kafka/Solr
Knowledge
Practice - Redis cache.put Hangs
- Get threaddump, figure out what is happening when read from cache
- Read related code to figure out how Spring implements @Cacheable(sync=true)
RedisCache$RedisCachePutCallback
- Check whether there is cacheName~lock in redis
When use some feature, know how it's implemented.
Knowledge
Common Problems – More to add in future
Different versions of same library
- mvn dependency:tree
- mvn dependency:tree -Dverbose
-Dincludes=com.amazonaws:aws-java-sdk-core
Practice - Iterator vs Iterable
What’s the problem in the following Code?
@Cacheable(key = "#appName")
public Iterator<Message> findActiveMessages(final String
appName) {}
Practice - Iterator vs Iterable
How we find the root cause
- Symptoms: The function only works once in a while: when
cache is refreshed
- Difference between Iterator vs Iterable
- Don't use Iterator when need traverse multiple times
- Don't use Iterator as cache value
Practice 2 - Spring @Cacheable Not Working
The class using cache annotation inited too early
- Add a breakpoint at the default constructor of the bean, then from the stack trace
we can figure out why and which bean (or configuration class) causes this bean to be
created
- Understand how spring cache works internally, spring proxy
- CacheAspectSupport
Building Application to Be Troubleshooting Friendly
Debug Feature
Return debug info that can check from response without having to check the log
- Of course secured, protected
Mock User Feature
Preview Feature
In memory test users in test env
How to write test efficiently
Take time to learn:
Hamcrest, Mockito, JUnit, TestNG, REST Assured
Add Static Import
Preferences > Java > Editor > Content Assist > Favorites, then add:
org.hamcrest
org.hamcrest.Matchers.*
org.hamcrest.CoreMatchers.*
org.junit.*
org.junit.Assert.*
org.junit.Assume.*
org.junit.matchers.JUnitMatchers.*
org.mockito.Mockito
org.mockito.Matchers
org.mockito.ArgumentMatchers
io.restassured.RestAssured
Misc. – Part 1
Don't overcomplicate it.
- In most cases, the solution/problem is quite simple
Troubleshooting is about thinking what may go wrong.
Track what change you have made
Misc. – Part 2
When help others
-Ask what related change they have done
Ask help from others.
-Try to understand the problem and fix it by yourself first.
-Provide log or any information that may help others
understand the problem.
When work on urgent issues with others
-Collaborate timely
-Let others know what you are testing, what's your progress,
what you have found, what you will do next
-Listen to others
Misc. – Part 3
Think More
- Think over the code/problem, try to find better solution even it's already
fixed
Everything that stops you from working effectively is a problem
- No access, slack different teams etc
Fix them
Reflection: Lesson Learned
How we find the root cause
Why it takes so long
What we learned
What's the root cause
Why we made the mistake
How we can prevent this happens again
Share the knowledge in the team
Take time to solve problem, but only (take time to) solve it once
Tools - Eclipse
Use Conditional Breakpoint
to Execute Arbitrary Code (and automatically)
Use Display View to Execute Arbitrary Code
Find which jar containing the class and the application is using
- MediaType.class.getProtectionDomain().getCodeSource().getLocation()
Breakpoint doesn't work
- Multiple versions of same class or library
Practice - Connect to the remote data in local dev
Create a tunnel to zookeeper and solr nodes
Add a conditional breakpoint at
CloudSolrClient.sendRequest(SolrRequest, String)
- before LBHttpSolrClient.Req req = new LBHttpSolrClient.Req(request, theUrlList);
theUrlList.clear();
theUrlList.add("http://localhost:18983/solr/searchItems/");
theUrlList.add("http://localhost:28983/solr/searchItems/");
return false;
Tools - Decompiler
CFR
http://www.benf.org/other/cfr/
- Best, Support java8
JD-GUI
Sometimes, it doesn't work
Tools - Java
jcmd: One JDK Command-Line Tool to Rule Them All
jcmd <pid> Thread.print
jcmd <pid> GC.heap_dump <filename>
Thread dump Analyzer
http://fastthread.io/
Heap dump Analyzer
Eclipse MAT
VisualVM
Tools - Misc
Splunk
- After search and find the problem, use nearby Events +/- x seconds to show context
nc -zv; lsof; df;find;grep
Search Contents of .jar Files for Specific String
gfind . -iname '*.jar' -printf "unzip -c %p | grep -q
'string_to_search' && echo %pn" | s
Fiddler
Resource
Debug It!: Find, Repair, and Prevent Bugs in Your Code
Shameless plug
https://www.slideshare.net/lifelongprogrammer
http://lifelongprogrammer.blogspot.com/search/label/Problem%20Solving
http://lifelongprogrammer.blogspot.com/search/label/Troubleshooting
http://lifelongprogrammer.blogspot.com/search/label/Debug

More Related Content

What's hot

Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
REHAN IJAZ
 
1 introduction to problem solving and programming
1 introduction to problem solving and programming1 introduction to problem solving and programming
1 introduction to problem solving and programmingRheigh Henley Calderon
 
Debugging
DebuggingDebugging
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Rabin BK
 
pseudocode and Flowchart
pseudocode and Flowchartpseudocode and Flowchart
pseudocode and Flowchart
ALI RAZA
 
The Art Of Debugging
The Art Of DebuggingThe Art Of Debugging
The Art Of Debuggingsvilen.ivanov
 
Programming Fundamentals lecture 2
Programming Fundamentals lecture 2Programming Fundamentals lecture 2
Programming Fundamentals lecture 2
REHAN IJAZ
 
Problem solving
Problem solvingProblem solving
Problem solving
Dedi Supriyadi
 
Problem Solving
Problem SolvingProblem Solving
Problem Solving
rewa_monami
 
Debugging
DebuggingDebugging
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
Deva Singh
 
Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence
Yasir Khan
 
Microsoft Projects; a step by-step guide for beginner's
Microsoft Projects; a step by-step guide for beginner'sMicrosoft Projects; a step by-step guide for beginner's
Microsoft Projects; a step by-step guide for beginner's
Abhik Tushar Das
 
Pseudocode
PseudocodePseudocode
Pseudocode
Harsha Madushanka
 
Fundamentals of Programming Chapter 2
Fundamentals of Programming Chapter 2Fundamentals of Programming Chapter 2
Fundamentals of Programming Chapter 2
Mohd Harris Ahmad Jaal
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPTsuhasreddy1
 
Programming for daily life - introduction
Programming for daily life - introductionProgramming for daily life - introduction
Programming for daily life - introduction
Joy George
 
Black Box Testing
Black Box TestingBlack Box Testing
Black Box Testing
Testbytes
 

What's hot (20)

Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
 
1 introduction to problem solving and programming
1 introduction to problem solving and programming1 introduction to problem solving and programming
1 introduction to problem solving and programming
 
Debugging
DebuggingDebugging
Debugging
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
pseudocode and Flowchart
pseudocode and Flowchartpseudocode and Flowchart
pseudocode and Flowchart
 
The Art Of Debugging
The Art Of DebuggingThe Art Of Debugging
The Art Of Debugging
 
Programming Fundamentals lecture 2
Programming Fundamentals lecture 2Programming Fundamentals lecture 2
Programming Fundamentals lecture 2
 
Problem solving
Problem solvingProblem solving
Problem solving
 
Problem Solving
Problem SolvingProblem Solving
Problem Solving
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Black box software testing
Black box software testingBlack box software testing
Black box software testing
 
Debugging
DebuggingDebugging
Debugging
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 
Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence
 
Microsoft Projects; a step by-step guide for beginner's
Microsoft Projects; a step by-step guide for beginner'sMicrosoft Projects; a step by-step guide for beginner's
Microsoft Projects; a step by-step guide for beginner's
 
Pseudocode
PseudocodePseudocode
Pseudocode
 
Fundamentals of Programming Chapter 2
Fundamentals of Programming Chapter 2Fundamentals of Programming Chapter 2
Fundamentals of Programming Chapter 2
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPT
 
Programming for daily life - introduction
Programming for daily life - introductionProgramming for daily life - introduction
Programming for daily life - introduction
 
Black Box Testing
Black Box TestingBlack Box Testing
Black Box Testing
 

Similar to How to improve problem solving skills

Chelberg ptcuser 2010
Chelberg ptcuser 2010Chelberg ptcuser 2010
Chelberg ptcuser 2010Clay Helberg
 
2019 StartIT - Boosting your performance with Blackfire
2019 StartIT - Boosting your performance with Blackfire2019 StartIT - Boosting your performance with Blackfire
2019 StartIT - Boosting your performance with Blackfire
Marko Mitranić
 
Steve Huffman - Lessons learned while at reddit.com
Steve Huffman - Lessons learned while at reddit.comSteve Huffman - Lessons learned while at reddit.com
Steve Huffman - Lessons learned while at reddit.com
Carsonified Team
 
Cloudera Data Science Challenge 3 Solution by Doug Needham
Cloudera Data Science Challenge 3 Solution by Doug NeedhamCloudera Data Science Challenge 3 Solution by Doug Needham
Cloudera Data Science Challenge 3 Solution by Doug Needham
Doug Needham
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Haribabu Nandyal Padmanaban
 
scale_perf_best_practices
scale_perf_best_practicesscale_perf_best_practices
scale_perf_best_practiceswebuploader
 
Optimizing your development process with Adobe Commerce
Optimizing your development process with Adobe CommerceOptimizing your development process with Adobe Commerce
Optimizing your development process with Adobe Commerce
Rafael Corrêa Gomes
 
A Successful Magento Project From Design to Deployment
A Successful Magento Project From Design to DeploymentA Successful Magento Project From Design to Deployment
A Successful Magento Project From Design to Deployment
Joshua Warren
 
Experiences with backend user rights in TYPO3
Experiences with backend user rights in TYPO3Experiences with backend user rights in TYPO3
Experiences with backend user rights in TYPO3
punkt.de GmbH
 
Lessons Learned in a Continuously Developing Service-Oriented Architecture
Lessons Learned in a Continuously Developing Service-Oriented ArchitectureLessons Learned in a Continuously Developing Service-Oriented Architecture
Lessons Learned in a Continuously Developing Service-Oriented Architecture
mdwheele
 
Theme development workflow
Theme development workflowTheme development workflow
Theme development workflow
Shameem Reza
 
JMP402 Master Class: Managed beans and XPages: Your Time Is Now
JMP402 Master Class: Managed beans and XPages: Your Time Is NowJMP402 Master Class: Managed beans and XPages: Your Time Is Now
JMP402 Master Class: Managed beans and XPages: Your Time Is Now
Russell Maher
 
Module05 arena
Module05 arenaModule05 arena
Module05 arena
BoPeng76
 
Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully
Applitools
 
Become a Better Developer with Debugging Techniques for Drupal (and more!)
Become a Better Developer with Debugging Techniques for Drupal (and more!)Become a Better Developer with Debugging Techniques for Drupal (and more!)
Become a Better Developer with Debugging Techniques for Drupal (and more!)
Acquia
 
DevOops Redux Ken Johnson Chris Gates - AppSec USA 2016
DevOops Redux Ken Johnson Chris Gates  - AppSec USA 2016DevOops Redux Ken Johnson Chris Gates  - AppSec USA 2016
DevOops Redux Ken Johnson Chris Gates - AppSec USA 2016
Chris Gates
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
Dave Haeffner
 
Devfest 2019-slides
Devfest 2019-slidesDevfest 2019-slides
Devfest 2019-slides
Alan Richardson
 

Similar to How to improve problem solving skills (20)

Chelberg ptcuser 2010
Chelberg ptcuser 2010Chelberg ptcuser 2010
Chelberg ptcuser 2010
 
2019 StartIT - Boosting your performance with Blackfire
2019 StartIT - Boosting your performance with Blackfire2019 StartIT - Boosting your performance with Blackfire
2019 StartIT - Boosting your performance with Blackfire
 
Steve Huffman - Lessons learned while at reddit.com
Steve Huffman - Lessons learned while at reddit.comSteve Huffman - Lessons learned while at reddit.com
Steve Huffman - Lessons learned while at reddit.com
 
Cloudera Data Science Challenge 3 Solution by Doug Needham
Cloudera Data Science Challenge 3 Solution by Doug NeedhamCloudera Data Science Challenge 3 Solution by Doug Needham
Cloudera Data Science Challenge 3 Solution by Doug Needham
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
 
scale_perf_best_practices
scale_perf_best_practicesscale_perf_best_practices
scale_perf_best_practices
 
Optimizing your development process with Adobe Commerce
Optimizing your development process with Adobe CommerceOptimizing your development process with Adobe Commerce
Optimizing your development process with Adobe Commerce
 
A Successful Magento Project From Design to Deployment
A Successful Magento Project From Design to DeploymentA Successful Magento Project From Design to Deployment
A Successful Magento Project From Design to Deployment
 
Experiences with backend user rights in TYPO3
Experiences with backend user rights in TYPO3Experiences with backend user rights in TYPO3
Experiences with backend user rights in TYPO3
 
Lessons Learned in a Continuously Developing Service-Oriented Architecture
Lessons Learned in a Continuously Developing Service-Oriented ArchitectureLessons Learned in a Continuously Developing Service-Oriented Architecture
Lessons Learned in a Continuously Developing Service-Oriented Architecture
 
Theme development workflow
Theme development workflowTheme development workflow
Theme development workflow
 
10 Ways To Improve Your Code
10 Ways To Improve Your Code10 Ways To Improve Your Code
10 Ways To Improve Your Code
 
JMP402 Master Class: Managed beans and XPages: Your Time Is Now
JMP402 Master Class: Managed beans and XPages: Your Time Is NowJMP402 Master Class: Managed beans and XPages: Your Time Is Now
JMP402 Master Class: Managed beans and XPages: Your Time Is Now
 
Module05 arena
Module05 arenaModule05 arena
Module05 arena
 
Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully
 
Become a Better Developer with Debugging Techniques for Drupal (and more!)
Become a Better Developer with Debugging Techniques for Drupal (and more!)Become a Better Developer with Debugging Techniques for Drupal (and more!)
Become a Better Developer with Debugging Techniques for Drupal (and more!)
 
Download It
Download ItDownload It
Download It
 
DevOops Redux Ken Johnson Chris Gates - AppSec USA 2016
DevOops Redux Ken Johnson Chris Gates  - AppSec USA 2016DevOops Redux Ken Johnson Chris Gates  - AppSec USA 2016
DevOops Redux Ken Johnson Chris Gates - AppSec USA 2016
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
 
Devfest 2019-slides
Devfest 2019-slidesDevfest 2019-slides
Devfest 2019-slides
 

Recently uploaded

TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
ssuser9bd3ba
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
Kamal Acharya
 

Recently uploaded (20)

TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 

How to improve problem solving skills

  • 1. How to Improve Problem Solving Skills - JefferyYuan
  • 2. Disclaimer Just try to summarize what I have learned.
  • 3. Why Problem-solving skills matters Problem Solving and troubleshooting »Is fun »Is part of daily work »Make us solve problem • More efficiently • With more confidence • Less pressure • Go home earlier
  • 4. Why Problem-solving skills matters »Solve the problem when needed • no matter whether its not related with you • It’s your responsibility if it blocks your or the team’s work
  • 5. Understand the problem/environment first Understand the problem before google search otherwise it may just lead you to totally wrong directions. Find related log/data Copy logs/info that maybe related
  • 6. Check the Log and Error Message Read/Understand the error message Where to find log Common places: /var/log From command line: -Dcassandra.logdir=/var/log/cassandra
  • 7. Case Study – The Log and Error Message Problem: Failed to talk Cassandra server: 10.10.10.10 - Where 10.10.10.10 comes from? gfind . -iname '*.jar' -printf "unzip -c %p | grep -q 10.10.10.10' && echo %pn" | sh -It comes from commons2, what’s the current settings in Github -Now the problem and solution is clear: Just upgrade commons2 to latest version
  • 8. Source code is always the ultimate truth Find related code in Github Find examples/working code Understand how/why the code works by running and debug the code Check the log with the code - Most problems can be solved by checking log and source code
  • 9. Reproduce the problem Find easier way to reproduce them - main method, unit test, mock Simplify the suspect code - Find the code related, remove things not realtedUse Reproduce locally Connect to the remote data in local dev Remote debug - Last resort, slow
  • 10. Solving Problem from Different Angles Sometime we find problem in production and we need code change to fix it -Try to find whether we can fix a workaround by changing database/Solr or other configuration -We can fix code later
  • 11. Find Information Effectively Google search: error message, exception Search source code in Github/Eclipse Search log Search in IDE -- Cmd+alt+h, cmd+h Search command history -- history | grep git | grep erase -- history | grep ssh | grep 9042 Know company’s internal resource – where to find them Know some experts (in company) you can ask help from
  • 12. Ask for help From coworkers Stackoverflow Specific forums http://lucene.472066.n3.nabble.com/Solr-f472067.html - Provide context and info you find - Ask help for same/similar things once, then you know how to do it - Learn the knowledge itself - But also learn their thinking process
  • 13. Fix same/similar/related problems in other places We make mistakes in one place It's very likely we make same/similar/related in other places GetMapping(value = "/config/{name:.+}")
  • 14. Knowledge Be prepared Know what problem may happen, the difference etc Know the services/libraries you are using Apache/Tomcat configuration How to manage/troubleshoot Cassandra/Kafka/Solr
  • 15. Knowledge Practice - Redis cache.put Hangs - Get threaddump, figure out what is happening when read from cache - Read related code to figure out how Spring implements @Cacheable(sync=true) RedisCache$RedisCachePutCallback - Check whether there is cacheName~lock in redis When use some feature, know how it's implemented.
  • 16. Knowledge Common Problems – More to add in future Different versions of same library - mvn dependency:tree - mvn dependency:tree -Dverbose -Dincludes=com.amazonaws:aws-java-sdk-core
  • 17. Practice - Iterator vs Iterable What’s the problem in the following Code? @Cacheable(key = "#appName") public Iterator<Message> findActiveMessages(final String appName) {}
  • 18. Practice - Iterator vs Iterable How we find the root cause - Symptoms: The function only works once in a while: when cache is refreshed - Difference between Iterator vs Iterable - Don't use Iterator when need traverse multiple times - Don't use Iterator as cache value
  • 19. Practice 2 - Spring @Cacheable Not Working The class using cache annotation inited too early - Add a breakpoint at the default constructor of the bean, then from the stack trace we can figure out why and which bean (or configuration class) causes this bean to be created - Understand how spring cache works internally, spring proxy - CacheAspectSupport
  • 20. Building Application to Be Troubleshooting Friendly Debug Feature Return debug info that can check from response without having to check the log - Of course secured, protected Mock User Feature Preview Feature In memory test users in test env
  • 21. How to write test efficiently Take time to learn: Hamcrest, Mockito, JUnit, TestNG, REST Assured Add Static Import Preferences > Java > Editor > Content Assist > Favorites, then add: org.hamcrest org.hamcrest.Matchers.* org.hamcrest.CoreMatchers.* org.junit.* org.junit.Assert.* org.junit.Assume.* org.junit.matchers.JUnitMatchers.* org.mockito.Mockito org.mockito.Matchers org.mockito.ArgumentMatchers io.restassured.RestAssured
  • 22. Misc. – Part 1 Don't overcomplicate it. - In most cases, the solution/problem is quite simple Troubleshooting is about thinking what may go wrong. Track what change you have made
  • 23. Misc. – Part 2 When help others -Ask what related change they have done Ask help from others. -Try to understand the problem and fix it by yourself first. -Provide log or any information that may help others understand the problem. When work on urgent issues with others -Collaborate timely -Let others know what you are testing, what's your progress, what you have found, what you will do next -Listen to others
  • 24. Misc. – Part 3 Think More - Think over the code/problem, try to find better solution even it's already fixed Everything that stops you from working effectively is a problem - No access, slack different teams etc Fix them
  • 25. Reflection: Lesson Learned How we find the root cause Why it takes so long What we learned What's the root cause Why we made the mistake How we can prevent this happens again Share the knowledge in the team Take time to solve problem, but only (take time to) solve it once
  • 26. Tools - Eclipse Use Conditional Breakpoint to Execute Arbitrary Code (and automatically) Use Display View to Execute Arbitrary Code Find which jar containing the class and the application is using - MediaType.class.getProtectionDomain().getCodeSource().getLocation() Breakpoint doesn't work - Multiple versions of same class or library
  • 27. Practice - Connect to the remote data in local dev Create a tunnel to zookeeper and solr nodes Add a conditional breakpoint at CloudSolrClient.sendRequest(SolrRequest, String) - before LBHttpSolrClient.Req req = new LBHttpSolrClient.Req(request, theUrlList); theUrlList.clear(); theUrlList.add("http://localhost:18983/solr/searchItems/"); theUrlList.add("http://localhost:28983/solr/searchItems/"); return false;
  • 28. Tools - Decompiler CFR http://www.benf.org/other/cfr/ - Best, Support java8 JD-GUI Sometimes, it doesn't work
  • 29. Tools - Java jcmd: One JDK Command-Line Tool to Rule Them All jcmd <pid> Thread.print jcmd <pid> GC.heap_dump <filename> Thread dump Analyzer http://fastthread.io/ Heap dump Analyzer Eclipse MAT VisualVM
  • 30. Tools - Misc Splunk - After search and find the problem, use nearby Events +/- x seconds to show context nc -zv; lsof; df;find;grep Search Contents of .jar Files for Specific String gfind . -iname '*.jar' -printf "unzip -c %p | grep -q 'string_to_search' && echo %pn" | s Fiddler
  • 31. Resource Debug It!: Find, Repair, and Prevent Bugs in Your Code Shameless plug https://www.slideshare.net/lifelongprogrammer http://lifelongprogrammer.blogspot.com/search/label/Problem%20Solving http://lifelongprogrammer.blogspot.com/search/label/Troubleshooting http://lifelongprogrammer.blogspot.com/search/label/Debug