Archive

Posts Tagged ‘Source Code’

Some notes on why and how to use a Version Control system like Git

Just recording here for posterity some comments I made on Delphi Deverloper Facebook group on the benefits and practice of using a Git repository on an online service like GitHub.

The idea with Version Control is that you can track changes, rollback easily to previous versions, if there are many contributors you can track which changes/lines they contributed etc. – e.g. see how GitHub diffs online (each Git client can use other diff tool) between the previous and newer version for a commit: https://github.com/…/03b0d7d20668a18b611dacf3134d0cdd5d…

Ideally you make commits often (a commit can contain changes to multiple files, ideally for just one feature/bug you were working on) and push them to the remote repo regularly (for extra safety/backup too), but usually when the code is buildable.

Some teams also spawn branches from the main branch in their repository (similar to forks, but those are for third parties usually to make a derivative of your whole repo) to work on experimental stuff and they merge them (and can get rid of those branches then) with the main branch when the feature/fix they were working on is ready. That way they also keep their main branch always buildable and working for testers and power users. Via automation sometimes they "continuously" (see CI / Continuous Integration) make latest/nightly builds from that main branch.

Also from that main branch they regularly make releases for the rest of the users when they’re confident enough the app/library/driver etc. they build is stable to release.

Even for small projects it’s worth setting up a Git repository (can even have pure local ones [for history tracking] with no remote) now that version control systems have nice visual clients without having to learn commands and use from the command-line. People also use them to track other artifacts like documentation, ideally text based artifacts, but there are diff tools that can compare binaries too (like images shown side by side with differences highlighted). There are some version contorl sytems specialized for non-text based artifacts, but Git can store versions of binaries too, even though it is textline-change focused.

The easiest way to use the Git repositories that GitHub offers for free (now backed by Microsoft so it will exist for years to come) is to install the GitHub Desktop app from their site (first you make a free account from their website). Then you can sync your local files to a public repository you make there (you commit updates to your local clone of the remote repository, then push the commits from the local clone to the remote repository). Others can make forks of that repository and work on their own versions and GitHub makes it easy to make pull requests (initiated by them or you) and merge changes from forks of your original repository into your own if/when you wish.

So it has the benefits of Git-based Version Control with extras too like optional Discussions, Wiki, Issue/Enhancement tracking, Milestones and Releases, Projects with Kanban boards and automated movement of tasks between columns on those boards etc.

There also other similar services like GitLab etc., but GitHub is probably the easiest to use and quite generous in offerings for OpenSource projects nowadays.

Categories: Posts Tags: , , ,

HowTo: Remove unused references and using clauses in Visual Studio

I recently posted a list of the VS2015 extensions I use on my main machine at: https://zoomicon.wordpress.com/2015/11/13/visual-studio-2015-extensions-i-use/

From that list of extensions I use the Productivity Power Tools one, it has a "Power Commands > Remove and Sort Usings" action that one can right click and run on the whole solution. Much easier than opening it for each

There is another nice extension called ResolveUR that is not available for VS2015, but only for VS2013 (think you can edit its .vsix and make it work for it too though, see the process for other similar extension explained at https://devio.wordpress.com/2014/12/03/remove-unused-references-with-visual-studio-2013/). I usually open up the solution in VS2013 too just to run that. Resharper also has such functionality as shown at:

https://www.jetbrains.com/resharper/help/Refactorings__Remove_Unused_References.html

Alternative is to use the Copy References extension and right click a reference under the References subtree of a project, then select "Copy Reference", then Remove the reference and rebuild that project. If rebuild fails, then right click at the References again and select Paste Reference. Then repeat till you remove all references that are not needed

In fact one should FIRST remove all unused using clauses and THEN remove unused references. That is because some files like App.xaml.cs, AssemblyInfo.cs may have using clauses that they don’t really use. So unless those using clauses are removed, the compiler thinks respective references to assemblies those namespaces were at are needed