420 likes | 787 Views
Version Control. TFS Without Fear. Getting To Know You. Who here uses version control? What tools do you use? Why do you use it?. Why Talk About Version Control. Most colleges don’t teach it Is an integral part of a programmers daily life Should be using it multiple times per hour
E N D
Version Control TFS Without Fear
Getting To Know You • Who here uses version control? • What tools do you use? • Why do you use it?
Why Talk About Version Control • Most colleges don’t teach it • Is an integral part of a programmers daily life • Should be using it multiple times per hour • Many people do not take full advantage • Many people use it wrong
What it is and does • A repository containing a project’s history • Tracks project artifacts’ history • What does that mean? • It keeps a record of each change to a project’s artifacts • The first step to CI
What it isn’t • Backup system
Why We Use It • Track changes throughout product life • task completion • bug fixes • Story/feature completion • Allows Teamwork • multiple people collaborate on project • Can recover from faulty commits • rollback
Why Track History? • Frequently need to know • When was feature added? • When was bug fixed? • When did we release?
Why would we need to know that? • Where are we in development? • Release notes • What was included in release? • When was bug introduced? • Hot-Fixes
How we use it • We commit (check in) code that is “done”, along with the associated tests • Tests all pass (not just the new ones) • Code is refactored
What we store • Whatever we need to successfully build the system • Source code • Test code • Build files • Project definitions • Configuration files
What we do not store • Anything the build process can create • NuGet packages • Compiler generated artifacts • dlls • exes • Etc.
How version control works • Various implementations • Distributed • E.g., GIT, Mercurial • Out of scope for this presentation • Centralized • E.g., CVS, Svn, TFS • Server based workspace • Local workspace
Centralized Repository • Repository on some server holds history • Server based workspace • The server tracks all changes you make • Requires connection to server while working • Local workspace • Your local workspace tracks all changes you make • No connection necessary until commit • We discuss centralized local workspace
TFS Local Workspace • Maps repository location local folder • Adds hidden folder to local machine • $tf • Tracks changes in $tf • Commit moves changes to repository
When to Commit • When TASK is done • When BUG is fixed • Do not wait until Story is done
Do NOT End Day Without Commit • Why Not??? • If can’t finish in a day, task too big • You probably don’t fully understand problem • Your code will be too complex • Other problems exist
Example • Jane works on big task • Doesn’t finish, goes home • Code is on her work station • Does not work next day • Got sick, hit by bus, … • Team is stuck waiting on task
Solution • Delete all of your code • Start over tomorrow • Break task into effort < 1 day • Complete manageable tasks • Commit completed task before leaving • Some would assign task to different person
Commit – What it Means • Your code is done • For the current task • Your code is tested • You put your seal of guarantee on the code • Now you check in to repository • Code is available to team
Commitment to Your Team • You make a promise to your team that your code is tested and works to specification
Interesting Observation • You should be able to deploy a working subset of the system from any commit
How to Commit • Select files to commit • Usually 2: test, production • If more, probably have poorly defined tasks • Link to task • Write good comment
Write Good Commit Comment • A. K. A. – Log message • To help a programmer in the FUTURE • Task description does part • Depends on GOOD task description • What you did • Why you did it
Workflow – The College Way • Write some code • Run the code to see if it works • Fix as necessary • Repeat until assignment is done
Workflow – Single Professional Programmer • Refresh from repository • Write test code • Edit production code • Run tests • Loop to 3 until all tests pass • Loop to 2 until task is complete • Commit to repository Some might swap 6 & 7
Things to Notice – Working Alone • Refresh from repository • Your local workspace matches the latest in repository exactly • You do your work as described above • You commit • your local workspace matches the latest in repository exactly • Life is Good
Workflow – Multiple Professional Programmers • Refresh from repository • Write test code • Edit production code • Run tests • Loop to 3 until tests pass • Loop to 2 until task is complete Now what? Ready to commit?
Things to Notice – Working on Team • Refresh from repository • Your local workspace matches the latest in repository exactly • You work as though you are alone • You commit • Your local workspace might not match repository • Code in repository might not even compile • What the ???
You Need Extra Steps • Other programmers make changes • Possibly including your current file • Facilitates team projects
Workflow – Multiple Professional Programmers - Continued • refresh from repository • merge as necessary • run tests • edit production code to pass tests • run tests • loop to 10 until all tests pass • loop to 7 until all tests pass • commit to repository
1st Step to CI? • What is CI? • Continuous Integration • On Commit • Build server builds code • Runs unit tests • Reports results • If your code breaks the build, but is in VC your team is dead in the water
TFS Solution • Gated Build • Shelves changes • Builds shelveset • IFF build passes – commits • Else – reports error
Demo • CI Build • CI Build w/ error • Gated Build • Gated Build w/ error
Try It • MSDN subscription • Visual Studio Online - free • http://www.visualstudio.com/products/visual-studio-online-overview-vs
Learn More • http://msdn.microsoft.com/en-us/library/vstudio/ms181237.aspx • Contact • CAndersen@planetds.com • Blog: http://geekswithblogs.net/ChuckAndersen