rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.91k stars 299 forks source link

Add Workbook name as prefix to Exported modules. #5521

Open Jomili1 opened 4 years ago

Jomili1 commented 4 years ago

Description:

Add Workbook name as prefix to Exported modules.

Additional Context:

I do a monthly backup of all code modules, forms, etc. I have a macro to do this, and it adds the workbook name to the front of the module so if two different projects have the same module name there's no Overwriting happening and I can always trace back to the original project. I'd like to see that ability in Rubberduck.

retailcoder commented 4 years ago

Wouldn't it be simpler to use folders for this? This feature works best when you export to a project-dedicated folder on the file system, like a git repository for example... which very arguably makes a much better backup than any filesystem-based solution.

IvenBach commented 4 years ago

I came to RD not knowing about a Version Control System (VCS). The ability to export to a dedicated folder as @retailcoder suggests that's set up for that project allows you to then git diff . to get a difference between them. git or any VCS will save your goose from getting cooked unintentionally.

Jomili1 commented 4 years ago

Folders could work, but for instance in my Personal I have 8 different modules and 6 different forms. I also have two home grown addins with their own modules. I also have projects in Outlook, Word, Access, and Powerpoint. Once per month I back them all up to the same folder, which I (usually) don't touch again until the next month. Exporting each to a separate folder makes sense, but also ramps up the effort. Short and sweet is what I'm going for. Like I said, I can already do this, but it would be nice if Rubberduck had that as an option.

IvenBach commented 4 years ago

It sounds like you would want to keep them in their own folders instead of mixing them. What you're describing is like taking flour, salt, sugar, pepper, cinnamon seagulls, finches, penguins, crows, quail and mixing them all together when they're already separated. As they say "Birds of a feather flock together".

retailcoder commented 4 years ago

I would put each project into its own folder, and add each one to a git repository. When you make changes to a project, export the source to the folder, commit changes, done - push to bitbucket or github private (or public) repository, and then no monthly backups need to happen anymore, and the code is readily available and any project can easily be reverted to any commit: manual monthly backups are reinventing a wheel that doesn't need reinventing!

That said, the filename has no bearing on how a module gets imported (it's the VB_Name attribute that determines the component name), so I suppose it can't hurt to offer the option... although I remain convinced that separating projects into separate, distinct folders is primordial to an orderly dev environment.

Jomili1 commented 4 years ago

retailcoder, "orderly dev environment" doesn't really define my situation. I've been fooling with VBA for a few years now, but it's all been at work and it's been pretty haphazard, so while I know a whole lot more there's also a whole lot of holes in my knowledge base, so when you say "put each project into its own folder, and add each one to a git repository. When you make changes to a project, export the source to the folder, commit changes, done - push to bitbucket or github private (or public) repository" you're speaking gibberish to my ears; I don't understand.

IvenBach commented 4 years ago

You story is where Past-Iven was 3.5 years ago when I found RD. https://guides.github.com/introduction/git-handbook/ can help answer questions you may have.

I had those same exact comments when I first heard about all this too. Keep at it and it'll pay off. Trust me it will.

Jomili1 commented 4 years ago

Thanks for the encouragement and the link. I'll study and learn. I assume RD is RubberDuck?

IvenBach commented 4 years ago

RD = Rubberduck.

Enjoy your studying. You're in for an frustrating-but-rewarding learning experience.

daFreeMan commented 4 years ago

Also, stop by the "war room" (or "the pond" as Iven calls it) to chat if you have questions. You'll learn about all the problems with your code and coding style that you never knew you had, more importantly, how to fix 'em.

You'll learn a lot over there, I sure have!

retailcoder commented 4 years ago

@Jomili1 it's okay, Rubberduck was my first time actually using source control outside of work, and my first time using git at all!

This site we're on - GitHub - is a cloud-based service that hosts source code in "repositories". github.com/rubberduck-vba/Rubberduck is the repository for Rubberduck: it holds the entire project's history, from the very first commit that was made. BitBucket.org is another (competing) such cloud service provider - both GitHub and BitBucket use a version control system called git. Programmers around the world, in every language, use git source control (or similar: SVN, Mercurial, etc.; git has been emerging as the clear winner for a while now though) to track code changes, and Rubberduck's export project feature (combined with sync project from file system) makes it easy to use this standard developer tooling with VBA code, without needing to write custom code to extract the VBA source from Office documents.

Once you've set up a git repository, all you need to do is to export your project to your local repository (aka "git clone") whenever you make a change/changeset, and then git automatically tracks what files were modified (and how), what files were added, or removed; you commit the changes to your repository (with a descriptive message), and git will then allow you to view the entire commit history of any given file - GitHub and BitBucket both provide tools to link commits to some form of ticket system: GitHub uses "issues", BitBucket integrates with JIRA - and with these trackers you can now link your work to, say, helpdesk tickets, or GitHub issues; you get to plan and organize your work into KanBan boards (todo/wip/done), split tasks among team members, etc.

Code that is under git source control does not need to be backed up: the repository is the backup, and it's secured and globally accessible. Code under source control doesn't need comments that say e.g. "ticket 7832 06/08" or anything like that, because a commit would already be linking the code diff to that ticket (and each commit already has a timestamp).

There are so many advantages to using proper source control, and the tooling is current and constantly evolving, which is great when our tech (VBA) is otherwise essentially frozen in time.

Jomili1 commented 4 years ago

Thanks everyone for the handholding and getting me started. Unfortunately working with VBA isn't my job, it's what I got into to do my job, so all of my efforts and learning fall into those small spaces when I get a break in my job, but I work in Budget so those breaks are small. But over the next few days or week I'm going to read through all the GitHub stuff until I can start interacting intelligently. I appreciate your patience and understanding.

A9G-Data-Droid commented 4 years ago

@Jomili1 git can be overwhelming at first. Iven told you about using the command line, which is the direct interaction with git. I find using a GUI like git extensions can get you going faster.

https://gitextensions.github.io/

You never have to drop to the command line to perform all the basic actions. You can just create folders for your different projects and right-click on the folder to choose "Create new repository". Then right-click again and choose "Commit".