I don't know if this is a thing but here's a silly idea. Often there are cases when you have to refactor code such that you need to change code pertaining to some particular area. This may involve changing functions or variable calculations spread across multiple files. Let's say I tag these places with a comment saying "tag server_path_calc". When the time comes to refactor or change the server path access logic, I can just search for these tags and make changes quickly rather than thinking "Hm What else I need to change where?". Does anyone follow this kind of strategy in programming?

A somewhat concrete example is: Let's say I have a binary repository whose path calculation depends on some variables. Now this calculation is used by some python scripts and also some CMake files. I tag wherever I access these paths as "# tag repo_path_calc".

Will this be an efficient process? Are there any productivity tools to do it.

When variables are multiple, it becomes hard to find/search and refactor across files unless you see what broke (via unit or manual testing) and continue to fix it.

Another example if it helps. The problem I pose is of search/find/refactor cycle, not code organization. Lets say I have an online repository (such as Maven/Nexus) to store binaries.

  • A python module is responsible for upload/download of artifacts segregated into a class
  • There are some tools who do path calculations and use this module above to transfer binaries
  • There is a CMake build system which produces artifacts and meta data used for forming paths for this python module to use.
  • Now there is a C++ application which could also access this online repo and download some application data (meshes, resources, images etc).

Now the online repo path changes (or the organization of the repo changes). Now I want to track down all different pieces of code which have this sort of access to the repo. How would you do it? You would search for these well named classes/variables and hope you reach all of the related code? I was just doing a mental experiment (silly as i noted) to see if comment tags can be used to track all these changes across multiple scripts/languages/modules. We tag content all the time, we also tag lets say commit descriptions to segregate them into "chunks of a particular implementation" for SCM software like Perforce. In code, yes we do have code organization but everyone starts with a "search" button right. In my case not everything is in one IDE/language.

  • 4
    Has anyone on this project thought about consolidating such changes into their own class factory or factory method, or some other generalized programming construct, rather than patching the code in multiple places? Jun 22, 2016 at 18:23
  • 3
    Can you give a concrete example? At the moment, it sounds like you have either duplicated or fragmented knowledge (or both), and the correct solution would be to refactor your code such that the knowledge is consolidated in one place, and one place only, so that the question doesn't even pose itself. Jun 22, 2016 at 18:31
  • So the thing is to ensure that one neat python class is used across CMake and C++ modules and all it takes is to search for it by name and change the source around it. And modules should not interact with the repository on their own but with that one single tool? :) I may not have sorted out the thoughts in my head properly. Hm Jun 22, 2016 at 19:09
  • 1
    Or, you could simply use a configuration file. Jun 23, 2016 at 0:55

2 Answers 2


When you are working on a code-base where you seriously consider this a good idea, it's a sign that you might be working with a horrible mess of spaghetti code.

In a well-organized codebase such tags should not be necessary, because each of these functionalities you mention should be contained in a single place. Components should be encapsulated and loosely coupled, so that you can change the way the path to some binary file is generated without having to change any other code.

  • Yes, it sounds like the design either violates Once And Only Once by duplicating knowledge such that it has to edited in multiple places in lockstep, or has fragmented knowledge across multiple places. Jun 22, 2016 at 20:23

I've used the approach you describe, and it does work. However, you have to be careful with what you use it for. You can only use it opportunistically to quickly find some of the places you need to edit. You cannot use it to find all of the places that need editing.

The reason you can't do this (or, perhaps more pedantically, it is extremely difficult to do this) is because the tags are not directly tied into any actual syntactic content. They're comments. The tags are also only tied to semantic content when a developer felt the tag should go there. If they miss a tag, their code goes untagged. This means their code will now not be updated.

The naïve solution of simply paying extra attention to the tags also ends poorly. When you have to pay more attention to the exact content in the comments than you do in the code, there's a problem. There's also the issue of tag explosions, as you want more and more careful annotations of code.

Tags will never be a valid replacement for well organized content which does not need tags. However, if your content is already in a form which cannot be well organized, tagging may be a useful way to find most of the connections you need between regions of content. I would not call it "tag based programming" because you should not be basing your programming on tags. However, "tag accentuated programming" or some similar phrasing may capture a very useful idea in software development.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.