Subversion, sometimes known as SVN, is an open source version control system. Subversion allows users to keep track of changes made over time to any type of electronic data. Typical uses are versioning source code, web pages or design documents.
Why Subversion over Visual Source Safe?
While Visual Source Safe (VSS) is fully integrated into the Visual Studio environment, there are many disadvantages that can not be ignored.
Sam Gentile, in his blog post entitled "No More VSS, Its Subversion", is so bold to just link to the search terms "VSS+corrupt" on Google to make a case for the ubiquity of VSS problems.
- Numerous accounts of crashing and corruption: See links above...
- Not a client-server application: The current VSS setup makes it difficult to expose source code to developer's outside your network.
- Database size restriction: Some say the limit is 2GB, others say 10GB. Even if it's 100GB - who want's to worry about a size restriction?
There are also a number of issues with VSS that are most fairly described as "preferential issues". I cite these issues because while they are not technically "bugs" they do represent limitations that many developers find as a hurdle to deal with in the real world. Examples of some of these issues are exclusive file locking and VSS's method of tagging and branching make it difficult at times to work with.
Subversion features the operations you would come to expect from any source control system. If you come from a VSS background, some of the terms may seem a bit awkward. Below is a list of the most common operations you encounter while using Subversion.
The trunk is the main thread where you will often work on your source code. The trunk acts as the basis where you can branch off and make changes or create point-in-time copies of your code. The trunk, just like a tree, is what supports a source code project.
As opposed to a "check out" in VSS, a Subversion checkout is when you contact the code repository for the first time and bring down the files on to your machine. When you do a checkout the file and directory structure is created on your computer and a hidden folder is created under each folder under source control that helps maintain the state of each file.
When you want to add a new file to the source control repository, you must first mark the file as being added. This will signal to Subversion that the next time you synch up with the repository, the file must be copied from its location on your machine to a versioned state on the Subversion server.
Many changes that you make to files will require a two-step process to expose the changes to other users of the repository. After you have added or changed a file, you must commit the changes up to the Subversion server. This will allow you to make many changes, but submit all the changes to the repository in a single transaction. Changes to the repository are atomic actions.
The two-step process also enables Subversion to keep the code repository's integrity while not requiring a exclusive lock on files under source control.
When multiple people are working on the same project, inevitably they will end up editing the same file at the same time. When this happens there is a conflict in file states that must be resolved. When you go to commit your changes to Subversion, if a conflict is detected you will have an opportunity to resolve the conflict. Some of the UI tools make the experience prettier, but the process is the same whether or not you are using a GUI tool or the command line. Conflict resolution will expect you to choose portions of a file or entire files all together as the file version of the file. You do have an opportunity to say, "give me this section from file 1 and this section from file two" in order to reliably keep everyones changes. Conflict resoution is usually a non-event as often two developers are not working on the same line of code in the same file. If the changes in question are on the same lines of code among what the developers changed, then a decision must be made as to who's changes to keep and the application must be tested or perhaps refactored to not break this build.
A feature that Subversion implements well is the branching feature. Rather than maintaing some huge change log off the main repository thread as to what a "branch" is, Subversion makes a copy of the trunk and allows you to make any changes necessary. To bring the changes back down to the trunk you will merge the changes down to the trunk.
Once you have created a branch that you need to bring down to the trunk you will run a merge operation. Merging a branch down to the trunk is equivalent to comitting a large-scale change to the repository. If there are any conflicts during a merge Subversion will give you a chance to resolve the conflicts.
Tagging gives you a way to set aside the trunk at a point and "label" the state of the trunk.
Branching vs Tagging
Often people wonder what is the difference between branching and tagging. You use a branch when you want to make significant changes to the trunk and still need source control features of commiting changes to the server, but don't want those changes to effect the users of the trunk. Branching creates an isolated environment for someone to make changes to the code.
Tagging is best used as a point-in-time snapshot of the repository. For instance at each version release of your code you would want to tag the code base.
When someone says they have Subversion installed on thier machine, often they mean they have a Windows Exporer shell installed and not the server on the box. Subversion is a client-server application where the service, security and database all live on a single server and clients (developer machines) use a separate tool for accessing the repository. The most common tool on Windows is Tortoise SVN.
File system integration is seamless. Tortoise SVN is a Windows Explorer shell extension that grants you access to the Subversion repository natively from Windows Explorer. If you right-click in a Windows Explorer window you immediately have access to the Subversion system. The greatest benefit from granting access from a shell extension is that the access is pervasive. Any window that grants you listing of the file system will expose the Tortoise menu (ex: File-> Open dialog boxes).
You may download Tortoise SVN here.
As a .NET developer, there is one issue that you must be aware of before you begin using Tortoise SVN for your Visual Studio projects. Tortoise SVN uses hidden folders within the file system to help maintain the link with the central repository. These hidden folders are by default named ".svn". You will find this folder under every folder that is under source control with Tortoise SVN.
For some reason, the ".svn" naming convention is nothing but trouble to the Visual Studio IDE. If you try to use Tortoise SVN using it's default settings you will eventually encounter the following error while trying to run your projects and solutions in Visual ] Studio:
Cannot load project information from server
While this is technically an error stemming from a problem in the Visual Studio IDE, the Tortoise development team seemed to concede that it was easier to make a small change in the Tortoise setup rather than wait for an update to Visual Studio.
Therefore before you begin using Tortoise SVN for the first time, be sure to change the settings for Tortoise to use a hidden folder named "_svn" rather than ".svn".The following section will walk you through the process.
Configuring Tortoise SVN for use with Visual Studio
Once Tortoise SVN is installed on your machine, open a Windows Explorer menu and right-click to open the context menu. From the menu do the following:
- Select TortoiseSVN
- Select Settings
- Check the box labeled Use "_svn" instead of ".svn" directories
- Click OK
Then you are prompted to reboot your machine. While the reboot is annoying, it is required.
Note: The change in directory setting is appropriate for all Visual Studio versions, not just for Visual Studio 2003.
When you begin using Subversion, you will appreciate the ease-of-use and performance, if you do not have a way to integrate with Visual Studio you will find it hard to use. Particularly if you have to somehow keep track of which files were added to your project and so on.
There are at least two options available to you to integrate access to the Subversion repository from within the Solution Explorer inside Visual Studio.
- AnkhSVN: AnkhSVN is free and provides the same types of services that you would expect from VSS integration with Visual Studio. The only downside to AnkhSVN is that the UI implementation sometimes feels a little clunky. Asethetics aside - AnkhSVN is a solid program which allows you to seamlessly integrate with the Subversion repository.
- VisualSVN: VisualSVN is much like AnkhSVN, but the UI experince is cleaner. Also the icons used in the context menus are exactly the same as in Tortoise SVN. This little touch just makes it easier to keep track of what operations you are performing since the experience looks the same in and out of the exporer shell. Functionally though VisualSVN's capabilities are equivalent to AnkhSVN. VisualSVN is not free.
One of the great benefits of working with a source control sysetm that is open source and extensibile, is how it will interface with other components in the development lifecycle.
Subversion integrates with many of the open source continuous integration packages as well as with MSBuild.
Note: Opening up access to your repository over the web can prove difficult on a Windows machine. Many people setting up for remote access will configure the repository on a Linux box running Apache.
Books on Subversion
Version Control with Subversion (printed copy) | Free e-book!
Pragmatic Version Control: Using Subversion
Practical Subversion, Second Edition
- Subversion entry on Wikipedia
- Moving from Visual SourceSafe to Subversion
- How does Subversion compare to XYZ Version Control System?
- CVS and Subversion vs. VSS/SourceSafe - Scott Hanselman
- Top Reasons Why I like Subversion Better than SourceSafe - Jesse Ezell
- Open source Continuous Integration Feature Matrix
The video and code for download is now posted at http://polymorphicpodcast.com/shows/webnavigator/.
Learn an object oriented way to encapsulate the location of your web pages, shielding the physical location of the pages to your application and creating a programmatic contract for required resources.
[advertisement] Watch the show and learn how to get $100 off an Advisor Summit event in Sept 2007.
You and Joe are working on a sizable web application. Nasty-Coder Joe, who is on another team, creates a new page that requires 2 session variables and a query string parameter in order for his page to work properly. You now need to pass data to this page to finish your last feature before you leave for vacation in one hour. Without reading Nasty-Coder Joe's code to try and figure out what the necessary session variables and QueryString paramenters are, how do you use his page?
Controlling page flow on the web has a number of distinct problems. Since the web is literally a "web" often the entry points to any one page are numerous. Many developers have come up with solutions to addressing the problem of page-flow in a web application, but the solutions sometimes end up becoming a thick mire of XML structures that try to be predictive in page-flow rather than facilitate the choose-your-own-adventures style of navigation often found in a web app.
Web Navigator is a technique, or pattern or approach that I came up with when I was faced with the same problem as stated at the beginning of this show. I was working alongside a developer who was creating pages that I needed to use, but I had no idea how to pass the correct information to the page.
What I came up with I call "WebNavigator".
Yes, I know I was wearing my terribly-original-idea-hat that day...
Web Navigatior is:
- A way for you to encapsulate the contract that each page has for required data
- If you change the contract, you experience compilation errors
- Abstract the location to pages to support change
- Who really cares if the login page is under a login folder or at the root of the site? You just want to get your user there!
- A way to organize and create a composable model of your site's navigation
- Once you have tens of pages, how will you know which pages relate to one another?
- A way to allow simple was to weave in and out of secured areas of the site
- Using SSL can be tricky. There are rules about how you must enter and exit secure areas of your site. Having a object to manage the changes in SSL makes your life easier
What is its Structure?
The syntax is based around a fluent interface. For example if you wanted to navigate to the homepage of the website, you would use:
- The destination methods (ex: WebNavigator.URLFor.Home()) will always return strings. This is so you can still use the Web Navigator class to build URLs for you without requiring a post back to build the URL.
- WebNavigator.GoTo() handles the redirection. You can overload the method to support Server.Transfers and instructions to use SSL
- For example, the following should give you a very good idea of where the user will end up: WebNavigator.GoTo(WebNavigator.URLFor.Membership.Login());
- If you have the access to a page wrapped up in WebNavigator.URLFor.Login() and it's real URL is http://domain.com/login.aspx, but used to be http://domain.com/login/default.aspx your website will not experience any broken links. You will change the mapping to the new location in one place and the rest of the site will reflect this change.
Examples of Encapsulation
When using pages throughout the website, some pages will require simple QueryString values and other pages will need session variables set and perhaps other requirements. Web Navigator will encapsulate the requirements of a page. When you are a developer consuming the page all you care about is what the destination method contracts in it's method signature.
For example, the following listing will show you how to pass a user's email address to the login screen.
// set userName to something... perhaps from the database
Using QueryString Values
The most common use of a destination method is to encapsulate the use of a QueryString parameter. The following example will show you how to hide the QueryString requirements.
public class Membership
public string Login(string userName)
Using Session Variables and Other Resources
Sometimes you do not want to pass an item the QueryString, or a page requires a complex-type before you can use it. (Think of a page requiring an object collection in memory). In these types of cases you could pass the data around in a session variable. The following will show you how to use session variables.
public class Reports
public string SalesReport(OrderCollection orders)
Using this method will set aside anything you need into session and then return the destination URL for you to use whenever necessary. The fun doesn't have to stop at session variables. You can use the same technique for application variables, context items, etc.
The point is that what is inside the implementaton does (setup QueryString vales, add Session variables, etc..) is completely hidden from the developer who is using the page. The method signature of the URLFor method will establish a contract for any required information for the page.
If the contract to a page changes, you will encounter compilation errors. If the page in the past did not require any external data, but then was changed to needing a piece of data, the updated destination method signature will cause the application to encounter compilation errors where ever the page is used. This will ensure the page is always getting what it needs.
For instance if your content editor page previously did not require a content ID the method might look something like this:
Now you have decided you want to pass in the content ID so the call would look like this:
// get contentID from somewhere
Handling SSLYou can implement it in different ways. I have done it as follows in the past:
Web Navigator is a pattern that you can use to help manage navigation throughout your websites. The strengths of this technique are:
- Encapsulation of page location
- Public contract of page requirements
- Single place of change for URLs (avoiding broken links)
- Manage SSL "auto-magically"
- Makes code easy to read and maintain
The Design Patterns Bootcamp : Model View * Patterns series is now complete!
The series features two audio pieces and five instructional videos. The audio portions take care of introducing the concepts and answering frequently asked questions, while the videos cover the following topics:
- Implementing Model View Presenter
- Supporting Windows Forms
- Controlling User Messages
- Data Sources, Service Layers & Maintaining State
- Encapsultaing DropDownList Data Sources
Good luck while you build your applications to last!
Check out the latest release in the video releases of the Design Patterns Bootcamp Series: Model View * Patterns. This video will show you how to report messages back to users in a web application written with MVP (Supervising Controller).
Check out the latest release in the video releases of the Design Patterns Bootcamp Series: Model View * Patterns. This video will show you how to implement a web application using the Model View Presenter (Supervising Controller) design pattern.
Make sure to keep checking the show notes page as there will be more in this series of videos!
Check out the latest release in the video releases of the Design Patterns Bootcamp Series: Model View * Patterns. This video will show you how to take an existing web application written with MVP (Supervising Controller) and re-purpose the lower layers for use in a WinForms application.
Every once in a while something happens that is really special. When you maintain a blog, podcast or a newsletter list - as much as a labor of love as it may be - at the end of the day you want people listening to what you have to say. Recently Microsoft's own Simon Muzio helped make that wish come true for me with a little more force. The Polymorphic Podcast is now listed under the podcasts section of the official ASP.NET website. It's nice to be in such good company as Scott Hanselman (Hanselminutes), Carl Franklin and Richard Campbell (.NET Rocks!), Wally McClure (ASP.NET Podcast) and Podcast Studio.NET.
Design Patterns Bootcamp: Model View * Patterns
Thanks to Dave Bost for the intro!
What is the Purpose of These Patterns?
- Put code in its proper place
- Way to provide clean reuse of the domain model
- Way to increase testablity
Rocky Lhotka wrote a blog post about a year ago that
discusses where validation logic should live in an application.
The entire post is great, but by the end of the post he make a
point that reaches beyond the question of where validation should live...
There's nothing more expensive than a line of code in the UI -
because you _know_ it has a half-life of about 1-2 years. Everyone
is rewriting their ASP.NET 1.0 UI code to ASP.NET 2.0. Everyone is
tweaking their Windows Forms 1.0 code for 2.0. And all of it is junk
when WinFX comes out, since WPF is intended to replace both Windows
and Web UI development in most cases. Thus code in the UI is expensive,
because you'll need to rewrite it in less than 2 years in most cases."
Model View * Patterns... What are they?
The main drawback to these patterns is usually the learning curve... this show will hopefully remove that barrier-to-entry. The first on the scene and primary pattern to all each involved is the Model View Controller. This pattern is used throughout many of the modern development platforms. The quickest way to describe MVC in the terms a .NET developer will understand is that you code your pages in such a way that you place the code that would be in your code-behind, into a separate class. This class is called a "controller". The "model" are your domain objects (business objects or data access objects).
So your controller will tell your domain objects what to do. Once the work is done, then the user interface must be updated. The code in the user interface is known as the "view". So if you can picture that the code-behind in an ASPX file is no longer where you do any real work and can re-label that code the "view", and you can picture a new class that would act as a bucket for the code you would have written in your code behind to do the work (call that the "controller") and imagine the finaly peice of the puzzle as a class that talks to the database, to encapsulates some business logic or does something else completely unlreated to any user interace (and call that the "model"), then you, my friend have just understood the most difficult part of the Model View * patterns.
What's built into ASP.NET?
Some people say that ASP.NET has the MVC pattern implicitly
implemented in the web forms architecture. The thinking goes like this...
the ASPX markup constitues the view, the code behind plays the role of
the controller and domain objects represent the model. While this seems
to fit nicely into the formal definition of MVC you quickly run into
Michael Hamrah makes the point that ASP.NET declarative controls don't break pattern, just limit your flexibility.
What is the Difference Between MVC and MVP?
- in MVC view talks to Model
- in MVP view can know about model, but won't send message
How is MVP Constructed?
Model View Presenter comes in two flavors:Supervising Controller and Passive View
Make sure to check out the MVP stub generator!
- Supervising controller will has some logic in UI, such as databindingd, etc.
- Passive view will have NO logic in UI
- Supervising controller is less complex and less-testable
- Passive view is more complex and more testable
ASP.NET 2.0 Web Parts
Interview with Darren Neimke
Darren Neimke teaches us how the ASP.NET 2.0 Web Part and Portal framework can help you achieve user customization, good OOP architecture and provide points of extensibility to your application.
Darren wrote a recent book on the topic, "ASP.NET 2.0 Web Parts In Action"
I have accepted a new position as a Senior Software Engineer for a marketing research company. That being said, PDSA is looking for a few good men... or women :). If you would like a chance to work with a Microsoft Certified Partner the opportunity to work with Regional Director, Paul Sheriff and a great team, send an email to firstname.lastname@example.org.
You can call thank Wally for this.
Taking the "five things" challenge the following are five things you didn't know about me and five
people we'd all like to know a little more about:
I graduated summa *** laude from DeVry Institute with a Bachelor's of Science in Business Operations in
1996. While this might sound impressive I remain dubious.
My class was the last group of students in a major that was being cut from the school's offerings. Business
Operations was really inventory control and production management - manufacturing - which had been a dying
industry in the US for, what 20 years? (Thanks for keeping the curriculum up-to-date DeVry!)
I started school two weeks off my high school graduation and was still a bit green to the world. I thought my
business schooling was more like business administration until about half way through my time. Once I did figure
out what was going on I realized that I had no interest in what I was learning about!
We didn't really realize as students the implications of a program being cut until we got to know some of our
professors. A number of these people were out-of-work industry folks who needed a paycheck. Teaching was
obviously not a passion for them and it manifested itself in some odd ways. One professor had a penchant for
giving grades based on whether or not he liked you. My group of friends were in the favored bunch and got good
grades. This professor's laziness insulted us because we were all bright and wanted to be graded on our merits,
plus we were paying for our education ourselves so we wanted a high ROI!
In an attempt to make a splash, my friend put the lyrics to "Mary Had a Little Lamb" in the middle of
an essay test to prove that the prof wasn't grading our papers. Sure enough he got an "A" on the paper
and when nothing was done after we reported it to the Dean, we gave up and took our good grades with us.
I was born in my parents bed and my dad delivered me. This was a total accident... I have a brother that
is two years older than I am so you would think that my mom would know when she was in labor, but as she
describes it she was experiencing "back pains" instead of regular labor pains. Through what I like to
think of as divine intervention my dad had just come back early to our house with my brother from the park.
While my mom was doing what most people do in the bathroom and realized I was about to make my grand appearance
she started yelling for my father. Now, with a two-year-old in the house a common practice is to have a hook-lock
on the bathroom door. After my dad broke through the lock and carried my mom to the bed I was out and blowing
bubbles in my dad's arms within minutes. Luckily we had a neighborhood nurse who tied off my umbilical cord with
kite string until the paramedics made it on the scene.
Yes, I know I was almost born in the toilet. Let this be the last time we discuss it,
I have been skydiving twice. I have a buddy who is an ex-airborne military guy. He and a group of my
friends always talked about skydiving, so one day he set it up to call our bluff. When I envisioned going
skydiving I always thought that we would do the kind where you are strapped to a professional and you are just
there for a ride. No so for my military friend. We were signed up for Accelerated Free Fall (AFF).
AFF is the training you go through to become certified to sky dive on your own. To be AFF certified you must pass
a series of ground training courses each which is followed by a jump. You must pass seven sessions to be
certified. After five hours of ground training I was ready for my first jump. The instructors take you up in a
small plane with only benches in the fuselage to, you know, "make your exit a quick one!" When you
leave the plane you are accompanied by two highly-trained jump masters. These jump masters guide you through the
free fall to test your form and allow you to quickly try some exercises. In the minute it takes you to fall from
13,500 feet to 5,000 you are done with free fall and then you must deploy your parachute.
This was one of the most fun experiences I have ever had in my life!
I have moved more times than you. I have lived in Colorado, Wyoming, Montana, Nebraska and California.
Each state I have had lived in at least two different homes (except for Nebraska) and my upper limit of addresses
is somewhere around is six houses (California). I went to three different schools when I was in the 6th grade and
at one point had moved more times than I was years old. No, I am not an Army brat, my dad just always seemed to
need or find a new job that required him to relocate. Recently I have reached a milestone in that I have stayed
in the same general area for over ten years and have lived in the house I own longer than any other home in my
I have the entire hair metal collection. Okay so this is embarrassing to admit now, but in high school I
became an aficionado of pop metal bands. In junior high I remember being dead-set against that "metal"
music, but after hearing "Welcome to the Jungle" and "Pour Some Sugar On Me" I was hooked and
started buying all the CDs I could find in the genre. Sure, I had all to go-tos like Def Leppard, Motley Crue,
Poison, Slaughter, Warrant and the like, but how many of you have ever heard of Sleeze Beez, Sons of Angles,
Dirty Tricks or Roxy Blue? Now granted, living in the suburbs of Los Angeles in the late 80's and early 90's
where hair spray and guitar solos reigned supreme probably had something to do with it.
So here is my chance to tag some others that we all would like to know more about:
If you haven't heard it yet, the latest podcast features Rocky Lhotka where he discusses emerging technologies.
While conducting some late shopping this Christmas for my brother I encountered a "Head First" book that I hadn't seen before. The book is Head First Object Oriented Analysis & Design. The reviews are good, but one person mentions that the book is best suited for beginners.
Have you read this book? Is it worth picking up even if you are not an OOP newbie?
Latest Podcast: Rocky Lhotka on emerging technologies in .NET.
I am now an ASP Insider!
I was accepted last month into the prestigious group, the ASP Insiders. The Insiders
are a group of industry professional that get an inside look at Microsoft products and provide early feedback. I am quite honored to be a part of the group for the opportunities that Microsoft provides as well as being associated with the stunning roster.
Declarative Progamming with ASP.NET 2.0
Listener Michael Hamrah wrote an interesting blog post on Declarative Progamming with ASP.NET 2.0. Check it out an comment up!
Working with SubSonic and Loving It!
One of the activities that has kept me from podcasting is working on a side project. For this project I have been using SubSonic. I must say I am impressed... check it out!
Rockford Lhotka is the Principal Technology Evangelist for Magenic Technologies, a company focused on delivering business value through applied technology and one of the nation's premiere Microsoft Gold Certified Partners.
Rockford is the author of several books, including the Expert VB 2005 and C# 2005 Business Objects books. He is a Microsoft Regional Director, MVP and INETA speaker. He contributes to several major magazines and regularly presents at major conferences around the world - including Microsoft PDC, Tech Ed, VS Live! and VS Connections.
Rockford has worked on many projects in various roles, including software architecture, design and development, network administration and project management. Over his career he has designed and helped to create systems for bio-medical manufacturing, agriculture, point of sale, credit card fraud tracking, general retail, construction and healthcare.
If you every find yourself trying to add MS Ajax (Atlas) to an existing application and find that no matter what you do pages keep posting back instead of making asynchronous calls, you may want to poke around your web.config file.
At PDSA, we have a code generator that will build a new application based off our framework. I was tasked with adding Atlas support to one of these applications only to find out that the UpdatePanel, try as I might, would not work in our project.
After some investigating we found that the web.config had a curious entry in it:
<xhtmlconformance mode="Legacy" />
Once we removed this line in the config file the Ajax requests worked as advertised!
January 11, 2007 will be the second anniversary for the Polymorphic Podcast. I am amazed that time has gone by so fast!
In preparation for the celebration I am inviting you to participate in the show! If you have a suggestion or comment about the show please leave a comment here and I will find a way to weave it into the podcast. If you would like, I would also love some audio feedback – feel free to send me an MP3 that I can play in the show. You can talk about the show – take digs at me – whatever... :)