CPSC 310 – Software Engineering
Lecture 5
Collaborative Development & Source Code Versioning
Huge thanks to Sebastien Mosser (sebastien.mosser@unice.fr) for the slides
Collaborative Development & Source Code Versioning Huge thanks - - PowerPoint PPT Presentation
CPSC 310 Software Engineering Lecture 5 Collaborative Development & Source Code Versioning Huge thanks to Sebastien Mosser (sebastien.mosser@unice.fr) for the slides works on piece of developer software 2 Collaborative
CPSC 310 – Software Engineering
Lecture 5
Collaborative Development & Source Code Versioning
Huge thanks to Sebastien Mosser (sebastien.mosser@unice.fr) for the slidesdeveloper piece of software works on
2Email? USB Key? Shared directory?
4«Why do we version source code?»
Motivations (among others)
windchime(c)Before
9After
10«not me!» «not me!» «not me!» «not me!»
To trace changes!
«Why do we version source code?»
12...
Here is the new release!
14Here is the new release! ???
14Here is the new release! ??? It was working 2 days ago...
14Here is the new release! ??? It was working 2 days ago... Can I see it?
14To rollback changes!
«Why do we version source code?»
15rollback
16To share changes!
«Why do we version source code?»
18Centralized Model
(e.g., CVS, Subversion)
20Shared Repository create
21checkout export
Shared Repository
22Shared Repository
23Shared Repository
23commit
Shared Repository
23commit update
Shared Repository
23Shared Repository
24Shared Repository
24commit
Shared Repository
24commit
Shared Repository
24commit commit
Shared Repository
24#1: different files Atomic operations. No problem at all!
25#2: different part of the same file File Locking (old school)
26#2: different part of the same file File Locking (old school)
#2: different part of the same file File Locking (old school)
X
reject!
26#2: different part of the same file File Locking (old school)
X
reject!
26#2: different part of the same file File Locking (old school)
X
reject!
Automatic merge #2: different part of the same file
27#3: same part of the same file Conflict!
29commit
X
Shared Repository
32update
Shared Repository
33update
Conflict! Shared Repository
33Conflict! Shared Repository
34Conflict! Shared Repository
34Resolved! Shared Repository
34commit
Resolved! Shared Repository
34commit
Resolved!
update
Shared Repository
34Distributed Model
(e.g., Bazaar, Git)
35Centralized = 1 repository Distributed = N repository
36He who can do more can do less
when N = 1, Centralized = Distributed
37repository
clone clone
38add commit
completely offline!
39untracked
artefacts lifecycle
[Pro Git, #2.2] 40
untracked unmodified
add
artefacts lifecycle
[Pro Git, #2.2] 40
untracked unmodified modified
add
artefacts lifecycle
[Pro Git, #2.2] 40
untracked unmodified modified staged
add stage
artefacts lifecycle
[Pro Git, #2.2] 40
untracked unmodified modified staged
add stage commit
artefacts lifecycle
[Pro Git, #2.2] 40
untracked unmodified modified staged
add rm stage commit
artefacts lifecycle
[Pro Git, #2.2] 40
add commit push pull
41commit add commit push
Centralized Distributed
42push push push pull
Distribution!
44Spiderman’s Theorem «With great power comes great responsibility»
45Best Practices
A commit should be a logical unit and have a descriptive message (avoid http://whatthecommit.com/ ) Commit/Update frequently Inspect your changes before committing Don't break the build (unit tests) if not expected by the others
DO VERSION
Source code of any sort (Java, HTML,CSS, etc.) Images Configuration files Documentation (related to process and product) Automated Tests Files related to the project
DO NOT VERSION
Generated Artifacts | compiled code, documentation, etc. Local build environment information Secured information
Use ignore mechanism provided by VCS For Git see: https://github.com/github/gitignoreVersion control strategy for your team
?
Conclusions
46Why do we version code?
47To trace changes! To rollback changes! To share changes!
(among others)Why do we version code?
48To trace changes! To rollback changes! To share changes!
(among others)Different models for code versioning
49Centralized
versus
Distributed
He who can do more can do less
when N = 1, Centralized = Distributed
(also works for P = NP)
50