1
00:00:07,450 --> 00:00:09,639
After watching this video, you will be able
to:

2
00:00:09,639 --> 00:00:14,700
Describe social coding principles and recognize
how pair programming creates better code and

3
00:00:14,700 --> 00:00:16,990
better programmers.

4
00:00:16,990 --> 00:00:19,160
What is social coding?

5
00:00:19,160 --> 00:00:22,750
I like to call it "Open Source for Inner Source."

6
00:00:22,750 --> 00:00:26,630
Social coding is something that the open-source
community has been doing for years.

7
00:00:26,630 --> 00:00:32,270
What’s new is bringing these concepts into
the enterprise and coding as a community on

8
00:00:32,270 --> 00:00:33,320
internal projects.

9
00:00:33,320 --> 00:00:38,070
In the past, developers worked in private
repositories (repos) and you had to be a member

10
00:00:38,070 --> 00:00:39,770
of the team to contribute.

11
00:00:39,770 --> 00:00:43,840
Everything was controlled by access control
lists and a strict "need to know" basis.

12
00:00:43,840 --> 00:00:48,510
The problem with that is no one knows that
you're working on it, so there is no possibility

13
00:00:48,510 --> 00:00:51,640
of reusing code because no one even knows
it exists.

14
00:00:51,640 --> 00:00:57,370
So, enterprises continually re-invent the
wheel because no one knows the wheel has already

15
00:00:57,370 --> 00:00:59,410
been built.

16
00:00:59,410 --> 00:01:04,510
With social coding, repositories are public,
and everyone is encouraged to fork the code

17
00:01:04,510 --> 00:01:05,750
and contribute.

18
00:01:05,750 --> 00:01:08,327
This is a hugely different way of thinking.

19
00:01:08,327 --> 00:01:12,920
Development teams love to think "this is my
code and no one else can touch it" but they

20
00:01:12,920 --> 00:01:16,549
need to get over that for the good of the
company.

21
00:01:16,549 --> 00:01:21,270
You would think that anarchy would ensue,
but actually, it works quite well because

22
00:01:21,270 --> 00:01:24,100
it’s controlled by the repository owner.

23
00:01:24,100 --> 00:01:29,679
The person who owns the repository is still
in complete control of the contributions.

24
00:01:29,679 --> 00:01:31,630
What problem is social coding solving?

25
00:01:31,630 --> 00:01:37,119
Let's say, you see a component, it’s 80%
of what you need, but there are some missing

26
00:01:37,119 --> 00:01:38,549
features.

27
00:01:38,549 --> 00:01:40,789
How do you add those missing features?

28
00:01:40,789 --> 00:01:44,040
You now have a decision to make:

29
00:01:44,040 --> 00:01:48,529
Do you make a feature request to the repo
owner for a new feature and risk that your

30
00:01:48,529 --> 00:01:50,639
request will be at the bottom of their priority
list?

31
00:01:50,639 --> 00:01:55,250
Or worse, their funding gets cut, and your
request will be cut out first.

32
00:01:55,250 --> 00:02:01,159
Or do you rebuild 100% of the code just to
get the 20% that you need so as not to have

33
00:02:01,159 --> 00:02:02,840
a dependency on another team?

34
00:02:02,840 --> 00:02:09,289
It’s sad to report, but many teams select
the latter and re-invent the entire wheel

35
00:02:09,289 --> 00:02:11,310
just to get the functionality they need.

36
00:02:11,310 --> 00:02:16,849
This is a huge waste of resources for any
company, but it happens all the time.

37
00:02:16,849 --> 00:02:20,190
How does adopting social coding principles
solve this?

38
00:02:20,190 --> 00:02:24,450
You discuss the new feature with the repo
owner, and you agree to develop it for them.

39
00:02:24,450 --> 00:02:28,311
This allows you to leverage everything that
they've done and add the feature that you

40
00:02:28,311 --> 00:02:29,311
need.

41
00:02:29,311 --> 00:02:34,150
You open up a GitHub Issue and you assign it to
yourself so that everyone knows you’re

42
00:02:34,150 --> 00:02:35,510
working on it.

43
00:02:35,510 --> 00:02:39,870
Then you fork the repo, create a branch, and
make your changes.

44
00:02:39,870 --> 00:02:44,019
When you’re all done and have something
to contribute back, then you issue a pull

45
00:02:44,019 --> 00:02:49,470
request signaling that you are ready for a
review and the repo owner can decide whether

46
00:02:49,470 --> 00:02:53,239
to merge your code back into the main project.

47
00:02:53,239 --> 00:02:56,370
The repo owners are in full control.

48
00:02:56,370 --> 00:03:00,079
They can ask for changes because they do the
merge.

49
00:03:00,079 --> 00:03:03,430
They can ask that you write more test cases
if you don't have adequate test coverage.

50
00:03:03,430 --> 00:03:07,040
They treat you and your contribution like
any other member of the team.

51
00:03:07,040 --> 00:03:08,420
This is a win-win situation.

