3 ms·
It often makes sense to have 2 alternate implementations of a component in the same codebase, so you can switch between them at startup/during runtime, and comp
by axod 17y ago
It often makes sense to have 2 alternate implementations of a component in the same codebase, so you can switch between them at startup/during runtime, and compare them side by side. Something that isn't as easy to do if you create 2 separate branches.
- etherealG 17y agoI think a better solution is to have both features in branches, and have a 3rd branch which allows realtime switching between the 2. a nice upside is that you can merge changes to each feature up into the "combined" branch as they get stable, to test side by side. when you finally finish, you can leave feature a behind by merging b into your release, or vice versa. or maybe even merge both into mainline. sorry, the point I was trying to make is that cheap branching and merging is still an easier way to manage this situation than just ignoring branches altogether.
- axod 17y agoIn what way easier? A: Create separate branches, manage merging/updating unrelated changesets. B: Create 2 implementations of something in code, and manage nothing. I guess it depends on how easy it is to isolate the part you want to create 2 implementations of, so it may depend on what language you're using as well as how you architected things. Branching+Merging just seems like something extra I have to do, manage, and remember. Like filing. And I still can't see what benefit it gives for many cases. But that's fine I think... I just don't get it. Maybe I'm too old ;)
- barrkel 17y agoWell, if you have a well defined protocol / interface for your component, and you have a runtime versioning mechanism (something as simple differently named DLLs will do if you're at the C level), then you ought to be able to do both: put the new code in a separate branch, but still switch in the old code at runtime. An advantage of keeping an old code in its own branch is that it's less likely to become incompatible through random changes. In particular, I'm thinking of bug compatibility: there may be bugs you wish to fix in the new code, but you don't want to fix in the older code because of third-party dependencies.
- jrockway 17y agoIndeed. It's a very common pattern to "has a" something that does some role, and then provide varying implementations. Image::PNG, Image::JPEG; Logger::File, Logger::Syslog, Logger::Database, Logger::Email, etc. This may give you millions of combinations, but since the various parts that don't need to interact can't interact, this isn't really a problem. OOP is nice when used by people that know OOP.