News for hackers. Stuff that matters.
Re:Distributed Version Control is here to stay, baby by steilpass on Thursday March 18, 2010 @10:03AM (#1201285)
"we developed a new way of developing software using if statements instead of branches." Is that critizing feature flags? Or is more to that?
Re:Distributed Version Control is here to stay, baby by spolsky on Thursday March 18, 2010 @10:43AM (#1201418)
Feature flags are usually just a poor-man's way to separate development (changing) and live (stable) code branches. They have explosive complexity (2^n combinations need to be tested). They require you to contort your code unnaturally to minimize the number of conditionals.
Re:Distributed Version Control is here to stay, baby by jedbrown on Thursday March 18, 2010 @11:46AM (#1201574)
Compile-time choices are a terrible code smell. If object creation is sorted out (through dependency injection/service locator/etc), the compile-time choice can usually map to exactly one runtime option and exactly one conditional.
Re:Distributed Version Control is here to stay, baby by raganwald on Thursday March 18, 2010 @12:03PM (#1201617)
Exactly. You're already creating all your objects with factories, so all you have to do is build a FactoryFactory that builds the right kind of factories and you're good to go...

http://discuss.joelonsoftware.com/default.asp?joel.3.219431

Re:Distributed Version Control is here to stay, baby by jrockway on Thursday March 18, 2010 @02:40PM (#1202098)
This is a poor argument (and sadly, I know exactly what you're linking to, without actually clicking it).

Factory factories, or dependency injection, is a lot more like Futamura Projections than a factory factory factory factory because you want a hammer.

On Futamura Projections: http://blog.sigfpe.com/2009/05/three-projections-of-doctor-f...

(And that's fu-ta-mu-ra, a Japanese name; not fu-tu-ra-ma, the TV show. I read it wrong the first time, and so did everyone I've admitted that to :)

Re:Distributed Version Control is here to stay, baby by jedbrown on Thursday March 18, 2010 @12:24PM (#1201693)
While that's a classic and amusing essay, having client code depend on concrete types instead if interfaces is lame unless you can be confident that they won't change their mind about which one they want to work with. I write mostly C, don't have anything called a factory, and yet every major object has a plugin architecture, many of these have more than a dozen implementations, and client code automatically works with all of them (and any that they or a third-party have written). Say what you will about architecture astronomy, but this is not complex and is far more maintainable and usable than the alternatives.
Re:Distributed Version Control is here to stay, baby by raganwald on Thursday March 18, 2010 @01:11PM (#1201828)
I'll take it one further and suggest that the expression concrete type is an oxymoron and that there are many, many ways to decouple code. You've mentioned two orthogonal ways to achieve this goal: Programming to interfaces (most people use this term to mean collections of method signatures) and Plugin Architectures (which sounds a lot like using composition or strategies instead of implementations).

But I stand by the tongue-in-cheek suggestion that FactoryFactories are high altitude if not low earth orbit. And obviously, you can use factories and still switch between production and development with a single flag. So please don't interpret my remarks as critical of code I've never actually seen.

Re:Distributed Version Control is here to stay, baby by jedbrown on Thursday March 18, 2010 @01:43PM (#1201946)
My use of "concrete types" was merely a proxy for any code upon which client code should not have an explicit dependency.

I don't see interfaces and plugins as being orthogonal at all, you can't very well have plugins without interfaces (it wouldn't be much of a plugin if the client depended on the "plugin" itself). Besides, orthogonal vectors don't get you to the same place. ;-)

In my opinion, the defining feature of a plugin is that it can be loaded and used with no modification of the code that uses it. On architectures with dynamic loading, this means you can drop a DSO somewhere and use it without code modification or relinking. "Factories", as usually described, would require some modification of the factory to support this new implementation (perhaps just a single line). A "factory" with a runtime-extensible list of implementations that it knows about, is a plugin architecture, but a plugin architecture need not look anything like a factory.

Re:Distributed Version Control is here to stay, baby by raganwald on Thursday March 18, 2010 @02:24PM (#1202059)
I think that some of our discussion around terms is an artefact of discussing a manifestly typed language like C. But if we handwave and say that "interface" is any dependency with at least one level of indirection and "concrete type" is any dependency with no levels of indirection, I agree that you can't implement plugins without some indirection somewhere.

That being said, you clearly can implement indirection without plugins. I think of a plugin architecture as being composition at a coarse level. In the case of a factory with a runtime list of implementations, I think of that as a factory and a plugin architecture, possibly that the plugin architecture is implemented with a factory.

Re:Distributed Version Control is here to stay, baby by nfnaaron on Thursday March 18, 2010 @11:49AM (#1201585)
What he's talking about is branching in code to avoid all subversion branches. That's probably pathological.
Re:Distributed Version Control is here to stay, baby by axod on Thursday March 18, 2010 @10:05AM (#1201292)
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.
Re:Distributed Version Control is here to stay, baby by jrockway on Thursday March 18, 2010 @11:01AM (#1201450)
Indeed. 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.

Re:Distributed Version Control is here to stay, baby by barrkel on Thursday March 18, 2010 @10:51AM (#1201435)
Well, 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.

Re:Distributed Version Control is here to stay, baby by etherealG on Thursday March 18, 2010 @10:19AM (#1201337)
I 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.

Re:Distributed Version Control is here to stay, baby by axod on Thursday March 18, 2010 @10:25AM (#1201363)
In 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 ;)