Slashdot Mirror


Applied Java Patterns

David Kennedy writes "Applied Java Patterns is an adequate Design Patterns reference for those who must have a Java version of the classic Gamma et al (aka Gang of Four, or GoF) Design Patterns, but it's only adequate. If C++ or Smalltalk hold little fear for you, stick with the original sources: 'This isn't the definitive Java Design Patterns book we're looking for -- move along.'" Read on for the rest of David's review. Applied Java Patterns author Stephen Stelting and Olav Maassen pages 561 publisher The Sun Microsystems Press / Prentice Hall rating B reviewer David Kennedy ISBN 0130935387 summary Adequate Java implementation of "Design Patterns"

Check your sources.

The title is published by Sun Microsystems Press, and the two authors are instructors for Sun Microsystems. As you would expect, this means you won't find any discussion of Java's darker corners; this isn't a particularly damning criticism in a book about Design Patterns, but it does mean that, for example, you won't see discussion on why double-checked locking implementations of the Singleton pattern don't work. (I might be reading more authorial/editorial bias into this than was intended of course -- I'm a bit paranoid. Too much caffeine, I expect.)

What's the book about?

From the blurb:

"[...] After briefly reviewing the fundamentals of design patterns, the authors describe how they can be applied effectively to the Java platform and present proven techniques for all types of patterns, from system architecture to single classes. Next, they present a pattern catalog."

