Slashdot Mirror


Book Review: Elemental Design Patterns

jkauzlar writes "Believe it or not, it's been 18 years since Design Patterns by Gamma, et al, first began to hit the desks of programmers world-wide. This was a work of undeniable influence and usefulness, but there is criticism however that pattern-abuse has lead to over-architected software. This failure is perhaps due to wide-spread use of patterns as templates instead of understanding their underlying 'grammar' of this language such that it may be applied gracefully to the problem at hand. What's been missing until now is a sufficiently authoritative study of design patterns at this 'grammatical' level of abstraction. Jason McC. Smith, through a surprisingly captivating series of analytic twists and turns, has developed a theory of Elemental Design Patterns that may yet rejuvenate this aging topic." Keep reading for the rest of Joe's review. Elemental Design Patterns author Jason McC. Smith pages 368 publisher Addison-Wesley Professional rating 9/10 reviewer Joe Kauzlarich ISBN 978-0321711922 summary Software Design Much as developing a large taxonomy of star-types in astronomy lead to and enabled theories of star formation, or a classification of organic life lead to studies of genetics, it makes sense that the large volumes of collected object-oriented design patterns should somehow lead to a generic understanding of them. Smith actually approached this in an attempt to solve a very practical problem: given the variety of ways a particular pattern can be implemented, how can one be recognized programmatically with a degree of certainty?

What's most fascinating about Elemental Design Patterns is the analysis performed in working out a solution to the question of how a pattern may be defined in a way that's language-agnostic and flexible to differing implementations. This was a success: his resulting pattern recognition tool even found unintentional usages of well-known design patterns in a large legacy code base, which could then be refactored from the ugly 'accidental usage' to transform apparent chaos into maintainable order.

The basic idea is that every pattern is composed of elemental patterns. For example, the 'Factory Method' pattern may be decomposed into four EDPs (elemental design patterns): 'Create Object', 'Fulfill Method', 'Conglomeration' and 'Retrieve'. The 'Pattern Instance Notation', introduced in this book, and which serves as an extension to UML, helps visualize the relationships between the four sub-patterns and the larger pattern. No doubt readers will find the notation useful in their own work.

This premise's success or failure hinges on two questions: are the set of patterns really elemental? and can the set of patterns be complete? Oddly, the patterns listed in the book are NOT complete: "this book touches on only one-quarter, at best, of the possible EDPs that exist" (p. 107). The fact that this book (which defines 16 patterns in depth) is only the beginning of a project is not well-communicated. Those who might benefit from a complete listing of EDPs (i.e. analysis tool makers) might be puzzled at how to immediately put this book to use if it's not complete. After all, Smith insists in the Preface that "this book is meant to be used." To me, this implies it should serve as more than a basis for research or design-skills edification.

As for them being elemental, in the sense that all possible 'macro-patterns' may be built from them, Smith backs up this claim with the help of a mathematical formal system called rho-calculus, which is introduced in some depth in the appendix, but avoided in the body of the text for readability's sake. Readers wanting a full mathematical treatment are referred to Smith's Ph.D thesis.

What makes the book worth reading and re-reading is in the methods employed to analytically derive EDPs. As dull as I probably make it sound, Smith gives the entertaining first half of the book an almost 'novelistic', first-person quality in which the reader is engaged to experience Smith's insights first-hand. In a sense, the EDPs are 'unfolded' from simple concepts like the degrees of method or object similarity in a method-call relationship.

Understanding this point is important to understanding EDPs: a method call is not just a method call from a 'micro-patterns' perspective. Calling a very different method on the same object is semantically distinct from calling a very similar method on a very different object. The first is described by the EDP 'Conglomeration' (breaking larger tasks into subtasks); the second, by the EDP 'Redirection' (redirecting a process to another object). Of course, the terms 'similar' and 'different' are fuzzy qualifiers to programmers and there's bound to be some debate on how these terms are applied. Smith, in order to make this distinction, puts faith in the developer's ability to name classes and methods. But anyway, such 'semantic' relationships are the real building-blocks of the higher-level patterns. Once other object-oriented principles are considered, like inheritance, the EDP list grows.

The importance of Elemental Design Patterns from a designer's perspective should now be more clear. I kept stressing the word 'semantic' in the last paragraph because what this book strives to do is provide a *language* for describing object-oriented structure that, first of all, doesn't rely on the OO language itself (C++, Smalltalk, Java, Javascript, etc), and more notably, which takes into account the designer's purpose for employing simple devices like method calls and class extension. As I said earlier, a method call is not just a method call. There may be a dozen or so 'structural' reasons to call a method, and each reason is given it's own 'word' (i.e. EDP) in Smith's language. It stands to reason that a designer with a firmer grasp on his own intentions is a more effective designer.

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