52
00:03:08,420 --> 00:03:13,090
You get to leverage another team’s code
and all the functionality that you need, and

53
00:03:13,090 --> 00:03:16,060
the other team gets a feature added for free.

54
00:03:16,060 --> 00:03:20,930
The company saves money because code is being
reused instead of rewritten and everyone is

55
00:03:20,930 --> 00:03:21,930
happy.

56
00:03:21,930 --> 00:03:28,540
This is how open-source works and this is
how companies should treat their inner source.

57
00:03:28,540 --> 00:03:33,849
Pair programming is an aspect of social coding
that is taken from Extreme Programming.

58
00:03:33,849 --> 00:03:39,400
It consists of two programmers sharing a single
workstation (one screen, one keyboard, and

59
00:03:39,400 --> 00:03:41,739
mouse between the pair).

60
00:03:41,739 --> 00:03:45,760
The programmer at the keyboard is usually
called the “driver.”

61
00:03:45,760 --> 00:03:50,010
The other programmer, also actively involved
in the programming task, but focused more

62
00:03:50,010 --> 00:03:53,530
on the overall direction, is called the “navigator.”

63
00:03:53,530 --> 00:03:57,590
While the driver is typing, the navigator
is checking their work, or perhaps looking

64
00:03:57,590 --> 00:04:01,130
something up, or thinking about what's coming
next.

65
00:04:01,130 --> 00:04:04,450
Then, after about 20 minutes they swap roles.

66
00:04:04,450 --> 00:04:07,829
This way they both get to play each role.

67
00:04:07,829 --> 00:04:10,349
I pair program whenever I can at work.

68
00:04:10,349 --> 00:04:12,629
I like this aspect of social coding.

69
00:04:12,629 --> 00:04:17,970
One of my personal weaknesses is that I will
agonize over what to call a new variable or

70
00:04:17,970 --> 00:04:18,970
function.

71
00:04:18,970 --> 00:04:22,070
I want to get it perfect, to make the code
as readable as possible.

72
00:04:22,070 --> 00:04:27,170
Having someone else to bounce ideas off of
helps me make those decisions faster.

73
00:04:27,170 --> 00:04:31,150
You might think that pair programming is using
twice the resources to get the same amount

74
00:04:31,150 --> 00:04:33,290
of work, but it’s not like that.

75
00:04:33,290 --> 00:04:37,070
There are many benefits of pair programming.

76
00:04:37,070 --> 00:04:39,280
The first benefit is higher code quality.

77
00:04:39,280 --> 00:04:44,420
There is something about "programming out
loud" that leads to a clearer understanding

78
00:04:44,420 --> 00:04:45,420
of the code.

79
00:04:45,420 --> 00:04:49,370
In the past, when I wrote code, and I wrote
it alone, and then when I explained it to

80
00:04:49,370 --> 00:04:53,540
someone, I would pick up on a bug as I was
talking out loud.

81
00:04:53,540 --> 00:04:58,040
I didn’t see the bug when I was looking
over the code in my head, but I saw it as

82
00:04:58,040 --> 00:04:59,650
I talked out loud.

83
00:04:59,650 --> 00:05:03,220
Having to explain code to someone forces clarity.

84
00:05:03,220 --> 00:05:05,070
This means that defects are found earlier.

85
00:05:05,070 --> 00:05:10,340
That's a good thing because it lowers the
maintenance costs right down the line.

86
00:05:10,340 --> 00:05:14,970
The later a defect is found in the process,
the more it costs to fix.

87
00:05:14,970 --> 00:05:18,310
Pair programming also forces skills transfer,
creating better programmers.

88
00:05:18,310 --> 00:05:22,050
I like to pair junior programmer developers
with senior developers.

89
00:05:22,050 --> 00:05:26,280
I do this all the time so that each one learns
from the other’s approach to a problem.

90
00:05:26,280 --> 00:05:28,240
They pick up tips and tricks that the other
one uses.

91
00:05:28,240 --> 00:05:30,060
It creates better programmers.

92
00:05:30,060 --> 00:05:33,690
You also get two sets of eyes on every line
of code.

93
00:05:33,690 --> 00:05:36,530
You don't want code that only one person understands.

94
00:05:36,530 --> 00:05:41,570
Then, that person goes on vacation, and no
one knows how to fix their code.

95
00:05:41,570 --> 00:05:44,930
Pair programming leads to a better understanding
of the code.

96
00:05:44,930 --> 00:05:49,310
More people understand the code well enough
to fix and enhance it.

97
00:05:49,310 --> 00:05:51,440
In this video, you learned that:

98
00:05:51,440 --> 00:05:55,990
Social coding is done communally with public
repositories and all team members are encouraged

99
00:05:55,990 --> 00:05:57,860
to contribute.

100
00:05:57,860 --> 00:06:03,050
Pair programming results in higher quality
code because defects are found earlier, costs

101
00:06:03,050 --> 00:06:07,008
are lowered, and there is a broader understanding
of the codebase.