internship at google -...

40
Google internship Peter Perešíni 3.11.2009

Upload: others

Post on 18-Oct-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Google internship

Peter Perešíni3.11.2009

Page 2: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Prehľad

Možnosti práce/internshipu v zahraničíAko vyzerá Google internshipNástroje na produktivitu (code reviews, testing)Voľná diskusia a otázky

Page 3: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Možnosti Internshipu

alebo "Čo sa dá robiť?"

Page 4: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Možnosti po ukončení štúdia

Page 5: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Možnosti po ukončení štúdia

Page 6: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Možnosti internshipu

IPAM (Institute for pure & applied mathematics) http://www.ipam.ucla.edu/about.aspxMicrosoft ResearchCERNGooglemnohé ďalšie

Page 7: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Prečo práve Google?

softwarový gigant20000 zamestnancovmilióny užívaťeľov

dobrá pracovná atmosféraarchitektúra a problémy, ktoré nemá nikto iný na svete

Page 8: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?
Page 9: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Ako vyzerá Google internship?

Page 10: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Step 1: Aplikácia na internship

Treba dať o sebe vedieťvoľné pozície - http://www.google.com/support/jobs/bin/static.py?page=students.htmlpre záujemcov môžem dodať nejaké kontakty

Page 11: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Step 2: Interview

telefonicky alebo na mieste2 x 45 minútrôzne ťažké úlohy (algoritmy, design, ...)

Page 12: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Step 3: Po interview

2 týždne čakať na rozhodnutiedohodnutie detailov internshipu

začiatok a koniecpracovná zmluva

Page 13: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Step 4: Pred začatím

čakanie na byrokraciupracovné povolenievíza

Page 14: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Internship - 1. týždeň

Asi najhorší týždeňbyrokracia

registrovať sa na úradochbankové kontozdravotné poistenie...

prístupové právavybaviť N+1 rôznych accountovna každé sa čaká, blokuje to ďalšie,

Page 15: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Bežný týždeň

snippetsstandupsiteration plannings

Page 16: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Posledný týždeň

opäť kopa byrokracie

Page 17: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Google Zurich

Prečo chodiť do práce?

Page 20: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Projekty na ktorých sa dá pracovať

gmailsearch qualitygeo (maps, earth)...

Page 21: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Môj projekt

Page 22: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Môj projekt

Čo bolo mojou prácou:

štatistický model na zlepšenie presnostikopec drobných bugovinterné toolypomoc pri zahájení novej verzie produktu

Page 23: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Môj projekt

Bolo to ťažké?niestačia základné vedomosti C++naučil som sa Pythonvedomosti zo štatistiky a pravdepodobnosti

Page 24: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Môj projekt

Prečo potom Google má najlepších programátorov?efektivita

kompilácia 5 minút, inkrementálne 30 sekúndspúšťanie servera - vzdialené datacentrum, pár desiatok počítačov, 10 minút

spoľahlivosťsubmitnutý kód musí byť spoľahlivý

nápady

Page 25: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?
Page 26: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Productivity tools

Page 27: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Niektoré nástroje

perforce/version controlmondrian/review boardbug trackerunit testsregression testsload tests

Page 28: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Version control

20000 collaboratorsmillions of lines of source codehistory of changeseasy revert

Page 29: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Peer review

more than one developer knows the codeforce developers to submit clean, understandable codereviewer may have good ideas (design/refactoring, naming functions, simplifying code, forgotten todo's, ...)

Page 30: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Bug tracker

global database of issues"bug triages"

Page 31: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Unittests & test driven development

Why to test even simple code?it can be buggytesting rocks, debugging sucks someone other can break it while refactoring/adding new featurescatch problems even before start of your server

catch problems before submitting the code

Page 32: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Unittests & test driven development

// Tests Factorial()TEST_F(IntegerFunctionTest, Factorial) { // Tests factorial of negative numbers. EXPECT_EQ(1, Factorial(-5)); EXPECT_EQ(1, Factorial(-1)); EXPECT_TRUE(Factorial(-10) > 0);

// Tests factorial of 0. EXPECT_EQ(1, Factorial(0));

// Tests factorial of positive numbers. EXPECT_EQ(1, Factorial(1)); EXPECT_EQ(2, Factorial(2)); EXPECT_EQ(6, Factorial(3)); EXPECT_EQ(40320, Factorial(8));}

// Tests IsPrime()TEST_F(IntegerFunctionTest, IsPrime) { // Tests negative input. EXPECT_FALSE(IsPrime(-1)); EXPECT_FALSE(IsPrime(-2)); EXPECT_FALSE(IsPrime(INT_MIN));

// Tests some trivial cases. EXPECT_FALSE(IsPrime(0)); EXPECT_FALSE(IsPrime(1)); EXPECT_TRUE(IsPrime(2)); EXPECT_TRUE(IsPrime(3));

// Tests positive input. EXPECT_FALSE(IsPrime(4)); EXPECT_TRUE(IsPrime(5)); EXPECT_FALSE(IsPrime(6)); EXPECT_TRUE(IsPrime(23));}

Page 33: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Testing & mocks

- What are mocks? - Why mocks?

break dependencies, dependency injectionstest object without collaboratorssmaller testeasy test of databases, filesystems, remote servers

Page 34: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Testing & mocks

class Turtle { ... virtual ~Turtle(); virtual void PenUp() = 0; virtual void PenDown() = 0; virtual void Forward(int distance) = 0; virtual void Turn(int degrees) = 0; virtual void GoTo(int x, int y) = 0; virtual int GetX() const = 0; virtual int GetY() const = 0;};

#include <gmock/gmock.h> class MockTurtle : public Turtle { public: ... MOCK_METHOD0(PenUp, void()); MOCK_METHOD0(PenDown, void()); MOCK_METHOD1(Forward, void(int distance)); MOCK_METHOD1(Turn, void(int degrees)); MOCK_METHOD2(GoTo, void(int x, int y)); MOCK_CONST_METHOD0(GetX, int()); MOCK_CONST_METHOD0(GetY, int());};

TEST_F(DrawerTest, TestSomething) { MockTurtle turtle; EXPECT_CALL(turtle, GetY()).WillOnce(Return(100)).WillOnce(Return(200)).WillRepeatedly(Return(300));Drawer drawer;drawer.do_something(turtle);}

Page 35: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Presubmit queue

catch problems before submissionautomatic testing of all important componentscode style checking

Page 36: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Regression tests

We have unittests, why to bother?tested code may not run in production (commented out)need of production environment

client-server, network, database, real queries unittest should be small, simple & fast

Page 37: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Loadtests

"If you do not plan to increase application speed, you change in 99% will slow down everything"

easy to add slow code

Page 38: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Open source variants

version control - svn, csv, git, ...reviews - reviewboardbug tracker - bugzilla, ...unittests - google tests (http://code.google.com/p/googletest/), CppUnitmocks

Java: jMock, EasyMockC++: google mocks (http://code.google.com/p/googlemock)

Page 39: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?
Page 40: Internship at Google - foja.dcs.fmph.uniba.skfoja.dcs.fmph.uniba.sk/mit2/prezentacie/Internship_at_Google.pdf · Unittests & test driven development Why to test even simple code?

Voľná diskusia

Máte nejaké otázky?