Slide 1

Slide 1 text

Alissa Bonas mikeyteva

Slide 2

Slide 2 text

“Run Forrest, Run”

Slide 3

Slide 3 text

When is it needed? ● Add a new feature ● Fix a bug ● Investigate a problem ● Maintain legacy code ● Integration with another system or component

Slide 4

Slide 4 text

“My momma always said, life was like a box of chocolates. You never know what you’re gonna get”

Slide 5

Slide 5 text

How can we succeed?

Slide 6

Slide 6 text

Ask the person who developed it

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

However...

Slide 9

Slide 9 text

Is it an open source project? ● Check the docs / wiki ● Ask in the community ○ mailing list ○ forum ○ irc ○ open an issue / ticket with a question

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

Back to basics

Slide 12

Slide 12 text

Back to basics ● Technology / Programming language ● Source control ● Running tests ● Build / Run / Deploy

Slide 13

Slide 13 text

Detecting languages on Github

Slide 14

Slide 14 text

Detecting languages on Github

Slide 15

Slide 15 text

Not 100% accurate

Slide 16

Slide 16 text

Look for hints ● File extensions ● .gitignore ● README.md

Slide 17

Slide 17 text

Look for more hints ● Requirements.txt / setup.py ● pom.xml / build.xml ● Gemfile / gemspec ● bower.json

Slide 18

Slide 18 text

Scope the task

Slide 19

Slide 19 text

Minor changes ● Fix typos ● Add more info to a log statement ● Persist a field that already exists in an object

Slide 20

Slide 20 text

In search we trust ● Search for strings in the code repository ● Search existing logs for object names

Slide 21

Slide 21 text

Medium size changes ● Add a new field to an object / model ○ process and persist ○ use it in all code layers ● Upgrade the version of a third party library ○ regression is your nemesis ○ minor version upgrade != major version upgrade

Slide 22

Slide 22 text

Follow the trail ● Follow existing fields ○ understand the flow ● Follow the tests ○ learn how to add new tests ○ check if tests pass after code changes

Slide 23

Slide 23 text

Major changes ● Refactor a module / component ● Add a new functionality which requires a deep understanding of the system ● Performance is key and must not be harmed

Slide 24

Slide 24 text

Understand ● The architecture of the system ● Relevant flows and use cases ● The main path ● Fallback, retries, etc.

Slide 25

Slide 25 text

Number 1 factor is...

Slide 26

Slide 26 text

Time

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Goal: Identify entry points ● UI / REST / Backend ● Class hierarchy ● Identify and learn frameworks

Slide 29

Slide 29 text

Get to know the code better ● Is there a dependency injection mechanism? ● How do the components communicate ● Configuration keys to enable more info in the logs

Slide 30

Slide 30 text

Get to know the system better ● Identify persistency ○ data store type ○ how the data is stored ● Know your container ○ web server ○ application server

Slide 31

Slide 31 text

Product configuration files ● Static files location ● Check how they are used and changed ○ directly ○ loaded into the database

Slide 32

Slide 32 text

Multi process system ● Identify the processes ● How do they communicate with each other ● High availability / symmetric

Slide 33

Slide 33 text

Multithreaded considerations ● Sync or async code flow ● Usage of thread pools

Slide 34

Slide 34 text

After several iterations ● Create a sequence diagram ● UML draw.io Free online Visio alternative

Slide 35

Slide 35 text

Iterating over the code is like solving a puzzle

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Creating anchors “In climbing, a piton (/ˈpiːtɒn/; also called a pin or peg) is a metal spike (usually steel) that is driven into a crack or seam in the rock with a hammer, and which acts as an anchor to protect the climber against the consequences of a fall, or to assist progress in aid climbing” (wikipedia)

Slide 38

Slide 38 text

Creating anchors ● Read the code ● If we can debug - put breakpoints ● Read existing logs ● Understand through unitests

Slide 39

Slide 39 text

Creating anchors continued ● Change the log level ● Add more logging statements ● Check history in source control - commits and comments

Slide 40

Slide 40 text

Creating anchors - IDE Bookmarks

Slide 41

Slide 41 text

Creating anchors - the analog way ● Works too!

Slide 42

Slide 42 text

Backend

Slide 43

Slide 43 text

Example - utilities to explore the JVM ● JConsole ● VisualVM ● (more tools exist)

Slide 44

Slide 44 text

Getting more hints ● Explore threads names ● Thread dump - check thread source ● Take a heap dump - explore classes ● Check which objects a map contains

Slide 45

Slide 45 text

Hint on the database Hint on the scheduler

Slide 46

Slide 46 text

Network analyzer / packet sniffer ● Software that intercepts and logs traffic ○ decodes data ○ shows packet fields ● For example - Wireshark ● Define filters for efficiency

Slide 47

Slide 47 text

Example

Slide 48

Slide 48 text

Goal ● Send a SOA envelope to a service ● Sender - Ruby code ● Target - Java SOA service

Slide 49

Slide 49 text

Reports Engine 1 Reports Engine 2 Reports Engine 3 UI Reports Engine 4 http /engine1 http /engine2 http /engine3 http /engine4 SOA Tomcat SOA SOA SOA SOA

Slide 50

Slide 50 text

Steps ● Basic understanding what SOA is ● Intercept traffic of the existing Java code ● Learn how a SOA envelope should look like ● Write Ruby code to create a SOA envelope

Slide 51

Slide 51 text

Frontend

Slide 52

Slide 52 text

Frontend ● Which libraries are used ● Search for strings / translation files ● Search for icon files location and usage ● Learn how UI calls backend

Slide 53

Slide 53 text

Browser developer tools ● FireBug ● Chrome developer tools

Slide 54

Slide 54 text

Following the code ● Which css and js are downloaded ● Add watches in the script tab ● Set a breakpoint ○ Use ‘debugger;’ keyword in code ○ Set a breakpoint ● Inspect elements

Slide 55

Slide 55 text

Inspect the logo 160px * 159px File type and location Press here to switch to element selection mode Inspecting elements

Slide 56

Slide 56 text

Inspect the logo 160px * 159px Inspecting elements

Slide 57

Slide 57 text

Useful options ● Network tab ● Copy as curl ● Copy response ● Copy link address

Slide 58

Slide 58 text

Following network requests Alissa Bonas @ PyTN 2016

Slide 59

Slide 59 text

Analyzing response Alissa Bonas @ PyTN 2016

Slide 60

Slide 60 text

Analyzing response - zoom in JSON response

Slide 61

Slide 61 text

REST Client ● Learn how REST API is designed

Slide 62

Slide 62 text

In short...

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

Thank you! mikeyteva

Slide 65

Slide 65 text

Graphics credits ● Signpost by Lubos Volkov ● Clock by Kid Mountain ● Idea by Matt Wasser ● Gauge by Joel Avery from the Noun Project ● Tomcat-logo by The Apache Tomcat Project Team ● Loop by useiconic.com from the Noun Project ● Magnifying Glass by Musket from the Noun Project ● Puzzle Piece by icon 54 from the Noun Project ● Writing by Creative Stall from the Noun Project ● Sherlock by James Keuning, the Noun Project ● Twitter by Lubos Volkov, the Noun Project ● Mug by Alex Getty from the Noun Project ● Diamond by MarkieAnn Packer from the Noun Project ● Light Bulb by artworkbean, the Noun Project ● Questions by Rediffusion from the Noun Project ● cancel by Jevgeni Striganov from the Noun Project ● Movies posters - http://www.impawards.com/