I'm not saying it's always a bad thing (especially in Java, where you're often forced to use overengineered APIs), but that you should pause and think whether you can do things in a simpler way.
- Tudor Bosman
Not always avoidable, either. Assuming you're talking Java, it's usually to compensate for constructors being bound to a concrete type, and/or as a pattern to create immutable instances. Call them Builders and they look less like over-engineering. : )
- DeWitt Clinton
Abstracting away the type you need to construct is already a step too far in most situations. If you need to choose between two types, there's nothing wrong with an if statement :) There are exceptions, of course -- deserialization is one.
- Tudor Bosman
Depends on who is supposed to be picking the concrete type, and if the caller should even know or care. For example, if I want to log something then it is probably better if I don't get to pick exactly how it is logged. I should just call something like getLogger() and the choice of the concrete representation should be delegated to the system as a whole. Fortunately, a good DI system (like Guice) can hide the Factory pattern rather well.
- DeWitt Clinton
I find DI / inversion of control to be even more annoying, as it's much harder to read through the code in an attempt to understand it; you need a higher level understanding of the architecture in order to navigate through, and you often don't have that luxury.
- Tudor Bosman
In an earlier life, I was a big advocate of the Avalon/Excalibur container-style of explicit DI/IoC programming. Those frameworks eventually took on a life of their own, got bloated, and imploded. Spring rose in parallel, and I probably would have gravitated to that, but then Bob created Guice and pretty much singlehandedly saved the universe. Well, Bob and Java 1.5 annotations.
- DeWitt Clinton
I would argue that, while DI may make it easier to keep track of tens of levels of indirection at once, it's better not to have them at all.
- Tudor Bosman
Sprinkling if statements around the code is like using C #ifdef, it makes rapid ports problematic. I've got code that runs, for example, on AppEngine, GWT, and Android, and using DI or Factories is invaluable for keeping this code portable. I've got 98% code reuse, and in a lot of cases, porting to a new platform simply requires writing a handful of classes and editing a Guice module file.
- Ray Cromwell
But why optimize for "porting to a new platform", which is rare compared to normal, day-to-day maintenance?
- Tudor Bosman
Depends on what kind of project you're working on. If you intend to build something that is easy to repurpose, it's different than building something that is a one-off application. For example, if you're building middleware for a game engine, you'd be crazy to not consider portability up front.
- Ray Cromwell
Again, in all of these architectural discussions, one must simply emphasize common sense and moderation. You want to be a Jeet Kune Do/MMA practitioner, and be flexible. Overemphasis on any kind of a priori rules is probably bad. You see this in 'over engineered' projects, but you also see it in underengineered ones too. While it's fun to bash on Java by picking on atrocious examples, there is polar opposite. Have you looked at the PHP code that forms the core of MediaWiki by any chance?
- Ray Cromwell
I haven't looked at MediaWiki, but trust me, I've looked at a lot of PHP code. It's not the language, it's the culture surrounding it; Java seems (for some reason or another) to have bred a culture of layers over layers over layers of indirection; PHP seems to have bred a culture of quick hacks. That's not to say you can't write overengineered code in PHP or ugly hacks in Java.
- Tudor Bosman
I like Python myself (both the language and the culture around it) -- keep things as simple as they can be, but no simpler. :)
- Tudor Bosman
And I definitely agree that pragmatism trumps paradigms. Keep in mind what you're trying to build, and get back on track if you find yourself writing something much more general than what you need. (Often, the abstractions that you conceive before you actually have a use case for generalizing your design will be wrong, and then you're spending a lot of time and headaches making your code fit an incorrect model, at least until you refactor).
- Tudor Bosman
+1 for not abstracting before you have plausible use-cases. I think that's one of the biggest failings of the "Java community", to the extent there really *is* such a monolithic beast. My biggest complaint about IoC "systems" (as opposed to simply using it as a pattern, where appropriate) is that they make your code more opaque to tools. I want to be able to make large-ish scale changes to my code in an automated fashion with ~100% probability of success.
- Joel Webber
I think this is one of the things that keeps me using typed languages for projects predicted to be large, because you can start off writing for the concrete, and extract abstract interfaces later through tool chains. Dynamic languages offer faster startup/turnaround, but aren't as easy to do 'after the fact' large scale refactoring. Of course, I'd prefer if people settled on a language...
more...
- Ray Cromwell
@Ray - if only Java had a formal macro syntax, you could do that.
- DeWitt Clinton
Where did factories come from? I assumed it was COM, which is a C-based interface and since C doesn't have constructors, they called their object creation functions class factories. Are they common in code other than Java?
- Gabe
@Gabe - It predates the GoF book, but that's where I first recall hearing it defined as the Abstract Factory pattern - http://www.amazon.com/Design-..., p87: "Provide an interface for creating families of related or dependent objects without specifying their concrete classes."
- DeWitt Clinton
This gripe has been circulating among the FriendFeed team for at least a year. Is there a particular Java library where overabstraction keeps biting you?
- Bruce Lewis
Bruce: I'm sure there's bias; not one thing in particular, just repeated instances where making changes to some external code is more difficult than it should be because everything is wrapped in way too many layers.
- Tudor Bosman
Is Lucene in that category? I think I'll eventually want to use it, but difficulties like that would push it further down the priority list.
- Bruce Lewis
I don't personally know about Lucene (the particular example that prompted me to write this was written in C++, not Java, for one); http://friendfeed.com/jim is the person to ask. As a general rule, it seems that projects move in the overabstraction / overgeneralization direction once they become owned by committees instead of small groups of developers.
- Tudor Bosman
(and while I don't want to point fingers at anyone, org.apache.* projects are generally a good example of this)
- Tudor Bosman
I suspect that designing / building by committee works more easily if the code has points of inflexion; it's hard to make a decision between two ways of doing something, so the committee's natural inclination is to not make a decision at all: abstract the mechanism away and let someone else make the choice.
- Tudor Bosman
"Lucene (SolrLucene) is now following your tweets on Twitter."
- Tudor Bosman
I was looking at some Java code recently, and after recursing through ~5 layers of methods with the word "Dispatch" in their names, I gave up in disgust.
- Ryan Anderson
Whenever I see a Java stack trace with over 100 lines I have to wonder how such a system can even work.
- Gabe
Agreed about org.apache.*, those libraries tend to be among the worse culprits. Their XML-RPC library (you know, the one that was supposed to be "simpler" than SOAP) has some truly offensive examples.
- Joel Webber
@Ryan: Yeah, there's also a tendency in some Java code to try and turn everything into some kind of event, when all you really want is to make a damned call.
- Joel Webber
@tudor, do you have an example of open-source project that is significantly complex and does not use DI or Factories? It's been my experience that system complexity and update difficulty usually correlate pretty well. DI and layers of abstraction help to de-couple smaller components in that large system, but in a sense, you can't really eliminate complexity, but just do your best to mitigate it's effects.
- no name
Bill: Sure :) The Linux kernel, any flavor of BSD, GIMP, Tornado...
- Tudor Bosman
Or you are moving crappy random construction stuff out of the way and off to its own land where it belongs.
- Hayes Haugen
I think that dependency injection and factories are primarily Java tools. Of course those tools may pop up in other languages under other names, but I've only seen them referenced in terms of Java.
- Gabe
Dependency is not language specific. It's part of the territory. Do we spread it all over the code? Or do we move it to someplace where it can be watched? I came to some of these patterns late in my career and if I stop myself from being dogmatic or reactionary to dogma I find there's a lot of good stuff there.
- Hayes Haugen
They say this skit cost $1.5 million, but Bugatti would eagerly loaned them a car for such publicity, which is probably what happened. If not, then the car still exists and is NBC property, in which case an NBC exec with a new ride is probably pretty happy with Conan right now.
- Kevin Fox
But the money for "Satisfaction" is just gone...
- Brian Johns
"...not necessarily funny, but crazy expensive"
- Bren
That was Wednesday, and topped out at 1.5 million bucks. Last night he brought out a Kentucky Derby winner racehorse dressed in a mink snuggie that was watching restricted NFL footage. Total price tag: 4.5 Million dollars! I seriously don't understand how he gets away with it, but it is hilarious.
- Josh Haley
I should totally find something to sell him that's both ridiculous and ridiculously expensive. I bet he buys everyone in the audience cars on the last day (today).
- Kevin Fox
Crap. I could'a sold him Fury.com for a cool million.
- Kevin Fox
We had ours with sour cream or Haleigh's homemade applesauce. I put out some cinnamon sugar and jelly too. Bill liked the cinnamon sugar! Happy Chanukah!!
- Marci Golub
Kenton, when my sour cream gets "chunky" ...as much as I like sour cream, I give in and toss that thing out! ;) O, you mean applesauce. Well, I'm going to find that out soon as I made some and I am going to make some latkes soon (after finals) so I can try them with applesauce on top. One thing I do like to add to my recipe is either finely chopped cooked chicken livers or whatever's left of the turkey giblet gravy along with some minced onions and that kinda makes me want to grab for the sour cream.
- Melanie Reed
@Kevin, I agree with Andrew and Anika, there is no "or" when talking sour cream & apple sauce for latkes. Regarding katchup, that would turn a otherwise tasty latke into a cheap diner hash brown.
- Ragani Harris
Actually Melanie, I meant the Latkas. Some people use shredded potatoes, some cubed, some mashed.
- Kenton
Kenton, Ah! even better! :) You have hit upon something I, too, care about in my latkes: texture. And I confess (though I have made the shredded) that I very much prefer to use mashed. This is how my father taught me.
- Melanie Reed
Melanie, I am not Jewish but my wife is. Having not grown up with Latkas, I don't have the same attachment to them as people who grew up with them. I tend to prefer the shredded ones though, they don't get mushy like the mashed ones can.
- Kenton
It's a theme that displays the current weather. I've never seen the snow version before. I don't think it's snowing outside but it would be awesome if it started.
- Kevin Fox
DO ANYBODY NO why I can't find that theme?
- Derrick
it's sugar boogers! woo hoo! call Tiger and have him bring some hookers over! *sings 'the cuervo gold. the fine columbian. makes tonight a wonderful thing...*
- Morgan
Rochelle - you and I seem to be on the same wavelength. Care to cyber dance? :-)
- Morgan
That theme has been wrong about the weather a lot recently.
- Shey
Pixels lose their pigmentation when they die, and they tend to accumulate at abrupt color transitions. Obviously, you need a new screen.
- DGentry