Lecture 01 - Overview, Development Environments, Source Control
Lecture 01 - Overview, Development Environments, Source Control
Lecture 1
Check in!
Overview
Development Environments
Source Control
(link)
We're full!
2
Introduction
Who are we?
4
Alex Monroe Fun facts
5
Eric Hennigan Fun facts
● UCLA alumni
6
Michael Burns Fun facts
● Grew up in SoCal
7
Philo Juang Fun facts
● Plays soccer
8
Proprietary + Confidential
You need to know how to program and use public LinkedList(T el) {
basic data structures. elem = el;
}
11
Software engineering is
not (just) programming
It's programming that's valuable to other
people
12
A small program
● Developed alone
● No obvious bugs
● Useful to me
13
A small program vs. a big program
● Uses large framework or platform
● Developed by a team
● Uses compiler and a few libraries ● Run many times
● Well-tested
● Developed alone ● Documentation
● Useful to many people
Which means:
● Run a few times
● Debugging
● Unit, integration, regression tests
● No obvious bugs ● Bug tracking
● Build process
● I know how it works ● Release process
● Monitoring
● Useful to me ● Performance testing
● Adding new features
● Updating documentation
● Programmer turnover
● Updates to the framework
● ...
14
BigTable
15
Valuable software
projects have risk
17
Software engineering is about managing risk
● Revision control
● Code reviews
● Coding style
● Refactoring
● Testable code
● Unit testing
● API design
● Design reviews
● Integration testing
● Build automation
18
Learning Software Engineering
● Hearing about tools, procedures, and techniques for writing valuable code.
19
Project / Assignments
Project: Web server
● Learn how to design robust APIs ● Make a project for your resume
22
Assignments Late Policy
23
Late Policy (Exception)
● Partway through the course, you will be asked to work in another team’s
codebase
● For this assignment, we will cap the number of late hours you will be able to use
so that other teams
24
Assignment logistics
25
This is a team endeavor!
26
Software Engineering is a team endeavor
● Using and learning from publically available code is encouraged in this class, and
will be useful in your career.
○ In this class, you must cite your source in a comment in the form of a URL.
● Make an honest effort to figure things out, but don't spend hours on some tough
problem—look at what someone else did. Most problems have already been
solved.
27
Suggestions...
● Start early, get help where needed! Make use of the discussion section and office
hours.
28
Suggestions...
● Start early, get help where needed! Make use of the discussion section and office
hours.
29
Suggestions...
● Start early, get help where needed! Make use of the discussion section and office
hours.
30
Suggestions...
● Start early, get help where needed! Make use of the discussion section and office
hours.
31
Suggestions...
● Start early, get help where needed! Make use of the discussion section and office
hours.
32
Don't let this be you!
33
Technology we assume you know
● C++
● Linux
34
An aside on GenAI
● Consider it a tool
35
Technology we will help you learn along the way
● Containerization (Docker)
36
Piazza – For students
37
Piazza – For students
38
Piazza – For students
Student: How should we handle double slashes in URL paths? Should we fail or
should we accept them in a path?
39
Timeline
~2 weeks ~3 weeks
● Midterm
40
Evaluation (Grading)
Assignments - 70%
Midterm - 15%
Final - 15%
41
Standardization:
Development Environment
Student Development
Environments
● Identity
○ Who knows?
● Platform
○ Linux/MacOS/Windows?
● IDE
○ Visual Studio/XCode/CLion/VS Code?
● Compiler
○ Clang/GCC/ICC/Visual C++?
● File / directory structure
○ Monolithic or separated?
● Code style
○ Opening brace? Indentation?
● Source control system
○ CVS/SVN/Perforce/Git/None?
43
Corporate Development
Environments
Standardized:
● Identity
● Platform
● IDE
● Compiler
● Code style
44
CS 130 Development
Environment
● Identity Identity:
○ @g.ucla.edu
● Platform Account is [email protected]
○ Linux
● IDE User is joebruin
○ Recommending VS Code
● Compiler
○ GCC
● File / directory structure
○ Not monolithic
● Code style
○ Make some decisions
● Source control system
○ Git
45
Demo
● Host is MacBook
○ clang compiler
○ missing gcloud
○ has docker
● Start devel env
○ SSH key
○ gcc compiler
○ has gcloud
○ has docker
○ git using cs130.org
user
46
Docker what?
47
Code file/directory my_project/
- build/
structure
- bin/
- [more build files]
Guidelines:
- include/
● Use .cc file extension - server.h
● One file per C++ class - session.h
implementation - src/
● Separate _main.cc file for main() - server.cc
- server_main.cc
● Separate directories for headers and
tests - session.cc
- tests/
- server_test.cc
- session_test.cc
48
Source Control
Proprietary + Confidential
One rule
50
Why?
● Reproducible state
● Backing up work
● Documenting progress
● Post-mortems
● Legal pedigree
51
Source control tradeoffs
● Adds complexity
○ can't just edit files willy-nilly
○ have to check them in, check them out
○ have to figure out how to size changelists
○ more thinking
● ... but reduces risk
○ of losing progress
○ of not being able to solve user problems
○ of legal liability
● ... and is more scalable
○ more people can contribute sensibly
○ allows specialization
52
Source control tools
● Git
● Subversion
● Mercurial
● CVS
● Perforce
● SourceSafe
● BitKeeper
53
Repository diagram
54
Changelists and filesets
● Files in source control organized by the logic of the project and build system.
● Different source control systems treat files differently
○ Git treats the entire repository at once, and references the whole fileset by a hash
● Changelists are determined by development logic
○ Chosen to advance the goals of the project
○ Use changelists to make sense internally as a project state transition.
○ Ideally they are:
■ self-contained
■ small
■ single-function
○ Can be part of a larger group of changelists
○ Larger sequences can be arranged as branches
55
Git source control: Basic idea
What we want:
v1 v2 v3 v4 v5
56
Git source control: Basic idea
What we want:
v1 v2 v3 v4 v5
57
Git source control: Basic idea
What we want:
v1 v2 v3 v4 v5
With this paradigm, need an entire copy of the whole repository for every version
What if your repository contains 1GB? What if you have 100 developers submitting
code so there are 100 new versions a day?
58
Git source control: Diffs
Solution: Instead of storing a copy of the repo at each version, store only a “diff” that
tells you how to modify each version to get to the next incremental version
59
Git source control: Diffs
Example:
1: Today is 2: Mon -> 1: Today is 2: Tues-> 1: Today is 2: Wednes -> 1: Today is 2: Thurs-> 1: Today is
2: Monday Tues 2: Tuesday Wednes 2: Wednesday Thurs 2: Thursday Friday 2: Friday
3: +TGIF 3: TGIF!
60
Git source control: Glossary
● Commit: A snapshot of the repository at a given point in time (think “node”)
○ e.g. v3
● Changelist: A diff that represents how the repository is changed between
commits (think “edge”)
○ e.g. Diff 2
61
Git source control: Making new commits
● In order to commit, edit your files locally, add them to potential commit, and then
call `git commit`.
● Git will automatically collapse your changes into a diff and store those changes
● Git will also give your commit a name (hash of fileset)
$ git add .
$ git commit -m “Adding more docs”
v1 v2 v3 v4
62
Git source control: Glossary
● In order to commit, edit your files locally, add them to potential commit, and then
call `git commit`.
● Git will automatically collapse your changes into a diff and store those changes
● Git will also give your commit a name (hash of fileset)
$ git add .
$ git commit -m “Adding more docs”
v1 v2 v3 v4 v5
63
Git source control: Glossary
main
v1 v2 v3 v4 v5
64
Git source control: Making a new branch
● “Making a new branch” means “create a new pointer that points at the same place
I’m currently pointed at”
main
v1 v2 v3 v4 v5
65
Git source control: Making a new branch
● “Making a new branch” means “create a new pointer that points at the same place
I’m currently pointed at”
main new-feature
v1 v2 v3 v4 v5
66
Git source control: Making a new branch
HEAD
main new-feature
v1 v2 v3 v4 v5
67
Git source control: Making a new branch
main *new-feature*
v1 v2 v3 v4 v5
68
Git source control: Moving around
$ git checkout v3
*main*
v1 v2 v3 v4 v5
69
Git source control: Moving around
$ git checkout v3
HEAD main
v1 v2 v3 v4 v5
70
Git source control: Moving around
$ git checkout v3
v1 v2 v3 v4 v5
71
Git source control: List turns into Tree
HEAD main
v1 v2 v3 v4 v5
72
Git source control: List turns into Tree
*new_feature* main
v1 v2 v3 v4 v5
73
Git source control: List turns into Tree
*new_feature* main
v1 v2 v3 v4 v5
74
Git source control: List turns into Tree
v6
Diff 5 main
v1 v2 v3 v4 v5
75
Git source control: List turns into Tree
v6
Diff 5 main
v1 v2 v3 v4 v5
76
Git source control: Tree turns into graph
v6
Diff 5 main
v1 v2 v3 v4 v5
77
Git source control: Tree turns into graph
v6 v7
Diff 5 main
v1 v2 v3 v4 v5
78
Git source control: Tree turns into graph
What’s in v7?
[v5 plus Diff 5] OR
[v6 plus Diff 3 plus Diff 4] *new_feature*
v1 v2 v3 v4 v5
79
Git source control: Pruning the tree
This feels a bit awkward. Can we keep things as having one parent each?
*new_feature*
v6 v7
Diff 5 main
v1 v2 v3 v4 v5
80
Git source control: Pruning the tree
v6
Diff 5 main
v1 v2 v3 v4 v5
81
Git source control: Pruning the tree
v6
Diff 5 main *new_feature*
v1 v2 v3 v4 v5 v6’
82
Git source control: Pruning the tree
Copies the diff on top of the commit you are rebasing onto
Leaves an orphan commit (v6)
v6
Diff 5 main *new_feature*
v1 v2 v3 v4 v5 v6’
83
Recommended tutorial
● https://learngitbranching.js.org/
● We’ll show usage and concepts in this lecture, but this tutorial is highly
recommended if you have not used git on a large project before
● Git can feel very complicated when first starting out
a. It’s easy to get lost in the terminology, and
b. git does not surface any graph diagrams like the one shown in the prior slides, so it
can be tough to figure out exactly what is happening in your live repository
84
Git source control:
Basic usage (local)
git init
● Creates a blank repository locally, with
data in a hidden .git directory.
git status
● Output will show hello.txt is
"untracked".
85
Git source control:
Basic usage (local)
git add hello.txt
● Add a file to the "stage" (or "index")
repository state.
git status
● Output will show hello.txt is
staged for commit.
git commit
● Create a named historical state of the
repository with staged changes.
Note: every commit requires a message that describes its
contents (see the -m flag)
86
Git with Gerrit (remote)
87
Git with Gerrit (remote)
git push
● This step fails. Code must be
reviewed!
git review
● Submit code for review.
88
Submitting in Gerrit 89
Git with Gerrit (remote)
git push
● This step fails. Code must be
reviewed!
git review
● Submit code for review.
90
Git source control: Advice
● Get familiar with merge and rebase. Use them to manage how your commits to
the main branch look.
● For class: Always send code for review, and submit in Gerrit web UI
91
Coming up
Assignment 1
Lecture 2
● Testing
92