In other words, what we get is an adequate intro, followed by about 275 pages of pattern catalog (mostly from Gamma et al, with a few threaded items from Doug Lea's Concurrent Programming in Java). This is what you're buying the book for, and on the whole it's decent material.

It continues:

"In addition, they identify patterns in the core Java APIs and present techniques for pattern use in distributed development. [this title] also features a section on pattern use in systems built with J2EE and Jini technology and coverage of the servlet, JSP, and EJB APIs."

Just about! This entire section is very much secondary to the catalog. The core Java APIs discussion is about 20 pages, the distributed section about a dozen, and the rest only 15! I've seen as much discussion of the pattern usage in the JDK in asides in, for example, Bloch's Effective Java (an excellent book by the way).

Of much more interest are the appendices. In reverse order -- Appendix B is a welcome bibliography. Appendix A is an odd decision on the part of the publisher. Appendix A is "Full Code Examples." Normally I'd think that this is a good thing, but appendix A is 224 pages, as compared to 273 for the whole pattern catalog. I feel it would have been better delivered on a CD. I realise this adds, what? $5?, to the cover cost, but the book would have been substantially thinner, with a knock-on effect on price.

A more important consideration is that this appendix distracts from the catalog, and adds little (other than working framing code) to the discussion of the patterns.

Target audience?

Experienced Java developers - but ones who haven't been exposed to Design Patterns before. I doubted that this was a huge audience, but then realised that Java is often used as a teaching language now, and I may be wrong in assuming most graduate programmers would be comfortable with the C++ and Smalltalk examples in Gamma et al. I could see this being a useful niche title for those mono-linguists starting out their professional careers.

What's good?

Overall, this isn't a bad title. It's decently written on the whole, has passable explanations of the main Patterns, and is presented clearly. It's just that there's nothing superb about it, and the problems (below) offset the overall competent tone. (It's a weird book to review: the majority of the content isn't original, and as a repackaging exercise I can't comment on, say, how brilliant it is to have a name of the Factory concept at long last.)

What's bad?

Too much for a simple port of GoF to Java. Let's start with the obvious flaws and then move onto "missed opportunities":

  • Diagrams
    Sorry, but there is no way that the UML diagrams in this title are acceptable in a professional publication. They're woeful, jagged-edged screen-capture affairs.

  • Appendix A
    As discussed above, the book has a schizophrenic feel with a LOT of material relegated to, or repeated in, Appendix A. A much more useful approach would have been to provide more material on the applicability of each pattern, or to flesh out some of the alternative implementations discussed.

  • The example application
    This title tries to do something laudable, but ill-thought out. What they do is start to discuss an example application (the Personal Information Manager) in the first pattern, and then carry that example through to all the other examples. This isn't a bad idea, but think about it. How do you use your pattern books? I flick through mine. I pull it off the shelf and read one pattern, or pass it to a colleague saying, "You want to change that to a [whatever]."

    When reading this title my flatmate was struggling with some OO design homework -- flicking to the pattern under discussion (Composite) starts us into another discussion of the PIM! This isn't what I want and puts me off the title immediately as I feel like I'm missing some background. The examples need to be more standalone. (To be fair, this only affects the blurb text, the code is independent.)

  • Oh editor, where art thou?
    While talking over the Composite pattern with my confused flat-mate, I noted that the Deliverable snippet actually gives the code for the ProjectItem again (page 163). Sadly, it's also wrong in Appendix A. On the full read-through this type of simple proof-reading error occurred too often.

  • Oh code reviewer, where art thou?
    Here's a hint for publishers. When writing a book for a professional audience which necessarily thrives on pedantry, try and have examples peer-reviewed first. Much of the code in Appendix A is not great. Now, I realise we're developing educational examples here, and we want to keep the focus on the pattern, but the impression given by the full code examples isn't good. Continuing the above example, the error handling of the Composite pattern is feeble. (Static ints defined in an exception class and then if-elsed on the main class to get printable versions? Yeugh.) I'm being picky here, but this is a book about better design, and people-in-glass-houses, etc. In addition, the core concepts aren't original, and so it's this (slightly sub-standard) example code which gives the added value, or rather, should.

  • Fly-leaves
    You know what I love most about Design Patterns? The fly-leaves -- to find a pattern I open the cover, skim the list and turn to appropriate page. Brilliant for a reference title. Applied Java Patterns misses a simple trick here. A hardcover edition would also be nice. As would those nice GoF ribbons. (My apologies if there is a softcover version of the GoF book featuring neither fly-leaves nor ribbons and I've been comparing apples to oranges.)

So, overall the impression that this book gave me was of an opportunity missed. Too many little details wrong, or lacking when compared to the GoF title.

Alternate titles?

There is another Java Design Patterns title: Addison-Wesley's Java Design Patterns -- A Tutorial, by James W. Cooper (2000, ISBN 0-201-48539-7). I can't say I recommend this title either -- it's much thinner, comes with a CD, takes a more tutorial tone, but suffers many of the same flaws (sloppy editing, lack of 'flickability,' chunks of dodgy code and some bloody examples).

Sorry, but the undisputed king still reigns -- the original GoF book is still superior in almost all respects. Only a lack of recent examples, and the fact that the examples are only in C++ and Smalltalk can be called criticisms. (Details: Design Patterns: Elements of Re-usable Object-Oriented Software, by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides. Addison-Wesley, 1995, ISBN 0-201-63361-2)

If you feel that the GoF book is a bit, well, academic and intimidating for your taste then might I suggest a side order of John Vlissides's companion volume, Pattern Hatching: Design Patterns Applied (1998, ISBN 0-201-43293-5). This slim volume talks about applying patterns -- where, how, etc -- in a clear way, using a tutorial approach. The example system developed helped me "get" some of the concepts first time through. The examples are in C++.

I don't want to give the idea that there are no new Design Pattern books worth reading - for example, for J2EE work I think highly of Core J2EE Patterns by Deepak Alur, John Crupi, and Dan Malks (2001, Prentice-Hall, ISBN 0-13-066586-X).

So, to sum up, this isn't a bad book, but it does feel like a pale imitation of the GoF title, and offers very little to anyone who develops in Java but has access to the GoF book. Any publishers or wannabe authors listening? Seems like now might be a good time to think about issuing The Design Patterns Java Companion, along the lines of the existing Smalltalk title. (Hmm, maybe I should take my own advice ...)

You can purchase Applied Java Patterns from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

114 comments

  1. How does it compare with Bruce Eckel's Book? by sisukapalli1 · · Score: 3, Informative

    Bruce Eckel has a book

    Thinking In Patterns

    How does this book compare to that?

    S

    1. Re:How does it compare with Bruce Eckel's Book? by Anonymous Coward · · Score: 3, Informative

      I've read most of Bruce Eckel's draft of Thinking in Patterns. It's clearly still a work in progress. Regardless, the finished work should be well worthwhile. Thinking in Java is one of the most well-crafted programming books I've read, and Thinking in Patterns is essentially a follow-up that takes the reader beyond language syntax and deeper into quality programming. Bruce is the real deal. Plus, he has a sort of open source approach to authorship, with freely downloadable versions of his works in progress and even his finished books. This naturally results in tons of peer review and feedback, delivering much higher quality writing and code than I've seen elsewhere.

  2. grr by K. · · Score: 0, Troll

    There should be a swear jar for people who say "this isn't the we're looking for. Move along." Either that or it should be legal to hit them in the face.

    Losers. There's no all-pervading cultural reference that controls *my* destiny.

    --
    -- Proud descendant of semi-nomadic cattle-herders.
    1. Re:grr by T-Kir · · Score: 1, Offtopic

      [officer_barbrady] All right people, there's nothing to see here, Move Along. [/officer_barbrady]

      --
      Are you local? There's nothing for you here!
  3. discussion on book by Hall+and+Oates · · Score: 3, Informative
    Hereis a link to the archive of a discussion about this book they had in April this year at Java.Sun.com.
    Very Interesting.

  4. Design Patterns by Benjim · · Score: 4, Insightful

    The original "Design Patterns - Elements of Reusable Object Oriented Software" is absolutely definitely the best book to describe design patterns. Ok so it has some C++ code, but if you are a Java coder worth your salt, you should be able to follow it to some extent.

    The main point is that design patterns are supposed to be language neutral! Most of the "Design Patterns in XXX" books pretty much break the idea, as they tie a pattern in to an implementation. The pattern of course is a collection of; pattern name, problem, solution, consequences, and not just some code.

    My point is that some of these books are great, and some are poor. But the original really is the only one to give you the real feeling of the patterns philosophy.

    1. Re:Design Patterns by SirSlud · · Score: 3, Insightful

      Doesn't "Design Patterns" have smalltalk in it too?

      I'm a C++ guy, but I always was able to look at code in languages I hadn't programmed in as pseudocode .. I mean, you can usually tell in general whats going on. And since Design Patterns are about generalizing solutions into clearly defined patterns, I felt it was pretty appropriate that you shouldn't need to be have to compile the language in your head for examples of design pattern ...

      --
      "Old man yells at systemd"
    2. Re:Design Patterns by Ed+Avis · · Score: 1

      I looked at the original GoF book and gave up on it as almost unreadable. It seemed to have about half a page of mumbling followed by two pages of dry C++ code, repeat for each pattern. I just couldn't be bothered, there are so many more worthwhile things to read for the same effort. Like real code, for a start. (At least I think it was the original GoF book, it might have been some lame cash-in but I don't think so.)

      Maybe it's just a prejudice I have against long code samples in books.

      --
      -- Ed Avis ed@membled.com
  5. Eamples in C++ aren't really criticism by matjac · · Score: 2, Insightful
    Onw would think that a good Java programmer would have at least a foundation in basic C++. Thus the examples should be easy for the Java programmer to understand. It was my experience that as a Java programmer that the GoF book was invaluable, no more so or less so than now when I do all C++ work.

    It seems that to produce a design patterns book that is language centric misses the point. They are patterns, they should be able to be implemented in any language, not just the one of the authors choosing.

    1. Re:Eamples in C++ aren't really criticism by Anonymous Coward · · Score: 0

      I agree in principle, but there is a value in language centric books. Certain languages have features that can be used in differing ways to implement patterns.

    2. Re:Eamples in C++ aren't really criticism by 12dec0de · · Score: 1
      Well, currently mono-language education seems to be the order of the day. There are Java curriculums and there will be .NET curriculums in a short while.

      And when you have no concept of separation between the syntax of a language and the semantics of a piece of code, you need a book in you language. Look on the bright side: More opportunity to make a buck selling another book in the language of the day. A .NET version of TAoCP anyone?

      Me, this just gives another opportunity to feel superior, reading Gamma et.al in the original and being able to write Software in about 20 different languages. ;-)

  6. Re:What's a good programming language in general? by Anonymous Coward · · Score: 0

    Have you considered Java?

  7. Yes, there is. It is called JAVA. (nt) by croanon · · Score: 0, Offtopic

    trg

    --
    Dear Bill, do you have a .net tatoo on your ass for marketing?
  8. I acutally like this book by Anonymous Coward · · Score: 1

    I like the way it is set up. that it is clear and it has a consistant feel hrough out the entire book. It's far superrior for reference to the GoF.

    It's an easier read for most people. And it covers more patterns. Gives more code examples. And uses one language which adds conistancy.

    I think this book was very well done and I would much prefer reading it then the GoF.

  9. "gang of four": apropriate? by autopr0n · · Score: 1, Offtopic

    Hrm, doesn't anyone think that these people calling themselves the "gang of four" is a bit, like, wrong? I mean, the original "gang of four", Mao's henchmen in the cultural revolution, were terrible people. I mean, it's like if some people wrote a book on 4th generation programming languages and called themselves the "fourth Reich" or something. Or created a foundation for OO design research and called themselves "Al Qaeda". ('al qaeda' = 'the foundation' in Arabic Eeh, whatever.

    --
    autopr0n is like, down and stuff.
  10. Re:What's a good programming language in general? by SirSlud · · Score: 2

    You'll probably elicit more concensus if you ask "Which religion is the right one?"

    I've had success in C++. Others have in Java. Every lang has its strength and weaknesses; when you use them often has more to do with what platforms and technologies and APIs you'll be hooking into, and whats been used in the past when you join companies and projects. There's no true abolute ..

    --
    "Old man yells at systemd"
  11. Re:Yawn by FortKnox · · Score: 0, Offtopic

    And my parents said I'd never amount to anything. Actually, I have nothing to say in this article :-P

    --
    Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
  12. Re:What's a good programming language in general? by NightWhistler · · Score: 2, Informative

    My experience is that Java is great for learning to program in OO, because it adheres more cleanly to modern ideas about OO-programming.
    Implementing an interface for example is a different thing in Java from extending a class, where in C++ both things are done with inheritance. This makes for a more clean seperation of ideas.
    Also, when you look at the Java API, patterns are virtually everywhere (look at the Java Collection Framework to see what I mean).

    That being said I would to add that though Java is a great choice for teaching, I'm still not very much convinced about it's merits in normal software development, especially when it comes to building GUI applications...

    --
    PageTurner Reader: open-source e-reader for Android with cloudsync. http://pageturner-reader.org
  13. Re:What's a good programming language in general? by MagPulse · · Score: 2, Insightful

    Two things. One, programming takes a lot of time and work, and you will be well rewarded for the time you put in to learning C++.

    Two, no one uses every feature of C++. I don't think any compiler even now supports the full ANSI C++ standard. I was just reading a CUJ article about separate template compilation and how it's just now being implemented, since it's doesn't really work as many people thought it would. People still do great things with C++ though. The C++ philosophy is to enable you to do what you want; if Bjarne sees something that might improve 5% of programs with a 5% speed hit on the other 95%, he'll add it (I'm thinking of multiple inheritence here, and don't quote my numbers). So don't worry about the complexity of C++, just use what you like.

  14. Re:CYBORG_MONKEY IS A COCKGOBBLER by Anonymous Coward · · Score: 0

    I'm intrigued by your ideas and would like to subscribe to your newsletter.

  15. Oh dear classic troll attempt... by MosesJones · · Score: 2

    But unfortunately a bit too obvious.

    The best programming language is of course the most obscure, that way you keep your job :-)

    --
    An Eye for an Eye will make the whole world blind - Gandhi
  16. Re:"gang of four": apropriate? by jfsather · · Score: 1

    Yeah, I think that is why the 80's New Wave band Gang of Four ("I Love A Man in Uniform") failed as well--they were too hurt by the comparison you mentioned. I'd have to wait for the VH1 Behind The Music to find out for sure. Anyway, they just happened to pop onto Spinner when I read your comment. Strange.

  17. Re:"gang of four": apropriate? by batkiwi · · Score: 2

    THEY didn't coin the name, other people did, since it takes too long to say all 4 author's names. It's common to refer to a programming book simply by it's author's name, so "gang of four" stuck. Blame whomever first said it.

    ps, love your site

  18. Help? by billbaggins · · Score: 2, Interesting

    Pardon my ignorance, but I haven't encountered this concept of "Design Patterns" (capitalized) before, and I wonder if one of you wonderful helpful egalitarian types (I know there have to be at least a couple on /.) would actually be willing to explain it for me so that I don't have to try to work it out from hints & snatches in this discussion. Please?

    --
    "The best argument against democracy is a five minute chat with the average voter."
    --Winston Churchill
    1. Re:Help? by Lazar+Dobrescu · · Score: 0

      Design Patterns are good ideas that experienced programmers have developed to solve different classes of problems using object oriented programmation. This would allow people to profit from work of more experienced people, and thus greatly reduce the time needed to solve a given programmation problem. The original idea of the GoF was to publish a collection of the most useful patterns and give a name to each one of them so people could then speak about them in a conversation and be understood.

    2. Re:Help? by BitwizeGHC · · Score: 1

      I will catch flamage for this not-entirely-flattering description, but what the hell. I got karma to burn.

      Near as I can tell, design patterns are to programming what paint-by-numbers is to art. I haven't met a gifted programmer who made extensive use of them, but they seem to be a sort of helpful template for average coders of the sort hired in legion strength for "enterprise" projects in Java and the like.

      --
      N4st0r, trixx0r h0bb1tz0rz! Th3y st0l3 0ur pr3c10uzz!
    3. Re:Help? by XMunkki · · Score: 3, Informative

      Design patterns describe some common code design problems, give a solution to it and analyzes the problem and the solution. So in short when you are facing a structural design problem (like "how should all my GUI widgets interact in the GUI toolkit I am writing"), you might wanna check these out.

      Usually programmers "use these" without even knowing them (after all, they are common solutions to common problems).

    4. Re:Help? by Anonymous Coward · · Score: 0

      Oh my god...

      "gifted programmers" use design patterns daily... any well designed app is rife with design patterns...

      design patterns are common solutions to common problems... reading about these patterns will help any programmer find ways they can make their code more readable, reusable and maintainable... not just by them, but by other developers...

      It takes some amount of experience and ability to even understand and see the goodness of design patterns... which is clearly your problem.

    5. Re:Help? by Dr.+Awktagon · · Score: 4, Informative

      Here is a FAQ.

      Patterns are named solutions to problems, which resolve constraints in a a given context. They aren't rigid (like, say, a template), they are abstractions of commonly occuring problems and solutions that occur in programming. For instance, "one object needs to do something to another group of objects" might be a problem, and the Visitor pattern might help you find the solution. The code you use to implement the pattern might be radically different than the code someone else uses, but underneath the pattern is the same.

      They come from Christopher Alexander's work in architecture, where he saw the same recurring patterns in architecture and felt that they arose from deeper truths about people and societies. An example of Alexander's architectural patterns: "Intimacy Gradient", which is a pattern that describes how the front of a home is less personal and intimate than the back of a home. For instance you might leave your stuff laying out in a back room, but you keep the front room neat for guests.

      Very interesting from a philosophical point of view as well, and helps you to better understand why some programs/houses/objects are pleasant to work with, and others are a chore.

    6. Re:Help? by cmh7r · · Score: 4, Insightful

      Don't mean for this to be the flame you expected, I'd just like to give the other side of the argument.

      > Near as I can tell, design patterns are to
      > programming what paint-by-numbers is to art.

      I can see how this comparison would occur to someone with little experience using Design Patterns. I think a better explanation is this:

      Most anyone can, given a programming problem, come up with a solution that works. If you're working on a quick and dirty piece of code for one-time use, then using patterns might not be the answer. However, its very common that people want to add new features... support new file formats, etc. Most quick and dirty designs, even by good programmers start looking really bad when new features are added. If the system grows significantly larger than the original developer expected then the design becomes completely unwieldy and they start to see how it should have been designed in the first place. The next time that developer has to design a similiar piece of software they wont make the same mistakes.

      This is where Design Patterns come in. A designer/programmer well versed in these patterns can see the end result of that first scenario before it happens. Learning design patterns helps teach good design faster. The solution to each common design problem is encapsulated in a well documented pattern.

      > I haven't met a gifted programmer who made
      > extensive use of them,

      Wow, I've met alot of people who think they are gifted programmers and write really badly designed code that works (at first) who don't use design patterns.

      On the other hand, if you judge code and design not by how much of a hack it is, but by how elegant it is, then Design patterns can make a huge difference. There is nothing beautiful about trying to cram a square peg in a round hole, even when it works.

      So, instead of "paint-by-numbers", I see design patterns as a "magic eight ball" that can tell you what problems your design will have before you even start programming. :)

      > but they seem to be a sort of helpful template
      > for average coders of the sort hired in legion
      > strength for "enterprise" projects in Java and
      > the like.

      While I am a fairly technical c++ programmer by trade, there is no reason to belittle java or "enterprise" programmers. There are some HUGE projects out there that simply cannot by done right by a few people hacking away. And I feel sorry for them when it becomes time for V2.

    7. Re:Help? by broody · · Score: 1

      The original idea of the GoF was to publish a collection of the most useful patterns and give a name to each one of them so people could then speak about them in a conversation and be understood.

      To my mind this is the major win for DP. The abillity to describe common approaches between a diverse group of programmers and systems in a way which allows them to learn, relate, and discuss approaches decoupled from implamentation in their pet language.

      --
      ~~ What's stopping you?
  19. Re:"gang of four": apropriate? by Pinball+Wizard · · Score: 1
    I think you are right - anyone who knows a little bit of history is going to picture Mao's gang of four right away. Its like a CEO refering to himself as Caesar or referring to your workplace as the gulag.

    Since /.ers aren't known to be history buffs, you're likely to to have some nazi moderator mod you down. Oops.

    --

    No, Thursday's out. How about never - is never good for you?

  20. Java Companion (Free Download) by gabbarsingh · · Score: 5, Informative

    Java Companion is a free (PDF) download of a good treatment on the subject. As a practicising java developer there's no substitute for the GoF Design Patterns especially the discussion on each pattern. But sometimes it's hard to gather the full meaning because a C++ demonstration is used replete with multiple inheritance or even just inheritance that may be realised in Java as composition. With Java, one requires little bit help, some lateral thinking to come up with an equivalent. The download has helped me immensely.

    1. Re:Java Companion (Free Download) by krony · · Score: 1
      A newer version of the same document can also be found in book form at Amazon.

      It is nearly the same document, only with a few added items, and both are written by James Cooper. It is a very good companion to the GoF book!

    2. Re:Java Companion (Free Download) by Fujisawa+Sensei · · Score: 2, Informative

      I have this guy's book. "Java Design Patterns: A Tutorial" It is the worst Patterns book I have ever read. If you don't believe me just check the reviews at amazon. I've you're looking for thye definative Java Patterns, I suggest looking at another author. Mark Grand also sucks. So far the Stelting-Maasen book is the best I've seen, after the GoF Book.

      --
      If someone is passing you on the right, you are an asshole for driving in the wrong lane.
  21. Re:"gang of four": apropriate? by red_dragon · · Score: 2

    To expand on batkiwi's comment above, here's the Gang of Four entry in the Jargon File:

    Gang of Four n.

    (also abbreviated `GOF') [prob. a play on the `Gang Of Four' who briefly ran Communist China after the death of Mao] Describes either the authors or the book "Design Patterns: Elements of Reusable Object-Oriented Software" published in 1995 by Addison-Wesley (ISBN 0-201-63361-2). The authors forming the Gang Of Four are Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides. They are also sometimes referred to as `Gamma et. al.' The authors state at http://www.hillside.net/patterns/DPBook/GOF.html "Why are we ... called this? Who knows. Somehow the name just stuck." The term is also used to describe any of the design patterns that are used in the book, referring to the patterns within it as `Gang Of Four Patterns.'

    --
    In Soviet Russia, Jesus asks: "What Would You Do?"
  22. EJB's by FortKnox · · Score: 1

    Design patterns with new technology (like EJBs and servlets) are trickier to envision, that is why books like these are valuable.

    --
    Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
  23. Book Review Ratings by shanelenagh · · Score: 1

    It would be nice if the book reviewers gave the scale that they rated books on (or were required to use a standard rating system). It is hard to compare reviews when one reviewer uses A - F, the next uses 1 - 5, and the next uses 1 - 10.

  24. Subtle irony warning... by pongo000 · · Score: 2


    Applied Java Patterns is an adequate Design Patterns reference for those who must have a Java version of the classic Gamma et al (aka Gang of Four, or GoF) Design Patterns

    If you feel you need the Java version of the original GoF (gang of four) book, I have a recommendation: Skip the book, and buy Eckel's "Thinking in Java," because you have some catching up to do if you can't translate the original design patterns into Java (or any other OO language, for that matter).

    Too many developers use design patterns as either (1) a crutch due to poor design methodology or (2) sparkle and glitter in order to impress the boss with an otherwise sound design methodology. Learn the language first, work with the language, and write some software before worrying about design patterns. The original GoF book will work with any OO language, but you will have to supply the necessary skills to get the job done. Another design pattern book isn't going to help you.

  25. Smalltalk version of Patterns book, my own project by MarkWatson · · Score: 2, Interesting
    Even though I usually use Java (augmented with Common LISP, Scheme, Python, C++), I bought the Smalltalk version of the Patterns book - it is excellent.

    I have no problems applying the Smalltalk version to Java, etc.

    Really, I think that it is best to be language agnostic: happily use any language someone pays you to use.

    my own project:I like to write (a lot!) and I am just starting a new Free Web Book project that I not-so-humbly call "The Software Design Book" that uses what I call "light weight" UML (i.e., only use case, class, and sequence diagrams) and lots of my own philosophy. Anyway, an early version will join my other two free web books on my site in a week or two.

    -Mark

  26. Patterns are not language neutral by PinglePongle · · Score: 2

    You could not implement most of the GoF patterns in a language that doesn't support the core OO concepts ("Design Patterns for assembler" anyone ?).

    Or rather, I would suggest that most if not all languages have un-documented patterns waiting to be published - but what works well in a java environment doesn't work in assembler and vice versa.

    "A pattern is an idea that has been useful in one practical context and will probably be useful in others". (martin fowler).

    Of course there are other definitions, but most include the word "context". The language in which you are approaching the problem is definintely part of that "context" - so I think there is definitely a place for an explanation of how to implement well-known patterns in a specific language.

    Having said that, I think there's a trend towards "rip-off" pattern books which add too little value - I recently read "J2EE design patterns applied", which allegedly expands on the Core j2ee patterns book. It's not very good...

    --
    It's all very well in practice, but it will never work in theory.
    1. Re:Patterns are not language neutral by IIRCAFAIKIANAL · · Score: 2

      You could not implement most of the GoF patterns in a language that doesn't support the core OO concepts ("Design Patterns for assembler" anyone ?).

      I have a copy of Visual Basic Design Patterns. They actually manage to pull them off in VB6, though it gets a bit kludgey at times. VB.net isn't a problem though.

      For the record, the book sucks.

      --
      Robots are everywhere, and they eat old people's medicine for fuel.
  27. why i don't give a rat's ass about design patterns by johnfoobar · · Score: 3, Insightful
    Design Patterns should be put in perspective. There are not the be all and end all that some Java/OO zealots make them out to be.

    Propoganda
    Design Patterns in Dynamic Programming
    "Design Patterns" Aren't (google cache link)

  28. Singleton Pattern / Double-check Locking by Elias+Ross · · Score: 1
    I guess I am alone in thinking that for the Singleton pattern, this sort of coding is sufficient:

    public class Something {
    private static Something s = new Something();
    private Something() {}
    public Something getInstance() { return s; }
    }

    You see in Java, unlike C++, we have a classloader that manages the loading (and thus creation) of a single instance of a class. If you are calling Something.getInstance, presumably the class-loader will then load the Something class at that time, instantiate a sole instance, and return it to you, without having to worry about the details of thread-safety and creating multiple instances.

    Anyway, using the Singleton pattern is not entirely "good programming practice", as it is often used to create "Global Variables" in disguise.

    1. Re:Singleton Pattern / Double-check Locking by Anonymous Coward · · Score: 0

      or this:

      public class Singleton {
      public final static Singleton INSTANCE = new Singleton();
      private Singleton() {}
      }

      reference: http://www.javaworld.com/javaworld/javaqa/2002-04/ 01-qa-0412-doublelock.html

      (no, you're not alone. sorry.)

    2. Re:Singleton Pattern / Double-check Locking by 2short · · Score: 2, Interesting

      Not to start a language war, but in C++ I say

      Singleton foo;

      and I'm done with it. Doesn't even matter if Something was originally designed for use as a singleton. (Yes, someone had to write the singleton template, but they only had to do it once, and in any case, it wasn't me)

    3. Re:Singleton Pattern / Double-check Locking by 2short · · Score: 1

      How many times can I forget preview?

      Singleton<Something> foo;

    4. Re:Singleton Pattern / Double-check Locking by Anonymous Coward · · Score: 0

      You see in Java, unlike C++, we have a classloader that manages the loading (and thus creation) of a single instance of a class

      Unless of course you have multiple class loaders on the same JVM which would yield multiple 'Singletons'.

    5. Re:Singleton Pattern / Double-check Locking by CoreyG · · Score: 2

      Double checked locking does not work in Java. Javaworld is fed up with people posing new solutions to the problem. See these articles

      They specifically cover your solution in that article. Hint: yours only works if there are no Object references or more than one primitive member in the class.

    6. Re:Singleton Pattern / Double-check Locking by Anonymous Coward · · Score: 0

      How do you guarantee that there is only one instance of Something?
      Make the constructor private and grant friendship to the Singleton pattern?

    7. Re:Singleton Pattern / Double-check Locking by 2short · · Score: 1

      Sounds good to me.
      Actually the way I've typically used this is in a module where the header only exposes static functions. The implementaion of these functions then call members of the singleton. This lets the object in question do what ever it needs to (one-time initialization, internal cacheing) without the caller having to even know it exists.

  29. Obligatory Contrarian View on Patterns by Tablizer · · Score: 4, Insightful

    GOF-style patterns get carried away with "using code to model your nouns". I find using relational techniques and tables superior because they do not depend on the physical structure of code (beyond relational formulas), but rather use as-needed "virtual patterns". It is like the differences between doing calculus by counting rectangle approximations under the curve and diriving dirivatives via formula transformation. GOF is a bunch of rectangles hand-weaved together in my viewpoint; a bunch of classes hand-indexed together the old-fashioned way. I would rather let the database engine and compact formulas do most of the weaving for me.

    In procedural/relational design, the programming code is less tied to the "noun-model". Thus if you want to change the noun model or have multiple simultaneous noun models in play, the code does not need large-scale overhauls in its structure. This makes p/r more change-friendly IMO, and most software expenses are on maintenance, not creation.

    If you tie your code tightly to noun models, like GOF and OOP tend to do, then your code needs more rework if you change your noun model/relations. Pretty simple.

    Paul Graham has made similar comments about patterns, although he uses relational's cousin: functional programming and set theory, to do similar "virtualizing". (In essence, he uses relational-like formulas in LISP.)

    More reading on my opinion of GOF-style patterns:

    http://geocities.com/tablizer/prpats.htm

    http://geocities.com/tablizer/whypr.htm

    What we have in this slashdot story is TWO overhyped techologies: Java and GOF-like patterns. A 2-for-1 bargain. PHB's and fad chasers will love it.

    1. Re:Obligatory Contrarian View on Patterns by Anonymous Coward · · Score: 0

      The problem with this, as any OOP-fluent programmer could tell you, is that procedural languages have a high degree of coupling; ie, a small change to one module (function, procedure, whatever) is likely to ripple through many other modules. Relational data storage does not alleviate this problem. If you have to change the code much (either for bug fixes or to add functionality), then you have a nightmare on your hands. This is the reason that most developers moved to the OOP languages years ago.

    2. Re:Obligatory Contrarian View on Patterns by Tablizer · · Score: 2

      The problem with this, as any OOP-fluent programmer could tell you, is that procedural languages have a high degree of coupling; ie, a small change to one module (function, procedure, whatever) is likely to ripple through many other modules. Relational data storage does not alleviate this problem. If you have to change the code much (either for bug fixes or to add functionality), then you have a nightmare on your hands. This is the reason that most developers moved to the OOP languages years ago.

      I have heard this claimed a jillion times, but have never seen an actual side-by-side code example, at least not from the biz domain.

      Past attempts have failed mostly because:

      1. They fail to consider the down-sides of their approach. IOW, they assume a certain change pattern that does not fit reality well, at least not as I perceive. For example, they will show how easy it is to add a "new subtype" in OOP. However, they rarely consider adding a new operation (to existing subtypes), or the fact that subtyping may be a bad model to begin with. Subtyping assumes a mutual exclusiveness for example. Polymorphism is heavily *tied* to the assumption of mutual exclusiveness. That is "coupling" in itself. I often (correctly) assume that features may drift orthogonal from each other over time, not M.E.

      2. They present lame procedural/relational code that can be fixed. Some OO fans don't "get" good p/r IMO. They have never been taught well.

    3. Re:Obligatory Contrarian View on Patterns by Jerf · · Score: 2

      It is intriguing to see such a criticism of the patterns, because to me the great personal breakthrough was seeing how the patterns enabled one to "objectify" a verb. As I see it, many of the patterns seem to do this: Iterator, command, strategy, and I don't have the book on hand but several others as well.

      Each of these bundle a verb: The iterator bundles "traversing the data structure", the command bundles some piece of functionality, the strategy does the same thing but inverted relative to the command.

      To me, the noun-like patterns were interesting and sometime useful (I always though "flyweight" was cool), but I've gotten a lot more milage out of the verb-like patterns.

      I'll read your critiques here in a bit, but I would be curious about any response or reaction you'd have to my thoughts that many of the patterns are verb patterns. (Feel free to privately email if you don't want to do this on Slashdot.)

    4. Re:Obligatory Contrarian View on Patterns by Tablizer · · Score: 2

      I'll read your critiques here in a bit, but I would be curious about any response or reaction you'd have to my thoughts that many of the patterns are verb patterns. (Feel free to privately email if you don't want to do this on Slashdot.)

      Most of the verb-centric patterns seem to be reinventing the database in my observation. For example, "iterator" may *duplicate* the interface and implementation of iteration for every class that needs it. In the p/r world, you don't have to reimpliment it over and over again. Plus, iterator lacks expression-based filtering, joins, sorts, indexing, etc. without yet more hand-coding and interface expansion.

      Every participant class ends up carrying around the "baggage" to be able to do otherwise common, database-like operations on it. Sure, there are ways to factor some of this to a central spot, but it tends to have other side-effects, and your central package is a hand-built half-ess database anyhow. You might as well byte the bullet and do it right.

      We would probably have to visit (pun) a specific example together. You mentioned taking this to email.

  30. Why Gang of Four is appropriate by Latent+Heat · · Score: 1
    Design Patterns got referenced so much, and Gamma, Helm, Johnson and Vlissides was such a mouthful that some wag probably called them the "Gang of Four" on account of having the same notoriety in the field of OO as the original Gang of Four had in post-Mao China.

    The only way I would find this offensive if it somehow demeaned any of the authors, which it doesn't, and it is a catchy title, and while Gamma et al are famous, they are also notorious (where is Tablizer when we need him?), so the name is fitting.

  31. Can you recommend . . . by Latent+Heat · · Score: 1

    Can you recommend a language/relational dB combination under Windows that allows you to do what you advocate, including using relational tables to dispatch code?

    1. Re:Can you recommend . . . by Tablizer · · Score: 2

      (* Can you recommend a language/relational dB combination under Windows that allows you to do what you advocate, including using relational tables to dispatch code? *)

      I said *nothing* about dispatching code here from tables. In practice, it is not needed/helpful that often. The relationship between rows and behavior often does not stay one-to-one over the long-run. Thus, there is little or no benefit to tying them one-to-one most of the time.

      However, just about *any* dynamically-typed or type-free language could do such. If you can hook say Python or Perl or LISP to a RDBMS, then you can do it. Heck, even MS-Access has an Eval() function IIRC if you want/have-to use that P.O.S.

  32. Re:Smalltalk version of Patterns book, my own proj by Anonymous Coward · · Score: 0

    Agreed. That book can be found at http://www.amazon.com/exec/obidos/tg/detail/-/0201 184621

  33. You forgot to make getInstance() static... by LouisvilleDebugger · · Score: 1

    public class Something
    {
    private static Something s = new Something();
    private Something() {}
    public static Something getInstance() { return s; }
    }

    1. Re:You forgot to make getInstance() static... by snatchitup · · Score: 2

      Mod parent up, Mod grandparent down.

  34. this book is just a poorly written rehash by a7244270 · · Score: 1

    I looked at this book, and decided not to buy it because it didn't really offer that much other than implementations of the GoF patterns in Java, and to be honest, they were basically crap. I'd say that this book might actually do more harm than good if it were being used in a teaching environment.

    I noticed that there are some comments criticizing the fact that the GoF book has examples in only C++ or smalltalk, which is perhaps what promted the authors to produce this book.

    The thing is though, the GoF text is trying to express some pretty fundamental programming concepts, that can be readily implemented in ANY language - granted it helps if your choice language supports inheritance/polymorphism.

    The bottom line is that C++ is basically similar to smalltalk which is basically similar to Java which is basically similar to C#.

    Any programmer worth his salt should be able to understand what the examples in the GoF book are trying to get across if he knows even one of those languages. They're not _that_ different. And besides, it might help if you have to look at the code a little harder.

    Now if the examples were written in some language that was an absolutely radical departure from your standard OO language, say Lisp for example, then I could understand some complaints, but seriously, the language is not that big of a deal.

    Just for fun, the language whiners should check out Donald Knuth's "The Art of Computer Programming" series - he defined his own language for those examples. His language is kind of like assembly, but it kind of isn't. Doesn't match any language today, but I bet you won't be able to find anyone who will say that those books are not an absolute treasure trove of information, despite the implementation language.

  35. really interesting by cmh7r · · Score: 1

    I found the ideas on your site to be really interesting... Obviously, you are taking exception to the idea of OOP and not patterns. I certainly see the value you in your approach. You appear correct that in some circumstances, a change in overall design could be realized just as quickly using a relational model (in some cases.) (I'm sure you would argue more quickly, but I am not convinced of that)

    Where it appears to fall short is in the area of reuse. Your code is written extremely specifically for the task at hand and does not seem like it could be moved over to a new domain. (I haven't had a chance to browse all of your articles so maybe you address this.)

    The functional programming models you talk about tend to be more similiar to the OOP approach (heavy use of polymorphism) only using far less "nouns".

    Anyways, thanks for the link to your site which seems to be a really interesting resource.

    1. Re:really interesting by Tablizer · · Score: 2

      Where it appears to fall short is in the area of reuse. Your code is written extremely specifically for the task at hand and does not seem like it could be moved over to a new domain.

      I would have to see a specific example of a something in OOP that is better at being reused than a procedural/relational approach.

      Note that "reuse" seems to be dropping off the list of "standard OO benefits" in OO circles. I have heard quite a few OO fans say, "reuse is not where it's at". And, I have cited some Wiki discussion groups and a Dr. Dobbs article that lean this way also. (Just follow the "myths" link on my website to "reuse".)

      I am not sure exactly what the benefits of OOP are *supposed* to be. Some OO fans lean toward it being better to mentally grok, while others insist that it makes software more "change-friendly" (but not necessarily easier). Of course, I disagree with both of those claims.

      Consistency of both design methodology and benefit reasons in the OO world is sorely lacking.

      I personally think OOP is popular (among the S.E. elite) due to these two factors:

      1. Some people just seem to think better under OOP due to their *particular* brain/phsycology.

      2. Written OO material tends to overemphasize certain change patterns that OO is particular good at, at the expense of change patterns that OOP has a tougher time with. IOW, they present a non-representative (frequency-wise) list of change problems, and then conveniently show OOP "fixing" them.

    2. Re:really interesting by cmh7r · · Score: 1

      > I would have to see a specific example of a
      > something in OOP that is better at being reused
      > than a procedural/relational approach.

      Although I'm not primarily a java programmer, a nice example that jumps out at me would be Java applets. You can simply inherit the majority of functionality that you do not need to change from code provided in the framework and simply provide your own implementation changes where appropriate. (I was going to use MFC as an example, but it sucks so I might have been disproving my own point). This amounts to creating an entirely new "noun" with fairly complex functionality in very few lines of code. Perhaps the cost here is knowing what does go one behind the scenes.

      Certainly the same effect could be achieved by using OO-like practices in a proceedural (or possibly relational?) context, but it would not be nearly as elegant. I believe this is the case with the majority of OOP benefits.

      Furthermore, designing using very specific "nouns" has the side affect of predisposing your code to reuse. When you go to program something else and need that same "noun" you already have it. I have found that proceedural programmers tend not design their software in a way that allows it to be immediately applicable to other tasks.

      > 1. Some people just seem to think better under
      > OOP due to their *particular* brain/phsycology.

      hmmm.. never gave too much thought to this, but it seems most programming paradigms use some kind of analogy model to help their users. Nonetheless, if what you say is true, you are giving a good arguement FOR OOP.

      > 2. Written OO material tends to overemphasize
      > certain change patterns that OO is particular
      > good at, at the expense of change patterns that
      > OOP has a tougher time with. IOW, they present
      > a non-representative (frequency-wise) list of
      > change problems, and then conveniently show
      > OOP "fixing" them.

      I'm definitely interested in what you're suggesting. Do you have any references that catalog some of these different problems OO struggles with (and other paradigms do not)?

      Most of the opinions that I have are based on either studying or maintaining code written with various approaches. I'm by no means an OO zealot and can appreciate elegance in any form. However, the OO code I've seen *tends* to be more readable/elegant than most proceedural. And the bad OO code is sometimes a result of using alot of proceedural ideas (or in some cases, design problems that could be fixed w/ GoF patterns :)

    3. Re:really interesting by Tablizer · · Score: 2

      (* Although I'm not primarily a java programmer, a nice example that jumps out at me would be Java applets. You can simply inherit the majority of functionality that you do not need to change from code provided in the framework and simply provide your own implementation changes where appropriate. *)

      Inheritance is simply a form of "overriding" defaults. In p/r you can also make it so that blank table cells or that not supplying a named parameter result in some default behavior. It is not more code than inheritance.

      But where inheritance fails is when changes are no longer hierarchical or not mutually-exclusive. You cannot easily "grab" behavior or attributes from a peer branch on the inheritance tree without a lot of code shuffling. P/r techniques allow one to use sets, for example, instead of trees if changes progress in a non-tree fashion. OOP requires a complete code structure change to go from tree-based feature management to set-based feature management.

      IOW, p/r does not make the code structure resemble your currently-used data structure. That way you can change the data structure characteristics/shape without major code overhauls. You may have to change an expression or two, but you don't have to *move* large chunks of code around.

      (* Furthermore, designing using very specific "nouns" has the side affect of predisposing your code to reuse. *)

      I addressed "reuse" in a sister message.

      (* I have found that proceedural programmers tend not design their software in a way that allows it to be immediately applicable to other tasks. *)

      I find procedural programmers do all kinds of different *bad* crap if you let them. (Same with OOP.)

      I will agree that OOP training *by tradition* encourages people to pay more attention to software engineering issues. However, the same could be done with p/r techniques, but is generally not.

      It is like the Hypocratic Oath being part of medical training, but not say jet mechanics. It is tradition, not need, that makes it that way.

      Are going to argue that bad OO is better than bad p/r? I know some OO fans who even disagree with this. They have some OO-gone-bad horror stories of their own. IMO, bad p/r is at least more consistent than bad OO in practice. OO training makes stupid programmers have more oddball ways to obfuscicate OO code.

      Thus, we should probably compare good OO[1] to good p/r rather than bad to bad.

      [1] If there is such a thing :-)

      (* Nonetheless, if what you say is true, you are giving a good arguement FOR OOP. *)

      I did not say *all*, or even *most* brains are a better fit for OOP. There is just no decent data on this issue. It may not be practical to pack rat a language with every paradigm and construct just incase somebody thinks a given way.

      (* I'm definitely interested in what you're suggesting. Do you have any references that catalog some of these different problems OO struggles with *)

      I suggest you poke around my website. A starting point may be:

      http://geocities.com/tablizer/change.htm#people

      (AKA, "people types")

      (* However, the OO code I've seen *tends* to be more readable/elegant than most proceedural. And the bad OO code is sometimes a result of using alot of proceedural ideas (or in some cases, design problems that could be fixed w/ GoF patterns *)

      Well, I would be interested in seeing something specific, hopefully from my familiar domain (custom biz apps), and not say Chemistry. I have no feeling for the change patterns of such industries.

      "Elegant" is often subjective, BTW.

    4. Re:really interesting by Anonymous Coward · · Score: 0

      Although I'm not primarily a java programmer, a nice example that jumps out at me would be Java applets. You can simply inherit the majority of functionality that you do not need to change from code provided in the framework and simply provide your own implementation changes where appropriate.

      Java applets are pretty much a dead technology. Not a very convincing example if we look at market acceptence.

    5. Re:really interesting by cmh7r · · Score: 1

      I wasn't making any claims about their worth, just that they are a great example of how OO design facilitates code reuse.

      Substitute Java servlets if it makes you feel better.. they work the same way.

  36. Double checked locking by SashaM · · Score: 1

    For those unfamiliar with double checked locking, it's explained here.

    The basic claim, is that code like this:
    public class Singleton{

    private static Singleton instance;

    public Singleton getInstance(){
    if (instance == null){
    synchronized(Singleton.class){
    if (instance == null)
    instance = new Singleton();
    }
    }
    return instance;
    }

    }
    doesn't work, and the only way to fix it is put the first (instance == null) check into the synchronized block, incurring the synchronization penalty every time the method is called.

    You could also simply avoid lazy initialization and instantiate the singleton when the class is loaded.

  37. Burn, baby burn by Latent+Heat · · Score: 1
    Patterns are the wheel that anyone who was ever tried to do anything serious with objects reinvents.

    Hey I got this main window object that has got all these child window widget objects -- they call that Composite. When I click on a widget, it notifies the main window -- they call that Observer. What I really want is to synch my edit box with the spin control, but I don't want to complicate the edit box by making it an Observer -- I will have the main window observe the spin control and forward that action to the edit box -- they call it Mediator (it is also known in the industry as Visual Basic).

    If GoF patterns are putting a name to commonly used OO techniques that you have probably already reinvented yourself, they are tres useful in explaining what you are doing to students, new programmers. If GoF patterns are "PHB says that I have to restructure my code to use patterns", I would agree with your flame -- they become a tool in search for a use.

    My biggest Pattern gripe is Singleton -- I have yet to see a clean implementation that does not require a lot of cut-and-paste to implement each Singleton. That darned thing is friggin hard to implement right -- Vlissides even admits in Pattern Hatching that he does not have a bulletproof C++ version of Singleton.

    1. Re:Burn, baby burn by 2short · · Score: 1

      "My biggest Pattern gripe is Singleton -- I have yet to see a clean implementation that does not require a lot of cut-and-paste to implement each Singleton"

      Funny, where I work we have a singleton template that lets me just say "Singleton foo;". All such declarations (with the same ClassName) actually get you the same object. I've used it a zillion times and never had a problem. I've never looked at the code for it (never had to!), but it never occured to me that it would be very complex. I'm not dissagreeing with you, I'm just curious what's supposed to be the big problem with singleton?

    2. Re:Burn, baby burn by 2short · · Score: 1

      doh! didn't hit preview. make that "Singleton foo;"

  38. Re:What's a good programming language in general? by Anonymous Coward · · Score: 0

    Language food fight predicted. Duck!

  39. Design Patterns Java Workbook by pokeyburro · · Score: 2

    Has anyone tried the Design Patterns Java Workbook by Steven John Metsker?

    It's sitting on my desk right now. I'm liking it...

    --
    Lately democracy seems to be based on the skybox, the Happy Meal box, the X-box, and the idiot box.
  40. And therein lies the difference... by avdi · · Score: 4, Insightful

    ...between software engineers and mere coders.

    --

    --
    CPAN rules. - Guido van Rossum
    1. Re:And therein lies the difference... by Ed+Avis · · Score: 1

      Which is which?

      --
      -- Ed Avis ed@membled.com
    2. Re:And therein lies the difference... by Anonymous Coward · · Score: 0

      If you need to ask....

    3. Re:And therein lies the difference... by kin_korn_karn · · Score: 1, Flamebait

      oh, fuck you, you pretentious cocksucker. At the end of the day software engineers and "mere coders" take home the same paycheck, so what the hell difference does it make?

    4. Re:And therein lies the difference... by avdi · · Score: 1

      Heh. I'm sure you'd like to think that's the truth. If it makes you happy, go on thinking it :-)

      --

      --
      CPAN rules. - Guido van Rossum
    5. Re:And therein lies the difference... by Sayjack · · Score: 3, Funny

      Coder - One who codes

      Developer - Also a coder but has a complex about being referred to as a "mere coder"

      Software Engineer - Coder who has read GOF and knows how to use visio, has a complex about being referred to as a "mere developer".

      Architect - Coder who has read GOF, knows how to use visio and can talk buzzwords to management thus securing the promotion. Could code, but isn't allowed to, eventually loses all perspective on facets of actual implementation. Has a complex about being called a "mere software engineer".

      --

      -- Good judgement comes with experience. -- Experience comes with bad judgement.

    6. Re:And therein lies the difference... by Anonymous Coward · · Score: 0

      then what?

    7. Re:And therein lies the difference... by kin_korn_karn · · Score: 2

      I'd rather be a mere coder and keep my life than be a *string flourish* SOFTWARE ENGINEER!!! and be the kind of dork that reads shit like this.

      Tech pays the bills for me, nothing more. I'm good at it and I used to love it, but now it's just a job. and I love THAT.

  41. If its anything like Bruce's other infatuations... by avdi · · Score: 2

    ...it'll be longwinded, over-enthusiastic, and discarded as soon as Bruce moves on to his next programming fad.

    At least, that's been my impression so far of Bruce "Shiny objects are neat!" Eckel.

    --

    --
    CPAN rules. - Guido van Rossum
  42. Singleton anxiety by Latent+Heat · · Score: 1

    I think I have been looking for an inherit-from-a-base-class instead of using a template.

  43. Re:What's a good programming language in general? by Anonymous Coward · · Score: 0

    Java sucks at GUI apps because of Swing's overuse (and misunderstanding of) patterns.
    Whoever designed that shit should be fired.

  44. Re:why i don't give a rat's ass about design patte by Anonymous Coward · · Score: 0


    Your links are slashdotted, it appears.
    A new design pattern: The Blank Screen Pattern

  45. Re:why i don't give a rat's ass about design patte by Anonymous Coward · · Score: 0

    I got through to one, but odd how the table of contents have no href links. If this is how anti-pattern people do content, they will turn off a lot of people. Few are going to walk into a house if they have a hard time finding the door. The Door-free House Pattern?

  46. multiple category problem? by Anonymous Coward · · Score: 0

    Why is this topic *not* also under "Developers"? Tablizer might have a point afterall about "tree-happy mutually-exclusive taxonomies" here on slashdot itself.

  47. Biggest gripe actually good feature. by Anonymous Coward · · Score: 0
    I feel it would have been better delivered on a CD. I realise this adds, what? $5?, to the cover cost, but the book would have been substantially thinner, with a knock-on effect on price.

    Try adding $15 to the price.

    And I can't put the CD in my lap and look at it when I'm coding. And since I 'ding have a few hundred dollars to spend on a laptop I can't take code on a CD with me. I can take a book. Dead trees also don't require batteries. I applaud the use of dead trees as opposed to 1s and 0s as a distribution format.

  48. shouldnt this be by Anonymous Coward · · Score: 0

    advanced jawa patrons?

    nerft poft.
    i nid it mynelf.

  49. And therein lies another difference... by kaladorn · · Score: 2

    Egotism and arrogance aren't necesarily desireable corrolary features either!

    Software Engineering is a much maligned, poorly-understood and often pretended-to discipline. But that doesn't mean that most "mere coders" don't perform engineering functions (note the definition of engineering involves applying thought and ingenuity to a problem).

    And a lack of any sort of humility on behalf of "Software Engineers" isn't likely to help bridge the gap between conventional engineering disciplines and the very active world of software production.

    Instead of displaying an annoying disdain for your fellow slashdotter (whom I may not agree with but I'm not going to trash for an ego boost), can't you make your point without the attitude?

    --
    -- Mal: "Well they tell you: never hit a man with a closed fist. But it is, on occasion, hilarious."
  50. Re:why i don't give a rat's ass about design patte by mjd · · Score: 1

    My site was not slashdotted.
    I was moving house and changing ISPs.

  51. FYI: Fixing Singleton in C++ by Anonymous+Brave+Guy · · Score: 2
    My biggest Pattern gripe is Singleton -- I have yet to see a clean implementation that does not require a lot of cut-and-paste to implement each Singleton. That darned thing is friggin hard to implement right -- Vlissides even admits in Pattern Hatching that he does not have a bulletproof C++ version of Singleton.

    You can make a pretty straightforward Singleton template easily enough, as long as your compiler is up to speed on basic template work (which almost all mainstream ones now are, so you're fine unless you're working in the legacy world). I refer my honourable friend to Modern C++ Design by Andrei Alexandrescu for one simple possibility (and many other useful tricks with Singletons and templates generally, if you're compiler's up to it).

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  52. I hate it when I forget to change "you're" into "your" after an edit and don't notice in the preview. Sorry.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  53. Here's a little about design patterns by Anonymous+Brave+Guy · · Score: 3, Interesting

    The basic idea is that certain problems arise frequently in designing code, and often people come up with very similar designs to implement the solutions. This gives rise to two ideas.

    1. It's handy to have a name for these common idioms, so you can discuss them without having to waste effort defining them all the time.
    2. One person may implement things slightly differently to another, to cater for a problem or possible extension that someone else didn't notice. It's useful to have a baseline solution that's been well-reviewed and is known to handle common problems/extensions well.

    A design pattern is simply a named, streamlined solution to a common problem.

    Many people, not least Gamma et al. in their book Design Patterns (Addison-Wesley, 1995, IIRC), suggest that if you find the same sort of idiom solving similar problems in two or three different places, then it's likely to be worth looking for the underlying common idea behind those solutions, streamlining and naming it, and thus producing a new design pattern. Some design patterns are quite general and occur in many OO designs in diverse fields, and others occur frequently in a particular field but are irrelevant elsewhere.

    Design patterns are basically useful in two ways.

    1. Up front when you're doing initial design, you might recognise your situation as being similar to a pattern you know, and thus get an idea about how to design the code to meet the situation.
    2. In code reviews and refactoring exercises, if you've wound up with something similar to a common pattern, it pays to check out the known issues with that pattern, and see if any of them arise in your code (in which case, you can use the known workarounds/design changes to fix them). If you've come up with a different solution to the same problem, maybe the design pattern handles cases you don't; if so, you might pause to convert your design to use the pattern instead.

    The final important thing to remember is that design patterns are never a goal in themselves. Code is not good just because it follows patterns or bad just because it doesn't. The benefit of patterns is simply that they make it easier to do what you might have done anyway, but probably with less effort, more confidence and better results.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  54. Double-checked locking by dwalsh · · Score: 1

    "you won't see discussion on why double-checked locking implementations of the Singleton pattern don't work. "
    ... nor should you.

    Two scenarios:
    1.There must be only one Singleton instance at a time, and if this rule is broken it has negative consequences for the correctness of your application, or a large performance overhead.

    Make the getInstance() method synchronized.

    2. A short-lived second instance is not a huge problem.

    Don't worry about it.

    There is far too much emphasise placed on the avoidance of synchronization, when greater gains can be made by optimizing other things like your algorithms. The performance cost has been reduced in VMs in the last few years anyway. The double locking idiom existed purely to avoid synchronization, and never worked anyway.

    I heard a great quote at JavaOne a few years ago: "The cost of synchronization is less than the cost of stupidity".

    --
    ${YEAR+1} is going to be the year of Linux on the desktop!
  55. I don't see reuse (was: really interesting) by Tablizer · · Score: 2

    (* I wasn't making any claims about their worth, just that they are a great example of how OO design facilitates code reuse. Substitute Java servlets if it makes you feel better.. they work the same way. *)

    I don't see code reuse. Could you point out something more specific?

    You could get something similar with associative arrays, named parameters, and tables. Example:

    handle = createThing() // use defaults

    handle = createThing(featureA=foo, featureB=bar,
    featureC=narq, etc.) // select specifics

    Dictionary:

    declare myDict[]
    handle = createThing(myDict) // defaults

    myDict["featureA"] = foo
    myDict["featureB"] = bar
    etc...
    handle = createThing(myDict) // pass in options

    I am not showing table versions here. Plus, one can use *set-based* defaults. Inheritance cannot do this very well without emulating my approach the hard way and overhauling pre-existing inheritance-based code.

    IOW, OOP has a hard time going from inheritance-based defaults to non-tree-based structures. Sets are a super-set of trees, and thus can be both without significant code structure overhauls.

    Tree-based "reuse" is too limiting in many cases. The world just simply does not change in a tree-wise fashion; that is the bottom line and I stand behind that observation to my deathbed!

    There is no natural force to herd things into tree-wise change patterns (except for some narrow domains). I keep saying it, but it does not sink in. You guys keep going tree on me.

    Get your heads out of the trees! Many of the more experienced OO fans have already realized this, and promote "delegation" (referecing) instead. Go ask them if you don't beleive me. (The problem is that delegation is reinventing relational technology from scratch the hard way.)

    1. Re:I don't see reuse (was: really interesting) by Anonymous Coward · · Score: 0

      You did it again in your examples there: you only show attribute management and not behavior management.

    2. Re:I don't see reuse (was: really interesting) by Tablizer · · Score: 2

      (* You did it again in your examples there: you only show attribute management and not behavior management.*)

      One cannot easily do set-based with inheritance-like structures with behavior. It takes a different approach altogether. The lack of guarenteed mutual-exclusion[1] means things may overlap or conflict if we try to do it the same way OOP inheritance does it. (Multiple inheritance can run into these problems, and thus it is mostly only used to inherit widely *different* things/interfaces to reduce chances of such collisions/conflicts.)

      [1] This is *not* a bad thing, because it reflects the real world's change patterns (in my observation). Mutual exclusion is simply rarer than OO books make it out to be, at least in long-term biz modeling. A common example is OO books showing a bank account split into Checkings and Savings account subtypes. Well, some banks have offered *hybrids* in the past. Inheritance does not handle catdogs very well.

  56. How much for... by fm6 · · Score: 2
    Really, I think that it is best to be language agnostic: happily use any language someone pays you to use.
    You should charge extra for some languages, such as Intercal.