129 comments

  1. That was painful by Anonymous Coward · · Score: 5, Insightful

    That review painful to read. Dunno if it’s the verbosity or what but it felt less technical and more like prose. I think too it got a bit too much into the books contents, almost trying to paraphrase the book. It’s supposed to tell me whether I want to read the book, not provide me the Coles notes version.

    As for the topic itself, while I find it interesting someone has done serious analysis on the topic, I think in practice it comes down to three things:
    1) Experience
    2) Common sense
    3) Checking your ego at the door

    First one applies to everything. OO design is harder than people think. It takes long term experience and many failed approaches before one develops an intuitive sense of what is going to work at well in code as does on paper.. and what will survive the inevitable scope changes and end of project quick hacks with some elegance in tact.

    Second one kinda ties in with the first one. Design complexity should match project scale and expected maintenance. Don’t abstract stuff that is very unlikely will ever need to be changed/will require massive re-write anyway. Abstract the hell out of stuff that would likely change.

    Annd third one ties into the second one. A lot of OO insanity comes from people trying to show off how big their brain is by cramming every design pattern they can think of into the software. Hey look, I created an abstract factory that takes a creation behaviour (built from an abstract behaviour) and covered it up in a facade! Just code it the way it makes sense, not what makes the most badass class diagram!

    That's not to say design patterns arn't useful. But I view them as problem solvers, not general usage code. You shouldn't instinctively try to use design patterns for everything.

    1. Re:That was painful by Gr8Apes · · Score: 2

      You shouldn't have posted anon... these are some good points. I'd go further - most software components should be designed with no more than 4 basic patterns in them - this allows for maintenance folks and others to come along later and understand what's going on without 6 months of due process. Note - these are components, not solutions. Components themselves generally should have very little internal abstraction - this means that a component should be testable and verifiable. If you abstract things within it, this becomes a much more difficult process. Lastly, components should follow functional boundaries as much as possible, again, this eases testing and makes for "complete" units.

      --
      The cesspool just got a check and balance.
    2. Re:That was painful by Anonymous Coward · · Score: 0

      Whenever someone mentions design patterns to me, my eyes water and my mind goes numb and I jump to number 3. Everything has its place, but some people take patterns to the extreme.

      When I was a contractor so many places brought this subject up only to find they weren't really using them or not using them correctly.

      Getting my Masters I had one professor who obsessed over them, it drove me nuts, I learned an awful lot but sometimes it took way longer trying to implement a pattern for everything when I could have had it done two days and 100 lines ago. Patterns always seemed to be labels for things that were obvious to me anyway.

    3. Re:That was painful by Eponymous+Hero · · Score: 4, Informative

      i have mod points to give you but you are maxed. there is a word for what you're talking about: anti-patterns. http://en.wikipedia.org/wiki/Anti-pattern

      --
      insensitive clod overlords obligatory xkcd car analogy russian reversals whoosh pedant fanbois ftfy in 3...2...1..PROFIT
    4. Re:That was painful by plover · · Score: 1

      Patterns always seemed to be labels for things that were obvious to me anyway.

      That's almost the exact definition of what a pattern is supposed to be. It should be an obvious name, so we can all talk about the same basic concept with a common shared language. They aren't magic beans you drop in code. they are concepts.

      After you grok the concepts they contain, then they become magic beans that you can drop into your code. See the difference?

      --
      John
    5. Re:That was painful by Anonymous Coward · · Score: 0

      You sound like you fall into number 3. When I wrote that I knew someone who point that out to me, and go "see". Oye

    6. Re:That was painful by Anonymous Coward · · Score: 0

      This comment was painful. First of all, prose is prose and reviews summarize books. get over it. Second, checking your ego at the door? I've seen untold numbers of lines of crap code written by 'cowboy programmers' who don't like to design in advance, who don't take design seriously or don't want to learn from book-readin'. I've spent years of my life debugging and rewriting that software after the fact, because a) it was impossible to figure out what the original guy was trying to do (i.e., he or she didn't adhere to common practices/patterns), b) it wasn't extensible, modular, etc (all byproducts of using patterns).

      Of course, they DO lead to over-design and that's what experience is for to avoid, but to be knowledgeable and curious about how other people are designing software is the difference between an average developer and a good one. Mostly your post is not far off, but the righteous attitude is a real problem in this industry. Some people deal with software on the scale of hundreds of thousands or millions of lines of code, but most developers deal with smaller apps, and mostly web apps. In the former camp, the dev and design process simply has to be a lot more strict and these 'big words' (as you see them) come in handy pretty often.

    7. Re:That was painful by plover · · Score: 2

      I fall into the category of "write simple methods that are easily proven with automated unit tests." When it comes to patterns, if I see one, they tell me "because you did it this way, it means X to performance, Y to maintainability, and Z to correctness."

      I care a lot more about design principles than about design patterns. Give me simple and clear code first. When it follows a pattern, I'll understand the consequences quicker. If it's close to a pattern, I'll stop and think about the differences. Why did you do this? What does this change solve? Your design doesn't have to follow a published pattern, but it has to have a valid purpose.

      --
      John
    8. Re:That was painful by Anonymous Coward · · Score: 0

      Much of the wheel-spinning in this area comes from a failure to define two common terms: design and architecture. In the systems engineering world (http://www.sstc-online.org/Proceedings/2005/PDFFiles/JOC846.pdf) design is "the plan for fulfilling functional requirements" and architecture is "the plan for fulfilling non-functional (aka: quality or performance) requirements". With these terms defined, everything else falls into place.

      What design patterns should be used? It depends on what functional requirements are being fulfilled.
      Is architecture pattern X appropriate? Only if there is some non-functional requirement driving it.

      Start with high-level capabilities, analyze and decompose them into detailed functional and non-functional requirements, then choose the appropriate design and architecture patterns for each requirement. If a pattern can't be traced to a requirement, then it isn't needed.

    9. Re:That was painful by greg1104 · · Score: 1

      Hey look, I created an abstract factory that takes a creation behaviour (built from an abstract behaviour) and covered it up in a facade!

      You are such a newb; obviously this is useless unless you then wrap the result in an iterator.

    10. Re:That was painful by Anonymous Coward · · Score: 1

      A bit of knowledge is a dangerous thing. I find it's better to start solving the problem at hand and let the patterns emerge naturally rather than shoe-horning the problem into a predefined design pattern from the start.

      When I was young and inexperienced I used to just code whatever needed to be done to solve the problem with a view to cleaning up duplication and other mess later, but usually never got round to it, so my programs worked but lacked maintainability. Over the years I've learnt various stuff from the coding world, OO, Design patterns, TDD etc and tried to apply these things to *everything*. The result, an overengineered codebase that had abstractions over abstractions and took ages to get anything done, it was needlessly over complicated. These days when I write something, I try to not think about what pattern would fit the problem, but rather just start coding and keep an eye out for patterns as they emerge. Then once I identify some duplication or something that looks very much like a pattern, refactor!

      Think coding Taoism - Let the code show you the "way" rather than forcing it into something it's not... ;-)

    11. Re:That was painful by jkauzlar · · Score: 2

      Reviewer here.. you say 'It's supposed to tell me whether I want to read the book, not provide the Coles notes version.' So, how should I know whether you want to read the book? I'd prefer to tell you what it's about and you're free to decide whether it's something you'd be interested in. I did find it interesting, but I really don't know the scope of the potential audience for such a book.

      As for your critique of design patterns in general, you're spot-on, but nothing new. The same critiques have been made repeatedly for at least 10 years and yet people continue to find a few patterns catalogues useful. I mean, they're basically just common ways of structuring code, so how could that not be useful? Though, as you say, just don't use them as goals to be achieved in order to have cooler-looking class diagrams.

    12. Re:That was painful by Anonymous Coward · · Score: 0

      That would seem to be the first two items listed.

      As you (and OP) said.. it takes experience to get to the point where you can even understand design patterns, and then years of using them wrong and seeing _why_ certain things work and certain things don't before you can use them effectively.

      It also takes common sense to, as you said, not just blindly apply them to anything or worse, contort your software to fit them for the sake of it.

    13. Re:That was painful by Anrego · · Score: 1

      Not to pile on the hate (I didn't find the review hard to read per se.. and nothing wrong with some elegant phrasing) but I too found the review got a little too much into the topic.

      Maybe it's just personal preference, but when I read a review, I am not yet ready to delve into the subject matter. I'm primarily looking for a quick overview of the subject area, scope, and target audience (specifically whether I fall into it), tone (cheerful, funny, dead seriousy, insightful, technical, etc.) and quality (well written, poorly written, lots of pictures, wall of text, etc.) to determine whether I want to commit some brain time. If I have to start thinking while reading the review, I may as well be reading the book ;p

      This is more like a critique of the book or a discussion piece than a review. Which isn't a bad thing either. Certainly judging from the comments, I think it has served more to get people talking about design patterns vice the book itself or its subject matter (which I think is the case for most vook reviews anyway, I mean what discussion can be had about a book no one has read yet. How does one discuss a review).

    14. Re:That was painful by jkauzlar · · Score: 1

      Thanks, I understand what you mean and it makes sense. This was a different sort of book than I usually review here, so I wasn't sure how to approach it, especially since it's hard to easily summarize what exactly the author's intentions are. Thanks again for the constructive criticism.

  2. Patterns over hyped? by darjen · · Score: 4, Insightful

    I am a senior developer at a large publicly traded company. We have some pretty high volume systems, and I have yet to really use any other patterns besides MVC in my daily activities. I have also worked at several smaller consultant firms and never used them much before my current place. Maybe it's just because the type of problems I have been working on aren't complicated enough?

    1. Re:Patterns over hyped? by Anonymous Coward · · Score: 2, Insightful

      I always through most of the patterns in the Design Patterns book could have been better described as 'Workarounds for language(or library) limitations'

    2. Re:Patterns over hyped? by Anrego · · Score: 1

      I find a lot of them are very useful in extremely special circumstances.

      There are some though that I do use on a fairly regular basis. The biggest ones being the factory pattern and observer/strategy patterns.

      I also the Singleton more often than I like to admit.

    3. Re:Patterns over hyped? by stanlyb · · Score: 1, Insightful

      Seconded. And as of the "design pattern" hype, man, thank you for describing and defining how exactly i am walking and running. Man, if it was not you, i could not imagine even moving my left foot in front of my right foot, then my right....then my left.....MAN, god bless you, now when i am walking, i now that i am using "DESIG PATTERN WALKING UNDER THE SUNSHINE".

    4. Re:Patterns over hyped? by thePowerOfGrayskull · · Score: 4, Insightful

      Alternatively you have implemented additional design patterns without knowing it.

      That's something I've seen a lot - just because someone doesn't know a name for something doesn't mean that they can't use it. In interviews I've asked people to explain the factory pattern (arbitrary example) to me - and had them draw blanks. But a few questions reveals that they're familiar with it, and just never associated it with the name "factory pattern".

    5. Re:Patterns over hyped? by Anonymous Coward · · Score: 0

      I always through most of the patterns in the Design Patterns book could have been better described as 'Workarounds for language(or library) limitations'

      As a good example of this in practice, see how Guava's EventBus replaces a huge chunk of the Publish-Subscribe pattern.

    6. Re:Patterns over hyped? by Anonymous Coward · · Score: 0

      The main use of Design Patterns is so that you can say "Hey, I'm a smart software engineer. Are you a smart software engineer?" It's reserved pretty much for interviews. Sort of like how Google has very, very long interviews which boil down to the question, "Did you just get out of grad school? 'Cause we think practical knowledge is stupid compared with what you learn in grad school and never use in real life software development."

      Really, though, the main thing is having built up the experience and breadth of knowledge to know where to look if you run into a particular type of problem. "Design Patterns" was utterly useless to me (except possibly for interview preparation) because the problems and solutions presented were all pretty fucking obvious to me or had severe failings that'd make them poor choices in any of my work. Working as a developer has constraints both on the types of problems you work on and the types of solutions you're allowed to pursue, so it's perfectly reasonable to think that almost none of the book will ever serve you practically. In fact, if you pick up "Design Patterns" and think to yourself "Oh, I should use this! And this!", the odds are you're like a kid applying to colleges who uses the thesaurus to make a much worse essay than they'd write if they didn't have a thesaurus.

    7. Re:Patterns over hyped? by Quince+alPillan · · Score: 1

      Oddly, I've never come across the concept of Object Oriented Design Patterns with specific names, nor have I heard of this book or the previous version before today. Are these patterns and their specific names commonly laid out across multiple titles that every junior programmer should come across, or are they esoteric and specific to the people who have read these books?

    8. Re:Patterns over hyped? by plopez · · Score: 1

      Yes and yes. It's considered esoteric because may haven't read up on the topic and everyone should at least be introduced to the concept of recurring design solutions.

      You might want to either purchase the books at the book store of your choice or check them out of your local library.

      --
      putting the 'B' in LGBTQ+
    9. Re:Patterns over hyped? by Anonymous Coward · · Score: 1

      The original Design Patterns book linked in the summary was written by four people (so-called "Gang of Four") back in the '90s. These are patterns that were found to be almost as useful as encapsulation and polymorphism familiar to C++ and Java programmers, but which cannot be conveniently expressed as a primitive in a language (unlike inheritance, for example). Some of them came out of the Smalltalk community in the '80s.

      Experienced object-oriented programmers are expected to know many of these patterns. In a nutshell, the larger the codebase and the more tiers involved in your solution, the more these patterns are useful, even essential. Also, it will help you understand the base class libraries for Java and .NET since those were obviously quite informed by design patterns.

      Unfortunately the Gang of Four book was written partly as a pattern reference, so it's not so easy going as a tutorial for those without either a CS degree or 10+ years programming experience. I'd advise start by looking for tutorials on the web.

      I would take some of the snarky comments here with a grain of salt. Those who spend most of their efforts in the presentation tier might not see the usefulness of many of these, other than MVC.

    10. Re:Patterns over hyped? by softwareGuy1024 · · Score: 1

      Interesting, seems very similar to Qt's signals and slots.

    11. Re:Patterns over hyped? by Darinbob · · Score: 1

      I haven't really used patterns either. I was at a company though where several engineers were religiously devoted to patterns. They would quickly denigrate code or designs that did not match any of the listed patterns in their book, or if something did match a pattern but diverged from the API. I've been in meetings where half of the time was spent arguing which of two patterns most closely matched the design. So I have been trained by experience to regard design patterns as something that induces irrational behavior.

      Now there's nothing wrong with design patterns per se. If a project has a certain set of patterns then it makes sense to follow them to keep the project coherent and understandable. But the idea of universal patterns that the entire world should follow and adopt to the letter is silliness. But then, things like this are just so rampant in computer science. So many goofy ideas that get follow unthinkingly without understanding them or knowing where they apply and where they don't. The cargo cult style of programming is still wide spread, we have armies of consultants spreading methodologies around, and I still run across people who look visibly worried when they see a "goto" in code.

    12. Re:Patterns over hyped? by Nerdfest · · Score: 4, Insightful

      Patter are simply giving names to the same things we've been doing for many, many years, and they're useful because of that. You can now describe your approach to a solution without showing actual code. Obvious examples most people will recognize are the Observer patter, Publish/Subscribe, and Factory. Many people implement these themselves long before someone gave an 'official' name to the solution. You use the right solution for the problem at hand, patterns just give a name to it ... or at least that's what they're supposed to do. I realize that some people consider it a contest to see if they can 'collect the whole set'.

    13. Re:Patterns over hyped? by Darinbob · · Score: 1

      These aren't academic books, they probably aren't taught in schools. But there are many managers and team leads out there who have read and memorized them and who assume every programmers knows it all as well. The books tend to be bought in bulk by teams; some team member reads it and becomes converted and convinces other team members are encouraged to purchase the books, or a manager puts it on a list of titles all new hires should purchase (all charged to the company too). It's a word of mouth thing.

      Now the book is not bad. There's some good stuff in there, but parts feel contrived. Overall the book's biggest flaw though is that some people treat it like a silver bullet that can solve all your problems. The ideas are more important than trying to treat it as a reference book, and memorizing names of the patterns is just a silly thing to do.

    14. Re:Patterns over hyped? by Anonymous Coward · · Score: 0

      thePowerOfGrayskull's observation that people "implemented additional design patterns without knowing it" is dead-on. I've been a developer since prior to the publication of the Gang of Four "Design Patterns" book, and the only real use I got from it was to give names to things developers were already doing. Which I suppose is helpful in communicating. But at no point in my career before or since did I take a pattern from the book, and make use of it in a design; it's always been solving a problem based on what makes sense to do, or by reference to actual similar implementations that I'd encountered. I think that's true for most developers. So I'm inclined to agree that patterns are over-hyped; these books are just recognizing and naming things, and creating a taxonomy. That good solutions have similarities is a matter of form following function - to go from pattern to implementation, rather than recognizing a pattern in the implementation afterward, gets the cart before the horse.

    15. Re:Patterns over hyped? by GreatBunzinni · · Score: 3, Informative

      I am a senior developer at a large publicly traded company. We have some pretty high volume systems, and I have yet to really use any other patterns besides MVC in my daily activities. I have also worked at several smaller consultant firms and never used them much before my current place. Maybe it's just because the type of problems I have been working on aren't complicated enough?

      I would guess that you do in fact use other patterns, but you actually do so without knowing. That isn't a bad thing, because ultimately what really counts is getting stuff done, and not write some kind of whitepaper announcing to the world that your company's current work is the result of an academically perfect implementation of a wide variety of design patterns.

      Nonetheless, I find design patterns to be very important and extremely helpful, mainly because they can be seen as a set of pre-defined solutions to a set of well-known problems. In other words, they represent building blocks which have been adequately studied and therefore provide important properties that are already known beforehand.

      Knowing these properties is extremely helpful when designing an application, because it lets you minimize the amount of work you will need to do to add some features, or even completely avoid it. By knowing design patterns you are able to come up with solutions to potential problems simply by identifying them and adopting the adequate design patterns to side-step it.

      As an example, let's imagine we were developing some sort of 3D modelling application. We could start by defining that the application would consist of a database component, which stores all the information regarding the model, and a GUI component.

      As you are already familiar with the MVC pattern, we could design the database component with as a model and implement any representation of the 3D model as a different view. But let's go a bit beyond that.

      In a 3D modelling application, we can expect that for each database component we might have multiple views. In addition, we might have an indeterminate number of components which might need to be aware of any information stored in the database. A nice way to pull this off is to design the database component as an observer pattern. By doing this, you are free to extend the 3D modelling any time in the future to add a new component without any trouble at all. In addition, you are also able to completely replace other components by simply taking them off and plug in a replacement.

      A 3D modelling application also needs to provide the user with a way to operate on the 3D model. Yet, more often than not we don't know everything the user wants to do and how he wants to do it. This means that it is a good idea to implement these operators in a way that you are free to add them in the future without being forced to rummage through half the source code tree. A good way to do this is to implement these modelling operators as a visitor pattern. By doing this, you've just defined a generic interface for every operator you might need, and basically you only need to add a single class to implement any extra feature for the 3D modeller. In addition, if you also make sure you also include the inverse operator for every operator then an undo system will pretty much write itself.

      The list goes on and on. You can implement your scene graph by employing a composite pattern, you might implement the components to import models from an assorted list of data formats by writing each component as a strategy pattern, you may implement a series of UI animations and input states around a state pattern, etc

      --
      Slashdot, fix your code or at least hire someone who is competent at it to do it for you.
    16. Re:Patterns over hyped? by Quince+alPillan · · Score: 1

      So it's a bit like SCRUM. Cult-like with some good gems, generally not taught in academic circles, treated as a silver bullet to solve all problems by non-coders, and ultimately useless unless its used as intended, which it generally isn't.

    17. Re:Patterns over hyped? by Anonymous Coward · · Score: 0

      That's great! Can you convince my boss to let us switch to lisp?

    18. Re:Patterns over hyped? by vux984 · · Score: 1

      I also the Singleton more often than I like to admit.

      Singletons are the modern global variable. We've all been trained to shun globals... and rightly so... but I think its gone too far.

      People are afraid to use use globals and singletons, even where they make sense.

      Sure every user control on your web page could open its own database connection and you can avoid a global or singleton by doing so.... but that doesn't mean you should.

    19. Re:Patterns over hyped? by Anonymous Coward · · Score: 0

      The "Design Patterns" book is overrated and full of trivial patterns. For a truly excellent book of useful patterns check out "Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions". The whole book is online here: http://www.eaipatterns.com/

    20. Re:Patterns over hyped? by stanlyb · · Score: 1

      I remember, when i was asked which container is the fastest one, and i was extremely surprised when i was told that the HASH table is the fastest one.... What the frack? What kind of idiots would try to find the fastest type of container, and always, i repeat ALWAYS would find out that the hash table is the fastest one!!!!!!
      Nevertheless, now i know why some big companies and some big sites are having their servers unable to handle a few hundreds of thousands requests even with their unlimited budget. You wonder why? I will answer you: HASH TABLE.

    21. Re:Patterns over hyped? by JonySuede · · Score: 2

      they both are reification of the Publish-Subscribe pattern. Patterns are use mostly to discus about code in a general way after the fact. It is quite rare to you go on choosing a mediator or a flyweight but looking back at a code base it is easy to find instances of patterns, whatever the language as they are implementation independent. The other use of pattern is to give a distilled experienced to a beginning programmer.

      --
      Jehovah be praised, Oracle was not selected
    22. Re:Patterns over hyped? by Jason+Smith · · Score: 2

      "Unfortunately the Gang of Four book was written partly as a pattern reference, so it's not so easy going as a tutorial for those without either a CS degree or 10+ years programming experience."

      Exactly. In my experience as an educator, I've seen both undergraduate and graduate students struggle with the GoF book when handed it with only the edict "Thou shalt do this." What inevitably happens is that they start copying and pasting the sample implementations as rote mantras, instead of seeing the underlying concepts as mutable pieces that they can work with to create a solution that fits what *they* need.

      That's where the EDPs come in. They give a ground level set of concepts and taxonomy to start composing the more abstract notions in the GoF text. For those new to patterns, they give an introductory way of approaching the literature, and thinking about even the most basic concepts of programming independent of implementation details. For folks who have been using patterns for years, they give (perhaps) a new way of looking at the tools to give them new uses.

      The design patterns literature is full of an immense amount of good information... when it's used well. When it's just copied and pasted, it can easily lead to worse problems.

    23. Re:Patterns over hyped? by Jason+Smith · · Score: 2

      I think you understand design patterns better than most people, to be honest. Copying and pasting a design pattern is the worst way of going about it, IMO. The bit that most people seem to miss, is that if it's not what you need, alter it to suit your purpose.

      That was actually a main reason for writing this book - to try and provide folks with an easier ramp-up to the existing design patterns literature in a way that got across the point that these patterns are both a) composed of smaller pieces that are understandable, and b) made to be custom-tailored.

      It's not the structure of a design pattern that is important, it's the concepts that it embodies. Fulfill those concepts in a way particular to your language, problem, or system, and you're still using that pattern, even if it doesn't look much like the example source provided.

      Of course, it really isn't obvious that that's the case when we haven't had a good underlying taxonomy for those concepts... hence the book.

    24. Re:Patterns over hyped? by Anonymous Coward · · Score: 0

      I am a senior developer at a large publicly traded company. We have some pretty high volume systems, and I have yet to really use any other patterns besides MVC in my daily activities. I have also worked at several smaller consultant firms and never used them much before my current place. Maybe it's just because the type of problems I have been working on aren't complicated enough?

      You've yet to recognise them you mean. I've yet to see a system that didn't use Singleton...and if you're using standard Frameworks I guarantee you're using Factory or Factory Method for things like database drivers, even if you are not actively building them.

      The problem is that people throw KISS principle out the door and try to use a pattern to solve every problem, even problems that did not exist. For example Factories, Factory Methods, Proxies and Bridges are all about building a system that can cope with components being swapped out for a different implementation. Well that's great if your system has or is likely to develop that need. Otherwise it's a collassal waste of time and effort and bogs the system down needlessly.

    25. Re:Patterns over hyped? by 2.7182 · · Score: 1

      I think your comment (a joke?) is just the right response to the abuse/misuse of OO oriented programming. It's really not that complicated - the situation is a hammer looking for a nail. When you find a nail you are sooo happy to have a hammer. But when you find you need a hex wrench to put together your Ikea book shelf, well, then you end up with a bad situation. (I'm sure an equivalent comment has been said many many times before...)

      I used to regularly teach data structures in the lates 90s when this stuff was the rage. There was a lot of pressure from the students actually to do more of it, since they were young vulnerable to the pressures of fads. As a person largely interested in numerics and scientific programming, I find it irksome that this stuff is sold by (some) people as a cure all. I was really surprised one day when I was discussing something like the behavior of arithmetic in C++ and the first thing the kid does after he opens his laptop is start defining a class in order to test what I was saying.

      Anyway, being a zealot isn't a great idea. But if I had to pick one thing to do everything in (you shouldn't!), Lisp wouldn't be a bad choice. Lisp and Fortran are old languages that are still around not just for legacy reasons.

    26. Re:Patterns over hyped? by GreatBunzinni · · Score: 1

      This doesn't make sense, and I am lead to believe that you actually don't know what a design pattern is. After all, no matter how complete a programming language or library might be, you still need to put stuff together, and when you put stuff up together you better choose to put them together in the best way possible, that actually solves your problems.

      To better explain what design patterns are, we can compare them to a more mundane field: civil engineering/construction. You see, while a programming language and API represents the individual building materials used in construction, such as mortar, concrete, steel rebar and I-beams, design patterns represent a specific way which these buildig materials are put together and made to work, such as reinforced concrete slabs, prefabricated joists, trusses, columns, beams, etc... It is helpful to think of a construction project in terms of individual components, by decomposing the entire structure into structural elements and the construction techniques that are used to implement them, than wasting time thinking about how you will arrange individual pebbles in a concrete mix, or how a rebar will be gripped by the concrete.

      So, in essence, design patterns provide you with a very convenient and useful way to think about pre-made solutions to specific problems, while saving you the time and need to reinvent the wheel each time you need to create a new component.

      --
      Slashdot, fix your code or at least hire someone who is competent at it to do it for you.
    27. Re:Patterns over hyped? by fatmonkeyboy · · Score: 1

      Depending on the type of work you are doing, it might be that the majority of your architecture is already in place (e.g., web frameworks like Rails). It could also be (as someone else implied) that the patterns are there and you aren't recognizing them. I hope you don't mind, but I checked your profile and it said "java web dev". You're not going to escape using Java for just about anything without using design patterns. You may not be implementing them, but the libraries you are using make use of them extensively.

      The "valueOf" function in Java is a static factory method. Why does it matter that it has a name? Because if you and I both know the name, we can discuss it more efficiently.

      For instance:

      Jill: "You have a lot of different constructors for your class, have you considered using static factory methods to make it more obvious what is going on?"
      Bob: "We could do that but maybe we should consider using the Builder pattern instead."
      Mike: "Whoa, wait a minute. I think Builder might be overkill for this situation."

      If our heroes don't have a common understanding of "static factory method" and "Builder pattern" the discussion becomes more lengthy. Having a common terminology for patterns facilitates discussion.

      People can describe a solution to a problem they encountered. Maybe their solution is a known pattern - great! They don't have to describe it themselves, they can point you at a wiki article and then describe how that solution worked in their specific situation. Maybe their solution isn't a known pattern - interesting! They can describe it in relation to other patterns and discuss the pros & cons of their approach versus the others.

      You can look up implementations of the pattern in the language / framework you happen to be using and see how other people have approached the problem.

      You can read people's thoughts about using the pattern, "Well, we considered but ended up doing something closer to ." Maybe you hadn't even considered "pattern 2" and maybe it's a better solution for your situation.

      And if people aren't using the names, you can still sometimes listen to their description of the system and short circuit a whole bunch of (high level) analysis. "Ah...that thing he's taking two pages to describe is a Factory. Got it."

      As far as using the patterns as a catalog...yes, that can be a problem. There is real danger of ending up in a "solution looking for a problem" mindset. But, paired with maturity and discipline, familiarity with solutions other people have used for a variety of problem can't hurt.

    28. Re:Patterns over hyped? by olau · · Score: 1

      And the best thing about this is that, by knowing design patterns, you are able to better express what you are doing and what you want others to do by referring to design patterns. For example, instead of talking about implementing a system of callbacks between a server and a set of clients by setting a common interface used to pass messages around and keep all clients coherent with the current state of the server... Just talk about implementing an observer pattern.

      This is nice and all - but I find in practice that people who are all gung-ho on patterns spend most of the time up in a sky where what they say is correct, but not terribly relevant to getting things done. To use your example, if you talk about an observer pattern rather than describing the mechanism, you are providing much less information about what you're doing.

      The principles themselves, as a sort of distilled experience, are important, no doubt about that.

    29. Re:Patterns over hyped? by angel'o'sphere · · Score: 1

      Everything you do half hearted or by following a hype is useless. However by dismissing it as useless you will never get the experience to understand it and to finally exploit its usefulness!
      People who find SCRUM useless don't understand it and use it wrong. After that gets pointed out they claim: the only awnser SCRUM fanboys have is: you use it wrong.
      Well, frankly if you can not do SCRUM or have no benefit from doing it you are on CMM level 1. Perhaps you schould learn how to do software in a team first.
      The same is for people ditching design patterns.
      The talking on /. is that _everyone they ever met_ does abuse them (followed by a: "don't get me wrong, they are useful in certain cases") I'm making software now since 30 years and I never stumbled over an design pattern excess or abuse everyone here is so frigthened about.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    30. Re:Patterns over hyped? by Mr+Z · · Score: 1

      Sometimes, it just takes a more approachable book with a shallower ramp to get your boat off the shore and sailing. I found the GoF book thicker than paste and more effective than a bottle of sleeping pills at putting me out for the night. A senior developer at my company then pointed me to some other books, such as Head First Design Patterns. It may've been a little on the goofy side, but it did present (most of) the patterns in a clear and motivated way.

      Once I read through that book and largely "got it", I found the GoF book much more approachable and much more useful. I actually read the whole thing. It's not a starter book, though.

      As for how I apply patterns, I apply them more like tools in a tool box. I have a problem with a particular shape, and I look for a tool (or tools) that fit that shape. For example, I needed to make a uni-processor program multi-processor while maintaining the fiction of uni-processor to the main program. The various threads' activities were already separate classes. The proxy pattern described an attractive way to replace a class with a stand-in that forwarded interaction to the remote processor, for example. The factory pattern offered a way to build these sets of remote objects from the main event loop on the remote processor. And so on.[*]

      It wasn't like one of these competitive cooking shows where they hand you an ostrich egg, some plaintains, purple cabbage and some veal and ask you to whip up a creative dessert...

      [*] You're probably thinking "ok, you're reinventing RPC/COM/CORBA/insert technology here, and probably poorly too. Why not use something off-the-shelf?" In case you're wondering, I wrote this to run on the "bare metal" (no OS) on a multiple CPU embedded processing chip. I didn't have the benefit of a more extensive framework, because whatever I write needs to run acceptably in a design simulator that runs veerrrrrrry slowly (on the order of 100 cycles/second), so every cycle counts. A framework with 1ms init time kills 10 hours of sim time to a first order of magnitude. And yet, I can make C++ and design patterns work for me in this environment.

    31. Re:Patterns over hyped? by Mr+Z · · Score: 1

      What if your container needs to return things to you in some particular order, like LIFO, FIFO, static priority-order, or the like? For those, the most efficient structures are usually stacks, queues, and heaps, respectively. Hashes make decent associative arrays, and if your total number of keys is relatively stable, then can perform better than RB trees, AVL trees and the like.

      Hashes are no silver bullet: Hash keys take time to compute. You can get lumpy performance if your key space varies dramatically and the underlying implementation keeps changing the number of buckets for the hash. If you pick a bad hash function (or a malicious party detects your hash function and tries to break it), you can blow up to O(n^2) performance where you expected O(n).

      They're good at a number of things, but they're not best at everything.

    32. Re:Patterns over hyped? by GreatBunzinni · · Score: 1

      This is nice and all - but I find in practice that people who are all gung-ho on patterns spend most of the time up in a sky where what they say is correct, but not terribly relevant to getting things done. To use your example, if you talk about an observer pattern rather than describing the mechanism, you are providing much less information about what you're doing.

      Any reference to a specific design pattern is nothing more than a reference to very concise but detailed description of the mechanism. An adequate parallel is referring to specific construction techniques, such as Berlin/king post retaining walls. Instead of wasting time and effort describing how the construction process works, what are the pros and cons, what materials to use, how to phase the construction, how to design them and other necessary but tedious information, we simply refer to it through a proper name.

      So, by referring to individual design patterns, we are actually providing much more information in a concise manner, due to the fact that if someone is really interested in more information then that person is free to pick up any reference on the subject and wrap their head around it.

      --
      Slashdot, fix your code or at least hire someone who is competent at it to do it for you.
    33. Re:Patterns over hyped? by Quince+alPillan · · Score: 1

      SCRUM is extremely useful if followed correctly, and I would not dismiss a fully functional SCRUM team's effectiveness. However, I've seen SCRUM used as a crutch by a dysfunctional management team that was using the hype of SCRUM and the effectiveness of SCRUM as an excuse to blame the coders when the project wasn't doing well (because of poor direction).

      Design patterns seem similar to SCRUM in that, when used correctly and effectively (as an algorithm reference, not coding with strict adherence to specific models) they can greatly enhance a programmer's effectiveness. Stories (above and below) about multi-hour arguments regarding which pattern name best fits a scenario and obeying known patterns to the exclusion of good design seem to be improper uses and abuses of design patterns and are similar to improper uses and abuses of SCRUM. That you haven't come across these abuses doesn't mean they don't exist - just that you've been with good programmers who have understood how they were supposed to be used.

    34. Re:Patterns over hyped? by angel'o'sphere · · Score: 1

      Well, frankly, I never saw a discussion about design patterns at all. People just use them, thats it. Sometimes one acquires a habit, and I find that interesting and encourage him to introduce his way to the team, so we have a new "local pattern". However this discussion that is often going towards: everything is hype, just code C and you are fine makes me ... hm, surprised, unwell?

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  3. Why do we bother numerical ratings? by i+kan+reed · · Score: 2

    I can't remember the last book review that wasn't 9/10.

    1. Re:Why do we bother numerical ratings? by somaTh · · Score: 1
      --
      Nostalgia isn't what it used to be.
    2. Re:Why do we bother numerical ratings? by Anonymous Coward · · Score: 0

      I once got an A on a Elngish comp paper for fessing up to never having read the book I was to cover in the paper. To my credit the paper wasn't "TL;DR. The End."

  4. What has been missing is critical thinking. by Anonymous Coward · · Score: 1

    Having seen patterns applied out of pure habit or subscription to programming dogma, what has stuck out in my experience has been the lack of any meaningful discussion around why a particular pattern was appropriate for the task at hand. See: EJB. See: people attempting to Hibernate their entire database. See: loads of unnecessary abstract classes. Just like Acai berry isn't going to make you skinny without exercise and regulated food intake, neither is any prescriptive development methodology going to make your code better without the requisite attention to its applicability vis a vis the problem you are solving.

    1. Re:What has been missing is critical thinking. by Anrego · · Score: 3, Insightful

      I think you nailed it in the first sentence.

      People have it in their heads that the crazier the class diagram, the easier the software will be to maintain. Obviously this isn't the case. Sometimes a design pattern can be used to provide useful abstraction or turn a complete hack into an elegant solution (or provide new and exciting hacks.. see: singleton) ,, but often it just adds extra classes that abstract things so core to the program that they will never change without a complete do-over .. or just adds useless layers of indirection that make it impossible for future maintainers to figure out what the hell anything does without using a debugger.

      I think applicability comes down to justification. Can you justify the usage of this pattern? If not.. don't use it! Treat them as things to use when there is a reason, not things to just always use.

    2. Re:What has been missing is critical thinking. by Darinbob · · Score: 1

      True, sometimes the silver bullet doesn't do the job. You have to break the rules, especially if the rules are just very loose guide lines. For instance, having software layers (ala OSI networking). Some people treat the division between layers as extremely important and inviolable; A calls B which calls C and finally D does the work, and A must never even know that D exists. But sometimes you can eliminate a large amount of code and speed things up by letting A query C or D directly.

      A lot of problems arise by applying design rules at too fine a layer. When a project is huge having fine grained abstraction does not simplify the design. Split things into large chunks instead, and let each chunk be somewhat independent.

      There's this holy grail of programming that it can be turned into a engineering discipline similar to hardware design. Or as I've heard someone put it, they wish they could design software the way people design bridges, with formulas and standardized parts and so forth. And design patterns are indeed used by some people as a sort of software parts catalog. Except that I think many of these people do not know what it is actually like to design hardware and bridges. Bridges often start with a very abstract design of what it should look like before the engineering part gets done, then there is an iteration that happens when the pragmatism conflicts with the idealism. In hardware I often see the same sorts of bugs and causes of bugs that you see in software; typos, over engineered parts, changing requirements, shortcuts, inadequate testing, etc.

    3. Re:What has been missing is critical thinking. by lwriemen · · Score: 1

      People have it in their heads that the crazier the class diagram, the easier the software will be to maintain. Obviously this isn't the case.

      I'm not quite sure what you mean by "crazier", but you later seem to equate it to more classes later.

      The more complete the class diagram, the easier the software is to maintain. This statement requires a qualifier: Good separation of concerns must be done before class modeling begins. i.e., subject matters must be divided into independent entities, which are then individually modeled.

      "Complete" means all the information possible (about the subject matter being modeled) is exposed by the class model. If this is done, your state and procedural models will be much simpler, changes will be easier to handle, and reuse possibilities will be wider. "Complete" excludes implementation decisions (unless that's the subject matter being modeled), so this kind of path is hard (impossible?) to follow in 3GL.

      See Executable UML

      Of course, the AC was right, and it should only be applied where applicable and appropriate.

    4. Re:What has been missing is critical thinking. by Joey+Vegetables · · Score: 1

      I call this the "onion architecture" and it is a mortal enemy of DRP (don't repeat yourself). It is generally sold as though it were an implementation of the SRP (Single Responsibility Principle). It isn't. The whole point of *both* principles is to help manage complexity, cohesion, and coupling. If they come into conflict, I choose the simpler. Most people in my experience don't though; they simply go to one extreme or the other - 10 classes to do the work of one, or one to do the work of 10.

    5. Re:What has been missing is critical thinking. by gweihir · · Score: 1

      Indeed. Actually understanding the problem and its implications cannot be replaced by anything. There are these managers that think programmers can be replaced by cheap drones that just follow a process. That can and will never work until we have strong AI (and then we might have the problem of how to motivate the AI to work for us....). Just look at more classical engineering, where they often _can_ make the whole thing out of standardized and well known components. Nope, still needs a human being with active intelligence and experience in the loop. Why some people thing programming is easier, is beyond me. If anything, it is much, much harder.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    6. Re:What has been missing is critical thinking. by gweihir · · Score: 1

      There is no silver bullet. There never will be one.

      If you disagree, go read "The mythical man-month". Required reading for anybody that does software, IMO.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  5. Who cares of funny names? by stanlyb · · Score: 1

    Singleton: Some poor language are missing the plain old structures, and did not bother to implement them thread safe BY SPECIFICATION
    Factory: God bless the reflection, and you, yes you man, that forgot to implement it in your little pity language, you go to hell
    Builder: Really? What is next? Every time i write 3 lines of code i have to say that i used 3some pattern???
    ................

    1. Re:Who cares of funny names? by shmlco · · Score: 1

      "Singleton: Some poor language are missing the plain old structures, and did not bother to implement them thread safe BY SPECIFICATION"

      Ah... no. Singletons are typically used as resource managers, like managing a pool of objects, or perhaps controlling access to a hardware resource, where you need to ensure that there's one instance and only one instance.

      It's true that you're more likely to need them in languages that don't implement threads as part of the language syntax, but the flip side of that is that as a developer you're probably not going to be able to dictate your personal language preferences (biases) to every employer and on every project.

      "Builder: Really? What is next? Every time i write 3 lines of code i have to say that i used 3some pattern???"

      You don't have to say anything. Design Patterns simply pointed out that a lot of code tends to be organized into certain patterns, and having an idea of what those patterns are and their associated benefits and tradeoffs may help you write better code.

      Or in your case, at least help you to write adequate code... (grin)

      --
      Any sect, cult, or religion will legislate its creed into law if it acquires the political power to do so.
    2. Re:Who cares of funny names? by Anonymous Coward · · Score: 1

      3some pattern???

      Your ideas are intriguing to me and I wish to subscribe to your newsletter.

    3. Re:Who cares of funny names? by Anonymous Coward · · Score: 0

      So your argument is that languages designed from the lessons learned from older languages are better than the (raw) older languages?

    4. Re:Who cares of funny names? by stanlyb · · Score: 1

      Look at the pity C++. It does not even have a proper reflection implemented? For god sake, it does not even have PREBUILD libraries. Really, what the frack? Why should i have all the templates source code, and why should i have to compile it every time i instantiate one template only!!!
      Callbacks? Thanks god the newest standard c++11 has lambda functions, AT LAST. but when i try to persuade my coworkers to use them, they look at my like alien (in its ET meaning) and keep using the stupid BOOST.
      And no, my argument is that since the boom of the OOP some 15 years ago, a normal sane developer would expect more dynamic and more sane features implemented, instead, we are served with plain, old, gang of four. Let them burn in hell.

  6. Design patterns were the worst thing to happen... by Viol8 · · Score: 1

    Frankly if you hadn't thought up half of them yourself without being told about them then you don't have much talent as a coder but aside from that, all that bringing out a load of books about them did was give no talent coders a method of lego brick programming that usually gives rise to some half arsed semi working inefficient POS that someone who has a clue ends up having to spend months debugging and sorting out other issues. I know I'm coming across as an arrogant snob but since when did programming stop being a profession and start being a free for all for all liberal arts failures who can type a line of C# and suddenly think they're Turing?

  7. The biggest problem with design patterns... by mark-t · · Score: 1

    ... is that they do not scale very well to software that is supposed to be on the cutting edge of what is technologically possible today. When all you think about is in terms of named patterns, then there's a pretty good chance that you're just reinventing stuff that other people have done. Perhaps you are doing it faster, or on a newer platform, but in the end, it's still just reinvention. Real pioneering comes from thinking outside of the box, where nobody else has ever tried exploring before. If all you can do is think in terms of the named patterns that other people have already thought of, then I think that's generally only going to hold you back.

    1. Re:The biggest problem with design patterns... by Anrego · · Score: 3, Insightful

      On the other hand, if you spend all your time re-solving things which have already been solved.. you aren’t going anywhere fast either.

      Ultimately design patterns already existed. Most of the commonly used ones are intuitive enough that most programmers arrived at them on their own. The main purpose served was creating a common vocabulary.

    2. Re:The biggest problem with design patterns... by O('_')O_Bush · · Score: 1

      On the other hand, it is really hard to be cutting edge and innovative when you spend almost all of your time and resources reinventing and maintaining your own versions of the wheel. Design patterns have important uses no matter the area of software, but it takes wisdom to tell the difference when a DP makes sense and when it doesn't.

      --
      while(1) attack(People.Sandy);
    3. Re:The biggest problem with design patterns... by shmlco · · Score: 2

      "Real pioneering comes from thinking outside of the box, where nobody else has ever tried exploring before. If all you can do is think in terms of the named patterns that other people have already thought of, then I think that's generally only going to hold you back."

      Ummm... this smacks of a distain for formal education, which I typically find in people who lack formal education and training.

      Regardless, patterns are simply tools in the box. They're not the ONLY tools in the box.

      --
      Any sect, cult, or religion will legislate its creed into law if it acquires the political power to do so.
    4. Re:The biggest problem with design patterns... by mark-t · · Score: 1

      Well I don't ever pretend to say that being imaginative should *ever* be a substitute for at least being aware of what else is going on around you, or knowing what other have done before. It goes without saying that any good programmer should be very well read. My only concern is that design patterns tend to put programmers, especially newer ones, into boxes that they will have a very hard time learning how to think outside of. They've learned all these terms that have been ingrained into them right from year one in computer science, and all to often, particularly with younger programmers, you see people applying named patterns to some problems for the sake of the pattern itself, rather than because it was really the best way to solve a particular problem. Design patterns, at least to me, come across as a means to sound impressive when discussing your software... like you know all the technical buzzwords, but in the end, they don't actually help you understand how to solve any real problems that programmers have to face.

    5. Re:The biggest problem with design patterns... by mark-t · · Score: 1

      I have no disdain at all for a formal education. But, particularly in computer science, the important thing to take from such an education is learning how to learn... because practically everything concrete that you learned in school will be obsolete before you graduate. Of course you need to learn what other people have done before you so that you don't reinvent the wheel. For what it's worth, I ended up learning about design patterns for one course I took in my last year just before I graduated. They seemed to make a whole lot of sense at the time, but it it took me some number of years after that, and in the real world of corporate software development, before I realized the problems that they bring with them

      Regardless, patterns are simply tools in the box. They're not the ONLY tools in the box.

      I can sort of agree with where you're coming from with this. My experience with younger programmers has often been that they are very eager to point out how they have used such-and-such a design pattern to approach a particular goal, and while that might sound impressive, it leaves one wondering if they had spent as much time thinking about the best way to accomplish the goal as they did finding a way to squeeze the problem into one particular design pattern.

      I am reminded of when I recently had the misfortune of working on a project with another younger programmer who seemed extremely eager to apply design patterns to every stage of the development process, all too often without regard for whether it was the best way to solve a particular problem. I hold him no ill-will in all of this, of course... he was eager, energetic, and very well meaning. But it just seemed that sometimes he was using particular design patterns just for their own sake.

      This experience, unfortunately, is far from unique. Maybe you're right about design patterns being practical... but it strikes me that there's something wrong with how they are being taught to people these days...and I find that teaching them tends to make too many programmers think alike, reducing the variety of creativity that will spring forth from a programming team.

    6. Re:The biggest problem with design patterns... by ratboy666 · · Score: 1

      The biggest problem with design patterns is that they codify repeated constructs.

      And, since we are teaching developers that repeating these constructs by rote is "the right thing to do", there is less call to actually push the problem to where it belongs...

      The language implementation itself.

      If you keep repeating "Factory", "Observer" (whatever), then why wouldn't you want something that can actually represent the concept?

      Reducing the concepts into a (hopefully) smaller set should make this more directly implementable. Or, at least provide the building blocks to permit direct Pattern implementation is a library sense. (although, I have not read the book, nor the thesis, just going by the summary here).

      But, I agree with you. Cutting edge development must take place in uncharted areas, and the use of patterns is "known space". It should be really known space, though, in that the Patterns must be subsumed (like subroutines and I/O libraries). Stressing about Patterns all the time will be... (or should be) wasteful.

      Peter Norvig wrote an interesting article about this:

      http://www.norvig.com/design-patterns/

      (http://norvig.com/bio.html)

      In the article, he shows how 16 of 24 GoF patterns simply disappear, or become considerably less relevant by proper language support.

      However, if the programming community at large insists on weaker languages, we may need to take smaller steps, and the book being reviewed may be a useful step in that direction.

      --
      Just another "Cubible(sic) Joe" 2 17 3061
    7. Re:The biggest problem with design patterns... by shmlco · · Score: 1

      Young and inexperienced programmers often suffer from the "when the only tool you have is a hammer..." mentality. This could be design patterns, or their insistence on using a single language for everything, or for always using a particular platform or framework.

      Regardless, patterns are interesting in that they're largely platform and language agnostic. They're just ways of thinking about a problem, and the true test of using them is knowing when they fit a given situation... and when they don't. Knowing the benefits and the tradeoffs.

      Which comes from experience.

      --
      Any sect, cult, or religion will legislate its creed into law if it acquires the political power to do so.
    8. Re:The biggest problem with design patterns... by Jason+Smith · · Score: 2

      I completely agree. In fact, in the book I show where some languages, such as C#, have started implementing some of these EDPs as basic primitives. I also show how these ideas are implemented in a number of languages (Java, C++, C#, Obj-C, Python, even straight C in a couple of cases) to demonstrate how the language feature set can radically change how you choose to implement a concept.

      Ultimately, that's what design patterns are: concepts. How they get implemented is unique to a language, a problem domain, and a set of constraints and requirements you're working with.

      Change the language expressibility, and you change how you can approach the concepts.

    9. Re:The biggest problem with design patterns... by Anonymous Coward · · Score: 0

      common vocabulary? oh please. that's like agreeing on...

      tabs vs spaces, do "blank lines" contain a semicolon
      to polish or not to polish, prepending s or _ to local / static variables, m for member variables
      mixed case variable names or word separated with _

      all said a waste of time.

    10. Re:The biggest problem with design patterns... by Jason+Smith · · Score: 2

      *Absolutely*. To me, one of the biggest wins of design patterns is that they let me quickly solve, describe, or *avoid* problems that others have solved, described, and found ways around.

      In fact, the material for the book came from my research in creating a system for the automated detection of design patterns in source code. It was originally intended to find the patterns to help document the system, but it quickly became obvious that the biggest benefit was that it defined the sections of the system that *didn't* need documentation. Other people had already done so. Instead, it let the developers concentrate on the portions of their code that were unique to their implementation. i.e., their innovation.

      I find patterns to be incredibly useful, obviously, but they are often most useful not for what they define, but what they *don't*. The negative space of the system, once it is seen as a system of patterns, is where the real fun starts.

    11. Re:The biggest problem with design patterns... by not-my-real-name · · Score: 1

      How can you think outside of the box when you don't know where the box is?

      --
      un-ALTERED reproduction and dissimination of this IMPORTANT information is ENCOURAGED
    12. Re:The biggest problem with design patterns... by mark-t · · Score: 1

      You don't need to know where the box is to think outside of it. In fact, the less you know about the box, the easier it *IS* to think outside of it.

      But don't misinterpret that as any sort of indicator that I don't value a conventional education. It's important to learn what other people have done in the field so that you don't unessarily reinvent the wheel.

      My experience with people who have been "raised up" using design patterns is that they mostly tend to think very similarly in how they would approach a given problem. While this might seem to be helpful in terms of everybody on a programming team working in a consistent style, the problem I've found is that the lack of diversity tends to, more often than not, lead to suboptimal solutions, because different ideas aren't considered and weighed out.

    13. Re:The biggest problem with design patterns... by liquiddark · · Score: 1

      You don't need to know where the box is to think outside of it. In fact, the less you know about the box, the easier it *IS* to think outside of it.

      This is so wrong it hurts.

    14. Re:The biggest problem with design patterns... by Anonymous Coward · · Score: 0

      Do you also write C++ like it was C?
      Design patterns solve ALOT of the real problems that programmers have to face. Not everything, but really most things. Yes, you still have to know how to implement the patterns.

      The problem is most people try to stuff the design problem they have into the pattern examples they have seen, rather than applying the principle of the pattern to the design problem they have. The same is true in every other field, nothing is ever really "textbook".

  8. Re:Design patterns were the worst thing to happen. by Anrego · · Score: 5, Insightful

    Design patterns served the purpose of giving names to the things that as you said, most coders already came up with. When I say strategy, or observer, or behavior, or singleton .. everyone knows what the hell I'm talking about.

    I know I'm coming across as an arrogant snob but since when did programming stop being a profession and start being a free for all for all liberal arts failures who can type a line of C# and suddenly think they're Turing?

    When we did what we do with everything.. made it easier. It's the natural progression. People said "hey, this is hard.. if we did it this way, it'll be less hard". Rinse and repeat. There's still hard stuff out there, but it's not common _because_ the common stuff has been made easy. If you want to be challanged, get a job doing something weird that hasn't benefited years of people doing the same thing and improving the process.

  9. Re:Design patterns were the worst thing to happen. by Viol8 · · Score: 1

    "If you want to be challanged, get a job doing something weird that hasn't benefited years of people doing the same thing and improving the process."

    Its not about me being challenged - I can do that with my own homebrew projects. What worries me is amateurs getting into coding positions and writing appalling code that probably ends up costing a lot more in the long run that if they'd hired people who had a clue. When Boeing or Airbus wants to build a new plane they don't hire some kid who's good folding paper aircraft, they hire proper engineers. I don't understand why IT should be treated so differently. Just because almost anyone can write a hello world program doesn't mean almost anyone should be allowed to work in programming.

  10. patterns and idiots by Anonymous Coward · · Score: 0

    From my experience familiarity of DP usually ends at singleton and factory. Idiots absolutely insist on writing as many as possible. More advanced idiots include command to the list and insist on replacing function calls with them.

    1. Re:patterns and idiots by Anonymous Coward · · Score: 0

      If I see anyone use the goddamn singleton (simpleton?) pattern again I'm gonna go ballistic. I just got done refaptoring a project where damn near every class was a simpleton. I don't understand why the pattern exists at all. It's exactly like having a global object, except it gets allocated at some random-ass point in the runtime and it lives on the heap instead of the static block (because the heap never gets corrupted or anything when you're trying to debug a crash, oh no sir!).

      Look, if you want to use a global object, if it's really necessary, hey go for it. Don't "singleton".

  11. Re:Design patterns were the worst thing to happen. by Anonymous Coward · · Score: 0

    It was stated already but it really has to be reinforced, "patterns" are names or common practises in modern programming, a common parlance.

    I don't have to show you what a factory pattern is, you either know it or you can look it up.

    Whether or not "pattern use" is effective is solely on the shoulders of the programmers that employ them.

  12. In defense of Patterns by DrEasy · · Score: 1

    Yes, patterns often are needed due to the inflexibility of your programming language of choice (erm, Java), and yes, when you first learn about them you tend to use them everywhere and over-engineer things to death (guilty!). BUT, with some experience you realize that it's the idea behind them that is important. Especially if you're using some agile methodology, you basically only end up with patterns or a piece thereof as a result of some refactoring (see Joshua Kerievsky's excellent book on the subject), and you should also be ready to move away from them as soon as you realize you don't need them. Patterns provide a direction, but they're not necessarily an end goal.

    I haven't read this new book, but breaking down patterns into smaller, more fundamental chunks could be very useful in that "refactoring toward patterns" attitude.

    --
    "In our tactical decisions, we are operating contrary to our strategic interest."
    1. Re:In defense of Patterns by DragonWriter · · Score: 2

      Yes, patterns often are needed due to the inflexibility of your programming language of choice

      Patterns, qua patterns, are only needed due to inflexibility of the programming language. With a sufficiently-flexible programming language, any given "pattern" is instead a piece of library code that needs written once, rather than a template that needs to be reimplemented each time it is used.

      Of course, real programming languages aren't perfectly flexible, so any real programming language is going to have patterns that are useful -- but which patterns is going to vary based on the limitations of the particularl language.

  13. Re:Design patterns were the worst thing to happen. by Anrego · · Score: 1

    It's actually an interesting topic.. because while newer languages and toolstacks have lowered the bar.. they've also made the cost of failure lower.

    You can be a complete knuckhead.. and write absolutely terrible code. But if your using java.. it'll still probably work and after a while of hacking out the bugs (with more ugly code) it'll attain a surprising stability.

    More relevant is this thought that better code will translate into the dollars and cents everyone else seems so concerned with. Sometimes it does, sometimes it doesn't. We get cheap coders because analysis of the business case shows you save more from the cheapness of the coders than you lose from the crumbiness of the software. If it was the other way around, most businesses would knock it off and up their standards.

    Good jobs where they care about the skillset and are willing to pay for it do exist in industries where bad software costs a metric fuck-tonne (industries like defense, aerospace, medical) but it's no longer the norm for stuff where it doesn't.

  14. Them templates in languages with no reader macros by Anonymous Coward · · Score: 0

    The main issue with most "design patterns" is that they are exactly that: templates.

    Yet they're needed, and that's the real sad thing: "good" projects do use them and there's a lot of incredibly repetitive code made of decorators, abstract factories, "fluent interfaces" (not really a "design pattern" but the issue is the same).

    And that's because C# / C++ / Java are "the industry norm" or whatever. Nobody wants to use parentheses:

    (decorate (wrap-subject) xxx)

    That's too hard. There are parentheses you see: people prefer to write the same templates all over C# / C++ / Java code.

    Design patterns are one thing: workarounds for C# / C++ / Java / Objective-C defects.

    When you program in a Lisp dialect, like, say, Clojure (to name one Lisp dialect who's gaining a lot of traction lately) you can burn 400 of the 600 pages of the original GoF book.

    Back in the days, when I read the GoF I thought it was cool, amazing, etc.

    Now I' beginning to think there may be other ways because "templates" leading to extreme repetition all over a codebase --and, worse, realizing that this is actually the "less worse" you can do in such languages-- may not be the only way...

  15. Re:Design patterns were the worst thing to happen. by plopez · · Score: 1

    "I know I'm coming across as an arrogant snob but since when did programming stop being a profession and start being a free for all for all liberal arts failures who can type a line of C# and suddenly think they're Turing?"

    I was in the business for a long time and it has been going on since time imemorable. Which is one reason I quit, we seem to never learn. And just as bad after 15 or so years in the business when you have learned your are considered to old and get thrown away. One of the other reasons I quit.

    --
    putting the 'B' in LGBTQ+
  16. Interesting theory, but is it practical by ndykman · · Score: 1

    The underlying concept isn't as hard as the review makes it sound. Using some formalisms, the author creates a set of blocks upon which you can build patterns like those in the Gang of Four book. By doing so, you can see what commonalities occur and hopefully, this leads to deeper insight into what patterns really are.

    The review mentions some detection of patterns in "legacy code" but the idea of refactoring the code to better support those concepts that is mentioned in the review seems too vague to me.

    There was a good book on how you could use refactoring to implement design patterns in existing code, but it wasn't as grounded on theory and automation as refactoring itself. The theory mentioned is this work could maybe serve as a foundation for such an idea.

    If this sparks a new set of tools that help automate the redesign of code to follow better practices, that'd be really great. But, I think there is still some real work left to be done before that happens. And while it remains to be seen, the formalism applied could reap great benefits in that regard.

    1. Re:Interesting theory, but is it practical by Jason+Smith · · Score: 2

      Do you by any chance mean Kerievsky's _Refactoring to Patterns_? Have a well-work copy on my desk, and between that and Fowler's _Refactoring_, I see a fairly clear path from the EDPs to patterns-based refactoring.

      It was one of the use cases, after all. :)

  17. Re:Design patterns were the worst thing to happen. by Anonymous Coward · · Score: 0

    Come over to the hardware side. People are a lot more thorough when it costs several million dollars and three months to run the compiler.

  18. Re:Design patterns were the worst thing to happen. by shmlco · · Score: 1

    "When Boeing or Airbus wants to build a new plane they don't hire some kid who's good folding paper aircraft, they hire proper engineers."

    When I need to have the brakes fixed on my car, an aerospace engineer would be overkill.

    For adding a few customization features and pages to a WordPress installation, a PHP guy with a year or so's worth of experience is probably all most people need. Or can afford, for that matter.

    --
    Any sect, cult, or religion will legislate its creed into law if it acquires the political power to do so.
  19. Show me on increase in ROI due to "Patterns" by Anonymous Coward · · Score: 0

    Just one. Verifiable from a third disinterested party.

    On the other hand, I can think of at least one case where patterns thoroughly fucked up what might otherwise have been a useful thing (i.e. Microsoft's UI Automation). The dimwitted, heavy-handed attempt at jamming otherwise perfectly understandable user interface categories into "patterns" is painful to read and far more difficult to program than it needs to be. I don't need "patterns" to click an OK button. I need an interface path [my.exe].dialog.tab.controlobject (e.g. objButton) and a method ("Click"). That's all. That's useful. I don't need "SelectionPattern" or "InvokePattern" or any other productivity sapping nonsense imposed by a business-impaired, 20-something with a brainwave. Wrapping that crap into useful, understandably named member functions is the first thing you have to do to make UI Automation even vaguely useful.

  20. That is why I wonder if patterns are useful by SuperKendall · · Score: 1

    Alternatively you have implemented additional design patterns without knowing it.

    I'm sure that he has.

    The reason is that a lot of the classical design patterns are such obviously good ways of doing things, that good programmers use them naturally even without knowing or reading about them before.

    That leads me to wonder, how useful are design patterns really? In the end what they really seem to be, is simply a way to communicate a good way of building software to people who do not intuit the use of these things naturally.

    The real question is do they work for that task? After many years of experience working with programmers of many different levels, I do not think they achieve that goal. Programmers who do not naturally grasp all of the things the patterns try to teach do not end up building better software with some understanding of the patterns. Instead they end up with a slightly pattern based mess, sometimes with patterns that are not really used as they are meant to be, sometimes with a horrendous number of patterns stuck together to make a bloated monster.

    Do many people really feel like they learned much from careful studies of pattern books? I went through a couple in CS course in college based around patterns but honestly I never felt like I learned anything I would not have simply come across on my own (and as you note, indeed I had been using many of the patterns without having known the "official" names).

    One could also claim that for advanced programmers patterns gives you terms you can use to discuss the structure of software. But even that has been of very limited value in practice, when working with teams of advanced programmers...

    I just can't see that design patterns are nearly as useful to learn for programming as something like algorithms, many of which are not nearly so intuitive a thing that you would discover easily.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
    1. Re:That is why I wonder if patterns are useful by Tyler+Durden · · Score: 1

      God damn but I wish I had mod points for you right now. My sentiments exactly.

      --
      Happy people make bad consumers.
  21. Patterns by Anonymous Coward · · Score: 0

    SO glad to read that others have tired of pattern-overload (along with the associated overarchitecture). I have worked for multiple architects who include facades just for the sake of "fulfilling the pattern" and others whose first order of business is to write a bunch of object factories (uhh, the runtime is usually best for this, since object creation is a core feature) and more facades (even to entity objects!). (then there is the other flavor of architect who sees him/herself as some kind of integrator, piecing together frameworks for every conceivable function and saying it's an application architecture)
    Patterns manifest themselves when you write well-designed code; using patterns is not what makes the code good per se.

  22. Singleton by Chemisor · · Score: 3, Informative

    Well, singleton is useful, if only because it is the only way to implement the application object right. Doing it as a singleton allows access from outside the object, handles constructor exceptions, and ensures the destructor always gets called. Making the app object into anything else is bad:

    If the app object is a global variable, you can not have exceptions in its constructor; terminate always gets called. Also, you do not get to control initialization order, so if you have any other global objects, they may or may not be initialized before it.

    If the app object is a local variable in main, you can not get a pointer to it from anywhere else (and you commonly need to). The second problem is that the destructor will not be called if someone uses exit() (signal handler) or terminate() (some EH problem), causing many problems of resource leaks if the app object is the root of your object tree, as is often the case.

    If the app object is a static variable in main, that solves the exit() problem, but you still need to set a global pointer to access it.

    Making the app object a singleton, first called from main in a try block, avoids all of the above problems.

    1. Re:Singleton by Anonymous Coward · · Score: 1

      Go check out the Google TechTalks about testing on Youtube. It has this gem (paraphrasing): "You all think that global state is bad, right?" then a bit later "You all think that the Singleton pattern is just fine, right?" and then the amusing conclusion "you know that the Singleton pattern is global state, right?" The reason why having the Singleton pattern is bad is exactly because you can get a pointer to it from anywhere. That's the problem. You have no way to control side effects to fields that anyone can access from anywhere with no indication in the calling signature.

      Your testers have to know about the global state that is being depended upon, and they have to set that up correctly, creating many possibilities for one test to impact the next one. If it's a dependency, it gets passed in to the constructor of the object. If you have too many constructor parameters then you have too many dependencies, it's just that making them explicit is making you aware of that instead of having it be a hidden gotcha' for everyone else dealing with that code.

      Singletons are just a slightly better way of doing global state, but it's still global state. If you want cleanup in the face of exit(), you can make a global variable with no public interface that does your cleanup.

  23. Re:Design patterns were the worst thing to happen. by Darinbob · · Score: 1

    The goal is to end up with a POS that has a detailed design, so that when it fails you point to the pile of design docs and say "see, we did all the necessary work, everything's been coded to the design, you'll have to blame someone else". They provide absolution.

  24. What we need... by jholyhead · · Score: 3, Interesting

    ...is a book that assumes you know all of the GoF patterns and gives a list of times when you shouldn't use each one.

    Most people's beef with design patterns is that inexperienced coders sit down and think 'what pattern could I apply to this problem?' or 'how can I change my problem to fit a pattern?' instead of 'what pattern, if any would make this code easier to understand and maintain in the long term?'.

    1. Re:What we need... by AnnoyingCow · · Score: 1

      ...is a book that assumes you know all of the GoF patterns and gives a list of times when you shouldn't use each one.

      That is so true. I think what might help in the original GOF book is to put more emphasis on the "Applicability" and "Consequences" sections in each pattern. Afterall, patterns are just a bunch of trade-offs in design (e.g. the Visitor pattern makes adding new operations easy, but it makes adding new ConcreteElement classes hard), and the trade-offs need to make sense in the problem context for the pattern to be beneficial.

      Something I keep reminding myself is that "complexity is not free", and meanwhile keep trying to understand the true essence of each problem in order to correctly apply the correct balance of "simple design".

    2. Re:What we need... by Anonymous Coward · · Score: 0

      It exists! It's called AntiPatterns

    3. Re:What we need... by Jason+Smith · · Score: 2

      God yes. One of the early examples I saw of this was a Hello World that ran to a couple thousand lines of code, using every conceivable design pattern at once. It was horrendous.

      Engineering is trade-offs, in almost every case. Adding an abstraction to encapsulate a bit of complexity doesn't dodge the fact that under that abstraction you are *adding complexity*. Sometimes the complexity is necessary, and sometimes it is a kludge. Knowing the difference requires understanding what the various underlying concepts you are adding actually mean, how they interact, and what they cost you in terms of implementation or design flexibility given your implementation language, constraints, etc.

      The EDPs are a way of conveying that information about the underpinnings of the current design patterns literature, so that the huge amount of information at our fingertips gets new utility... and hopefully so rising programmers can have a smoother introduction to the literature than we did.

  25. Re:Design patterns were the worst thing to happen. by DragonWriter · · Score: 1

    What worries me is amateurs getting into coding positions and writing appalling code that probably ends up costing a lot more in the long run that if they'd hired people who had a clue.

    The problem, of course, is that lots of people who are hiring programmers also don't have a good ability to detect the ones that have are really skilled -- spending the money that it would cost to get someone that has a clue would often mean they were still getting not-so-good programmers writing needlessly-expensive-to-maintain code, but paying top dollar for it.

    When Boeing or Airbus wants to build a new plane they don't hire some kid who's good folding paper aircraft, they hire proper engineers. I don't understand why IT should be treated so differently.

    Because most IT work doesn't involve the level of risk associated with garden variety moderate deficiencies in competence that aircraft engineering does. (The IT work that does have that level of criticality often has substantially higher standards, and skilled people applying the standards.)

  26. Re:Design patterns were the worst thing to happen. by stretch0611 · · Score: 3, Insightful

    You can be a complete knuckhead.. and write absolutely terrible code. But if your using java.. it'll still probably work and after a while of hacking out the bugs (with more ugly code) it'll attain a surprising stability.

    And with this crap code, people will spend twice the amount of time (or much more time) trying to maintain it or even trying to add a simple enhancement. In addition, the system will be such a piece of crap that it will be short listed for a complete rewrite. A system with well written code does not need a rewrite every 2-3 years... It can last. I have web-based systems that are 10 years now and still do not need a re-write. When a change is requested, it is easy to find the right place to make the modifications and when you go back into a certain block of code, it is easy to understand what the code is doing even if you have not looked at it in over a year. That saves money in the long run, not cheap coders.

    We get cheap coders because analysis of the business case shows you save more from the cheapness of the coders than you lose from the crumbiness of the software.

    Please tell me where you work so I NEVER apply there.

    You get what you pay for, and slop code will always cost more in the long run. In addition, an expensive developer who truly understands what he is doing will code faster and with fewer errors. Depending on how bad of a hack job is done by your cheap coders it may even save money with the initial expense.

    Back in 2002, I was outsourced/offshored. I was one of the first to go because I found a new job immediately and left instead of training my replacement. I spoke with my friends/colleagues that were left behind and the first assignment to the offshore company would have taken me 16 hours to complete. They billed a total of 120 hours for the same work. In addition it went all the way into production and failed miserably with a syntax error... They did not even test it!!!

    Now the outsourcing company actually told us that money was the only reason why we were offshored. They said that the client rate was $90/hour for us and $60/hour for the offshore help. If you do the math, that meant the project cost was $7200 for the cheap coders, instead of $1440 for the expensive developer. Not to mention, I am sure some MBA is telling the executives that their cost saving plan saved the company $3600 on this change alone and that they deserve bonuses when really, they just lost $5760.

    Now how do cheap coders save money?

    --
    Looking for a job?
    Want your resume written professionally?
    DON'T USE TUNAREZ!!!
  27. Re:Design patterns were the worst thing to happen. by Anrego · · Score: 1

    Please tell me where you work so I NEVER apply there.

    For what it's worth I was talking in the general, not my specific case. As it happens I did exactly as I said in my first post after working for a standard issue software mill and getting frustrated by the constant cost cutting and fear of outsourcing. Got into a specialized field where mistakes are expensive and high quality code is worth the price. Experienced coders, formal testing, people who can define the difference between system and software architecture, etc. I'd seriously recommend this to anyone getting fed up of being told "it works, ship it!".

     

    Now how do cheap coders save money?

    I don't pretend to understand how it works, I just have faith that things happen for a reason. Business guy's arn't _that_ stupid (they are generally making money after all). Obviously there are going to be cases where it doesn't work for whatever reason, but I have to assume that since the practice is becoming more universal, it has to have merit. Either way I've washed my hands of the mess.

  28. Thats what I have been waiting for. by StillNeedMoreCoffee · · Score: 1

    Given a design language, the next step is to design a design pattern optimizing compiler, using a set of transforms to reduce canonical forms to optimized merged patterns.

    1. Re:Thats what I have been waiting for. by Jason+Smith · · Score: 1

      I see that as one very useful direction, absolutely. Frankly, this isn't that different than what we do now, in turning a set of concepts of programming (such as data types, functions, and so on) into bits.

      The EDPs form a bridge between the higher-level abstractions of the existing design patterns literature, and language constructs. From there, it's turtles all the way down. :)

  29. Fuck Patterns by Azure+Flash · · Score: 1

    When I was studying in computer programming, there was a whole course about just UML and patterns (it was called Software Analysis I think). The whole subject was extremely efficient at inducing analysis paralysis, it was boring as hell, the software we used to draw UML diagrams was shit, and it almost killed my ability to code. My advice (as a very non-professional coder, but a knowledgeable enthusiast nonetheless - take this for what it's worth) is to just stick to well-defined use cases, good documentation and tests if you're in a big project. Fuck patterns.

    1. Re:Fuck Patterns by jholyhead · · Score: 1

      Fine if you're doing Mickey Mouse projects, but if you have to maintain a code base with a few hundred thousand LoC, you'll be glad to see code structures you recognise.

  30. The singleton in reality by SuperKendall · · Score: 1

    The reason why having the Singleton pattern is bad is exactly because you can get a pointer to it from anywhere. That's the problem. You have no way to control side effects to fields that anyone can access from anywhere with no indication in the calling signature.

    Except that the dire warning has no teeth, because mostly singletons are used to access resources that generally are not changing during the life of the application.

    People are told simply that singletons are bad, without considering there are a lot of uses for singletons that are not bad in that way at all.

    Furthermore I challenge the notion that code elsewhere changing a singleton value is at all bad for testing - you simply need to model possible changes in the singleton and have whatever code is being tested react to that. Who cares if it's other code or the test harness changing values? It's all testing the code.

    If singletons are not abused they can be a very helpful resource, and to if I had to choose between testing and singletons in terms of getting better code together, I'd choose singletons because of the flexibility they give you.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
    1. Re:The singleton in reality by angel'o'sphere · · Score: 1

      Singletons don't give you flexibility. They lock you in. You can not make a derived class from them, you can not instanciate more than one object from them. You need a global access method to use them (or do you do the mistake and use the global variable directly? If so you can not even change the instance 'behind the scene' because references to the old instane might linger around) ...
      Sooner or later you will have singletons refering to other sinletons and in my eyes this will become a great mess.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    2. Re:The singleton in reality by SuperKendall · · Score: 1

      In decades of software development this has simply not been a problem. A singleton is something you do not inherently NEED to subclass, or have more instances of - because having one instance is the whole point!

      Generally I've not had much cross-talk between singletons, because they end up being edge nodes representing resources used across an application by the many class instances that make up an application.

      Yes, I always use a global access method to get the instance... yet another reason they are no danger to testing as you can always have those methods return a new instance for test harnesses.

      --
      "There is more worth loving than we have strength to love." - Brian Jay Stanley
    3. Re:The singleton in reality by Mr+Z · · Score: 1

      Nearly every program uses a singleton whether they realize it or not: the heap, or global store, or whatever you want to call the well that 'new' and 'malloc' dip their metaphorical buckets in.

      I use singletons in applications where I have either a static resource pool that I need to manage, or the application itself is statically allocated. Now, I don't use singletons much or at all on "workstation" applications.

      Where I use them mostly is in embedded environments where the specific configuration of the system is largely static and can be mostly resolved at compile time. In those cases, there's very little value to blowing a bunch of cycles at startup building objects to represent the system, when I could have precomputed all that at compile time.

      Example: The buffer allocation manager? DMA channel allocation manager? Singletons with static initializer arrays that I could even link in ROM if necessary. Likewise for many other resources. This has the advantage of pushing that cost off to software integration time and compile time. As I said elsewhere in a post, my code has to run more places than on a board. It also has to run in design simulations that run amazingly slow (1ms could be 8-10 hours of sim time).

      They definitely have their purpose, and I prefer their encapsulation to bare globals. But, in the common situations that most people will encounter, the singleton isn't very common at all.

    4. Re:The singleton in reality by angel'o'sphere · · Score: 1

      My point is that you only make singleton when want that there is only one single instance. In other words: having more than one would cause harm. If having more than one is not causing any harm, having a singleton is wrong.
      Regarding subclassing: the question is not if you need to, the question is if you want to. Having two very similar applications but being forced to duplicate code because the older one uses this particular code via a singleton seems pretty stupid.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    5. Re:The singleton in reality by SuperKendall · · Score: 1

      But, in the common situations that most people will encounter, the singleton isn't very common at all.

      That is not true at all. In every language I have worked in, I have had cause to have something like a singleton at times.

      In my most recent work as an iOS developer the system itself has a number of singletons core to applications - the application object itself is a singleton, as are a number of other resource management classes like the class to save default values, or a class to get information about the current hardware.

      --
      "There is more worth loving than we have strength to love." - Brian Jay Stanley
    6. Re:The singleton in reality by Mr+Z · · Score: 1

      I should have phrased that differently. After all, I started off my comment with: "Nearly every program uses a singleton whether they realize it or not". And, the examples you cite are great examples.

      What I was really trying to get at was that unless you're writing the low level resource managers yourself (as I was), it's uncommon to need to write new classes that are explicitly singleton (along with all the trappings of adding multiple-creation avoidance, etc.). Central resource managers and the top-level object that encapsulates your program may be singletons, but it's much less common to need to write additional explicit singletons as part of your application.

  31. Re:Design patterns were the worst thing to happen. by chthon · · Score: 1

    +5 Insightful

    The barrier to entry in programming is very low, but that does not mean that programming is simple and/or easy.

  32. Re:Design patterns were the worst thing to happen. by chthon · · Score: 1

    +1 Cynical

  33. Re:Design patterns were the worst thing to happen. by alexo · · Score: 1

    Design patterns served the purpose of giving names to the things that as you said, most coders already came up with. When I say strategy, or observer, or behavior, or singleton .. everyone knows what the hell I'm talking about.

    When I was young(er), we had just one name for almost all of the design patterns: "another level of indirection".

  34. Google's C++ coding standards by Required+Snark · · Score: 1
    Take a look at the coding style standards for C++ at Google. They contradict much typical practice in the C++ world, http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml

    Classes Classes are the fundamental unit of code in C++. Naturally, we use them extensively. This section lists the main dos and don'ts you should follow when writing a class.

    Doing Work in Constructors In general, constructors should merely set member variables to their initial values. Any complex initialization should go in an explicit Init() method.

    Default Constructors You must define a default constructor if your class defines member variables and has no other constructors. Otherwise the compiler will do it for you, badly.

    Explicit Constructors Use the C++ keyword explicit for constructors with one argument.

    Copy Constructors Provide a copy constructor and assignment operator only when necessary. Otherwise, disable them with DISALLOW_COPY_AND_ASSIGN.

    Structs vs. Classes Use a struct only for passive objects that carry data; everything else is a class.

    Inheritance Composition is often more appropriate than inheritance. When using inheritance, make it public.

    Multiple Inheritance Only very rarely is multiple implementation inheritance actually useful. We allow multiple inheritance only when at most one of the base classes has an implementation; all other base classes must be pure interface classes tagged with the Interface suffix.

    Interfaces Classes that satisfy certain conditions are allowed, but not required, to end with an Interface suffix.

    Operator Overloading Do not overload operators except in rare, special circumstances.

    I am particularly struck by the depreciation of inheritance and the promotion of composition (has a rather ithen is a). This is a design decision I very much indorse, and I have done so over the course of many years. It has caused me trouble, because C++ code geeks think that if you are not using inheritance, you are doing a bad job. They're wrong. I know that I even was not hired on a couple of occasions because I expressed this opinion. I was very pleased when I saw that Google uses the same strategy.

    --
    Why is Snark Required?
    1. Re:Google's C++ coding standards by angel'o'sphere · · Score: 1

      Well, having an explicit "init()" method means they don't understand what the constructor is ment for. Lazy as I am, the first thing I would do is: writing a factory method that uses the constructor and calls init().
      MI ... well, perhaps google for taligent and the frameworks they built.
      Fact is, most people (especially those defining rules like the ones above) don't know how to use MI efficiently, so they abolish it.
      Abolishing a certain set of features (or restricting their usage) of your programming language can only make you less productive.
      Suppose you would write a novel, now you may no longer use passive costructs or simple past tense. That would be a challange :)

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  35. Re:Design patterns were the worst thing to happen. by Anonymous Coward · · Score: 0

    I know I'm coming across as an arrogant snob but since when did programming stop being a profession and start being a free for all for all liberal arts failures who can type a line of C# and suddenly think they're Turing?

    In my experience (from somebody who was a Liberal Arts major before I studied programming); it is far easier for a Liberal Arts major to learn computer programming than it is for a computer programmer to acquire critical thinking skills.

    And no you don't come across as arrogant; just stupid. I hope your day job isn't programming, because even though programming is nothing more than a simple craft that anybody can learn, it does take a certain level of intelligence to produce something that is worth-while.

  36. Know why, and know why not by Tablizer · · Score: 1

    The biggest problem with the pattern movement is that little attempt has been made to document both the upsides AND the downsides of each and to compare and contrast in practical terms, especially from the view of likely future changes. Designing technology is largely about managing and weighing tradeoffs.

    If you cannot explain clearly why you picked pattern/technique A over pattern/technique B or C etc., then you probably don't know what the hell you are doing. "I did it because it looked so cool in the book" is NOT a real reason.

  37. Re:Design patterns were the worst thing to happen. by Viol8 · · Score: 1

    "In my experience (from somebody who was a Liberal Arts major before I studied programming); it is far easier for a Liberal Arts major to learn computer programming than it is for a computer programmer to acquire critical thinking skills."

    LOL! :o)

    Ah , I do like trolls. LIberal arts doesn't involve thinking - ie problem solving - its just memory. A parrot could do it.

  38. Re:Design patterns were the worst thing to happen. by Anonymous Coward · · Score: 0

    I know I'm coming across as an arrogant snob

    No, you're coming across as an pretentious uninformed hack that draws overly broad conclusions.