Design patterns have (mostly) flopped



  • @Shortjob said:

    Everybody: To be honest, I am quite shocked about what transpired in this thread. Especially in regard to what design patterns are. I think we're on the same page regarding their usage: Implement X solve Y. But that's not the whole story. Every pattern just solves a specific class of problems and sadly, only few problems fall in such a class. The larger part of daily coding cannot be properly solved with patterns alone.  I think the comparison to "Lego" is dangerously inaccurate. If we already had figured out how to create programs by stacking blocks, do you really think we'd be grinding our asses with programming?
    And lastly, patterns are only useful during one stage: when planning the implementation. Most patterns require knowledge of the interfaces consumed by your app or provided internally. Likewise, some patterns do nothing but providing an interface (Iterator). Sometimes they are bound to a specific requirement, functional ("App is a service" => Singleton) or data ("App stores 5 mil highly redundant objects in mem" => Flyweight+Factory).

    I guess I could go on, but seriously </rant>

     

    You just about said exactly what I was thinking when reading this thread again.  


     



  • @RHuckster said:

    Patterns work on a large scale, like a framework, but they also work on small scales like implementing asynchronous initialization within a class.

     I love making my classes do background initialization.  There is a certain elegance in calling EndInitialize as the first real line of code in most other public members of the same class, while also allowing your user-programmer to choose synchronous initialization (by calling EndInitialize at the end of BeginInitialize if the Asynchronous parameter is false).

     The bitch I'm having right now is this:

    I have an enumerable factory class that creates delegatee objects to carry out each part of the job.  When the factory is done initializing (in the background, of course) it raises the Initialized event, which carries among other things the number of delegatees it created.

    Each delegatee also raises an Initialized event (optionally hooked up to one handler by way of the factory's own constructor) when it has finished initializing (each one in its own thread).

    Now I am handling the factory's Initialized event (which carries int DelegateeCount) to set ProgressBar.Maximum on a form.  The delegatee's raise their little Initialized events, too, each one of which is handled to increment ProgressBar.Value.

    Unfortunately, delegatee #1 finishes initializing long before the factory is done manufacturing its siblings (even when they all initialize in background threads), so it increments the progress bar before Maximum is set, resulting in Value > Maximum which throws an exception and causes ProgressBar never to reach 100%.

    But happily, there is yet another design pattern for fixing that problem...



  • Trolling or not?

    Hoodaticus, are you trolling or serious? I really can't tell the tone of your message and I doubt I'm the only one.


  • 🚽 Regular

     Hoodaticus, thank you for that. I've been working on something myself tonight which I thought I might be starting to overengineer until I read your post. Reading that put things in perspective and now, I feel assured that I'm not overengineering anything.



  • @Super Coders Website said:

    .applyForJob();

    foreach ([coders, web developers,
    software developers, programmers,
    software engineers, computer scientists])
    if (you're passionate about software development &&
    software development is more than 'just a job' &&
    you want to work where your talent is valued) {
    we'd like you to apply ;
    send your resume to apply for job ;

    }
     
    I hate stuff like this


  • @RTapeLoadingError said:

    I hate stuff like this
    Join the club

       foreach(Person patronizingPrick in World.Marketing.Employees) {

            Intestines bowels = patronizingPrick.disembowel();

            Kill.Hang(patronizingPrick, bowels);

        }

        MessageBox.Show("The world is free!");

    (I've been learning C#)



  • @RTapeLoadingError said:

    @Super Coders Website said:

    .applyForJob();

    foreach ([coders, web developers,
    software developers, programmers,
    software engineers, computer scientists])
    if (you're passionate about software development &&
    software development is more than 'just a job' &&
    you want to work where your talent is valued) {
    we'd like you to apply ;
    send your resume to apply for job ;

    }
     
    I hate stuff like this

    So they are asking for people who are either good at lying, or green enough that they don't know how much boring repetitive work the average programmer is subjected to.



  • @Gazzonyx said:

    Hoodaticus, are you trolling or serious?

     

    False dichotomy.  He could also be joking.  I personally love this type of subtle satire.



  • @frits said:

    @Gazzonyx said:

    Hoodaticus, are you trolling or serious?

     

    False dichotomy.  He could also be joking.  I personally love this type of subtle satire.

    +1 on all you said.

    Can I call you patates?



  • While we're on the subject of bad website designs, here's this one: [url]http://www.liblfds.org/[/url]

    <td onclick="javascript:change_page('wikipedia_and_documentation');" id="tab_wikipedia_and_documentation" class="td_link_selected">Wikipedia&nbsp;&amp;<br>Documentation</td>

    JavaScript-based navigation without any possible degradation? Seriously? At badly done, at that.

    Also, they call their wiki.. Wikipedia.  WTF?



  • @Zecc said:

    Also, they call their wiki.. Wikipedia.  WTF?
     

    They're new to the interweps.



  • @Zecc said:

    Can I call you patates?

    Absolutely. 

     I've also been known as Vlad the Poutines, "Latkes, YUM!", tater tots, and other examples of fried goodness.



  • @dhromed said:

    @Zecc said:

    Also, they call their wiki.. Wikipedia.  WTF?
     

    They're new to the interweps.


    Dhromed, they're intarwebs. Don't let everyone know we're n00bs. We're R teh 13370rZ



  • @DOA said:

    (I've been learning C#)

     

    MessageBox.Show() - that's so 1995 ;-)



  • Most jobs are not glamorous (I use most although I don't know of any that is glamorous for completeness).  If an accurate description of every job was provided then no one would work at all.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    For a world without lies (aka marketing) watch "The World's first lie".

    Regards



  • @dhromed said:

    @Zecc said:

    Also, they call their wiki.. Wikipedia.  WTF?
     

    They're new to the interweps.

    From my experience, most people refer to Wikipedia as just "wiki." But I've never heard of anybody doing it the other way around.



  • @blakeyrat said:

    rom my experience, most people refer to Wikipedia as just "wiki." But I've never heard of anybody doing it the other way around.
     

    That's weird, because the error of calling any wiki Wikipedia would be in line with the other group/item confusion as seen with Adobe, Microsoft, and the companies that make them.



  • @eBusiness said:

    @boomzilla said:

    Learning them [b]from a book[/b] can shorten the process
    And it can block out all alternatives if such a concept is taught too early in a programmers life. The article pretty much states "you are too dumb to make a design on your own, so use a pattern made by a smart person, sucker". If you manage to teach that mentality to someone then they are bound to become cargo cult programmers of the most horrible kind, simply because they are afraid of thinking for themselves.

    Universities all over the world are spewing out object oriented zealots, 'cause that is the right way to code, and any book that says different is heresy. As great as the object oriented way may be, it is not healthy to know nothing else.

     

     

    from a book is the best way to learn anything because the results are often hilarious.

     

     



  • Design patterns are overrated anyway.  Mostly they are hacks used to work around the glaring limitations in mainstream languages.  For example, most uses of Visitor are really compensating for the lack of multimethods.  Iterator is only useful in languages that lack higher-order functions.  Singleton is rarely useful at all, which is why it's the only pattern most programmers can name (though most of them can't implement it correctly).  Etc.


  • 🚽 Regular

     @Iago said:

    Design patterns are overrated anyway.  Mostly they are hacks used to work around the glaring limitations in mainstream languages.  For example, most uses of Visitor are really compensating for the lack of multimethods.  Iterator is only useful in languages that lack higher-order functions.  Singleton is rarely useful at all, which is why it's the only pattern most programmers can name (though most of them can't implement it correctly).  Etc.

    [Gritting teeth]

    must... not... feed... the... troll...



  • Fail



  • @The Troll said:

    must... not... feed... the... troll...



  • @dhromed said:

    @Zecc said:

    Also, they call their wiki.. Wikipedia.  WTF?
     

    They're new to the interweps.

    It's a *lock-free data-structure library*, but the author is new to the Internet?

    It's a solar powered carbon fibre body car, but the designer is new to roads?




  • @Zecc said:

    While we're on the subject of bad website designs, here's this one: http://www.liblfds.org/

    <td onclick="javascriptchange_page('wikipedia_and_documentation');" id="tab_wikipedia_and_documentation" class="td_link_selected">Wikipedia&nbsp;&amp;<br>Documentation</td>

    JavaScript-based navigation without any possible degradation? Seriously? At badly done, at that.

    I thought about making it so if the page was loaded without JS, you'd have plain text telling you JS is required, but I've not actually done it.

    My priority was to get a site up through which I could publish the library.  The site itself is not my primary concern; of the time I have, most of it goes into the library.  Having a beautiful site with a medocre library isn't very useful; almost all people can access a browser supporting JS and much as I could spend time dealing with the situation where JS is disabled, I could OTOH just require it to be active.

    Also, they call their wiki.. Wikipedia.  WTF?

    The Wikipedia is about the only Wiki I use, and I've done enough editing over the years to have come to think of Wiki's in general as Wikipedias.  A mis-learning.  Someone else pointed this out as well.  Unfortunately, for all the people who have provided feedback about the web-site, only -one- person has had the time and necessary competencies to provide useful feedback on the actual code in the library itself.


     



  • It's rare that we can discuss both sides of a situation when the original perp shows up for a few words. Wilkommen!

    @liblfds_admin said:

    I thought about making it so if the page was loaded without JS, you'd have plain text telling you JS is required, but I've not actually done it.
     

    Have you considered using links? If so, what requirement made you reject them? I imagine that setting up the XML HTTP Request was more work than doing it neatly with some server-side includes for the header.



  • @liblfds_admin said:

    It's a solar powered carbon fibre body car, but the designer is new to roads?
     

    Well, apparently.

    I wouldn't trust an engineer claiming to have built such a device if he didn't possess knowledge of infrastructure. It probably wouldn't even have wheels.



  • @Zecc said:

    While we're on the subject of bad website designs, here's this one: http://www.liblfds.org/

    <td onclick="javascriptchange_page('wikipedia_and_documentation');" id="tab_wikipedia_and_documentation" class="td_link_selected">Wikipedia&nbsp;&amp;<br>Documentation</td>

    JavaScript-based navigation without any possible degradation? Seriously? At badly done, at that.

    You haven't seen nothing 'till you have seen what the javascriptchange_page function actually does, without further investigation one would think it is just a wrapper for changing the src of an iframe, but it will actually load the content asynchronously and insert it into the page using innerHTML. But the best part is what is actually inserted:

    <iframe src="/wikipedia/index.php" height="100%" width="100%"></iframe>



  • @dhromed said:

    It's rare that we can discuss both sides of a situation when the original perp shows up for a few words. Wilkommen!

    @liblfds_admin said:

    I thought about making it so if the page was loaded without JS, you'd have plain text telling you JS is required, but I've not actually done it.
     

    Have you considered using links? If so, what requirement made you reject them? I imagine that setting up the XML HTTP Request was more work than doing it neatly with some server-side includes for the header.

     

    Originally, the design was to have a seamless page - no IFRAME, but rather, load the given page into a placeholder element in the main page.

    Unfortunately, having implemented that, I then realised that the Wiki, forum and blog of course all generate full-page HTML - you cannot load that into a placeholder element - you need an IFRAME.

    So the target became the IFRAME rather than what was before a placeholder element.  That's why there's a JS based page load mechanism which is actually only doing what an <A> with a TARGET would do.

    (Also, I had all the code for the XMLHTTPRequest from previous work.  It was pure code reuse).



  • @liblfds_admin said:

    My priority was to get a site up through which I could publish the library.  The site itself is not my primary concern; of the time I have, most of it goes into the library.  Having a beautiful site with a medocre library isn't very useful; almost all people can access a browser supporting JS and much as I could spend time dealing with the situation where JS is disabled, I could OTOH just require it to be active.
    Of course. I can appreciate this. But as it has been said, it would have been much easier to just use plain links.

    Look.. My main gripe with your website is that it prevents basic browser functionality; namely opening new tabs and using the Back button. It's terribly annoying.

     



  • @Zecc said:

    But as it has been said, it would have been much easier to just use plain links.
     

    For a one-off, it probably understandable to not do the extra work to convert it all back to links proper after it's all been set up once.

     

    So.

     

    Sandwiches. Who likes 'em?



  • @dhromed said:

    Sandwiches. Who likes 'em?
    Sandwiches are great, but I never know what kind to make. Do you have some patterns for constructing sandwiches?



  • @dhromed said:

    For a one-off, it probably understandable to not do the extra work to convert it all back to links proper after it's all been set up once.
    Yes, I later read how it was code reuse. I feel relieved knowing this is bad design by lack of time and not by ignorance.

    @Enterprise Architect said:

    Sandwhiches are great, but I never know what kind I want to make. Do you have some patterns for constructing sandwiches?
    I like to not cut the bread all the way through, as to avoid the spilling the contents of the sandwich when I hold it. I also like to make miniature sandwhiches by lodging a biscuit between two slices of cheese, or wrapping it inside a single thin slice of cheese.





  • @liblfds_admin said:

    Originally, the design was to have a seamless page - no IFRAME, but rather, load the given page into a placeholder element in the main page.

    Unfortunately, having implemented that, I then realised that the Wiki, forum and blog of course all generate full-page HTML - you cannot load that into a placeholder element - you need an IFRAME.

    So the target became the IFRAME rather than what was before a placeholder element.  That's why there's a JS based page load mechanism which is actually only doing what an <A> with a TARGET would do.

    (Also, I had all the code for the XMLHTTPRequest from previous work.  It was pure code reuse).

    I'm going to post the same thing at you that I posted at the Debian project on Slashdot yesterday. (It was pouring down rain. My friends are out of town. Shuddup!)

    To wit:


    If you can't get your shit together on the website, which is frankly pretty damned easy, why should your users believe you have your shit together on the vastly more complicated code library?

    Usability matters.

    Now that all said, your website is still better than Debian's. And they have hundreds of people in their project, not just one. I thought I should put that up in the actual post, since tags get removed from time to time. Not trying to pick on you personally, just making a point.



  • @frits said:

    @RHuckster said:

     @frits said:

    You need the whole picture:

    The bottom is clearly not a continuation of the top.

    There isn't enough information to say definitely either way.  Although the indentation suggests the bottom and top are matched and we just don't get to see all the code in between.

    Why would anyone print "uploading file ..." before checking if the file extension matches? I imagine output:

    Uploading file tubgirl.jpg...
    Oh btw I lied, you can only upload documents here STUPID!
    Edit: Why do I never see when threads have a second page?


  • Or am I supposed to be posting about sandwiches?



  • @blakeyrat said:

    I'm going to post the same thing at you that I posted at the Debian project on Slashdot yesterday. (It was pouring down rain. My friends are out of town. Shuddup!)

    To wit:


    If you can't get your shit together on the website, which is frankly pretty damned easy, why should your users believe you have your shit together on the vastly more complicated code library?

    1. They are different problem domains.  Being a strong multi-process C developer is different to being a web-site designer.

    2. The issue you're upset about is, I dare to say, not in fact a big deal. It comes down to requiring JS for a web-site.  This is not the end of the world.

    3. At least some users appear to be reasonably convinced, since the code is being used.




  • @liblfds_admin said:

    @blakeyrat said:

    I'm going to post the same thing at you that I posted at the Debian project on Slashdot yesterday. (It was pouring down rain. My friends are out of town. Shuddup!)

    To wit:


    If you can't get your shit together on the website, which is frankly pretty damned easy, why should your users believe you have your shit together on the vastly more complicated code library?

    1. They are different problem domains.  Being a strong multi-process C developer is different to being a web-site designer.

    Yah, but the latter can be done by a free CMS with free templates, so...

    @liblfds_admin said:

    2. The issue you're upset about is, I dare to say, not in fact a big deal. It comes down to requiring JS for a web-site.  This is not the end of the world.

    I do web usability for a living, so I'm sensitive to things like this:


    (Click image for enbiggenification.)

    I never said it was the end of the world.

    @liblfds_admin said:

    3. At least some users appear to be reasonably convinced, since the code is being used.

    Yes, but you don't know how many users look at the website and left before downloading it. (Presuming you don't have analytics, you don't appear to.) Who knows? You might have twice as many users.

    Anyway, I didn't mean to be the horrible evil awful person, and you're perfectly free to ignore everything I say here..



  • @Zecc said:

    While we're on the subject of bad website designs, here's this one: http://www.liblfds.org/

    Interesting library though.

    Are these structures merely lock-free or are they wait-free as well? Have they been proven free of race conditions, or are we relying on empirical evidence? I ask because merely lock-free algorithms are of limited value while wait-free can be a really nice guarantee, and because it's really easy to subtly screw up this lock-free stuff.



  • @liblfds_admin said:

    I thought about making it so if the page was loaded without JS, you'd have plain text telling you JS is required, but I've not actually done it.
    The site is truly awful though, and it breaks my browser's "open in new tab" functionality, which to me is a far deeper issue than it not working without Javascript.



  • @Enterprise Architect said:

    @Zecc said:
    While we're on the subject of bad website designs, here's this one: http://www.liblfds.org/

    Interesting library though.

    Are these structures merely lock-free or are they wait-free as well? Have they been proven free of race conditions, or are we relying on empirical evidence? I ask because merely lock-free algorithms are of limited value while wait-free can be a really nice guarantee, and because it's really easy to subtly screw up this lock-free stuff.

    The "Wikipedia" answers your question with a big fat no, far from wait-free, so it doesn't seem like this is the holy grail in multi-thread management.



  • While we're on the topic of design patterns, which design pattern is this?@judge.c said:

    struct accused *
    investigate (char *name, struct law *l)
    {
    // Nonsense including call to get_testimony(...) goes here
    }

    int
    judge (struct accused *a, struct law l)
    {
    assert (a && l);
    if (S_ISLNK (a->mode))
    return 0;
    else if (S_ISDIR (a->mode))
    return judge_dir (a, l);
    else if (S_ISREG (a->mode) && a->size)
    {
    a->guilty = judge_reg (a, l);
    if (a->guilty)
    shake_reg (a, l);
    /
    Show result of investigation, if the file is guilty or if
    * level of verbosity is greater than 2
    */
    if ((a->guilty && l->verbosity) || l->verbosity >= 2)
    show_reg (a, l);
    }
    return a->guilty;
    }



  • I dare say: Composite. 'accused *a' implements the component. Pretty weird to see it in C though.



  • @Enterprise Architect said:

    @liblfds_admin said:
    I thought about making it so if the page was loaded without JS, you'd have plain text telling you JS is required, but I've not actually done it.
    The site is truly awful though, and it breaks my browser's "open in new tab" functionality, [snip]
     

    In what way?  I can open root pages (wiki, forum, etc) from their 'tabs' on the main page into browser tabs; and any given link will open up into a new tab.

    Do you mean that the visual appearance of the site is not preserved over tabs, e.g. when you open a tab, you're no longer in the IFRAME?

     



  • @Enterprise Architect said:

    @Zecc said:
    While we're on the subject of bad website designs, here's this one: http://www.liblfds.org/

    Interesting library though.

    Are these structures merely lock-free or are they wait-free as well? Have they been proven free of race conditions, or are we relying on empirical evidence? I ask because merely lock-free algorithms are of limited value while wait-free can be a really nice guarantee, and because it's really easy to subtly screw up this lock-free stuff.

     

    Lock-free.  Very, very few algorithms are wait-free.  Certainly nothing as sophisticated as a queue or stack.

    What makes you say lock-free is of limited value?



  • @blakeyrat said:

    Yah, but the latter can be done by a free CMS with free templates, so...

    Free and free - but not free, because it takes time.  I'd need to learn a new system of producing web-sites when I already know how to hand-craft sites.  More to the point, I would never want to use a CMS system.  Hand-crafting is what I enjoy.  This is a hobby site. The point is to enjoy yourself.  Failing to do so -means you failed-.

    I do web usability for a living, so I'm sensitive to things like this:


    (Click image for enbiggenification.)

    Now, this image - do I see it correctly??  you have a -partial page load- occurring, and there is no more progress after what is shown?




  • @eBusiness said:

    The "Wikipedia" answers your question with a big fat no, far from wait-free, so it doesn't seem like this is the holy grail in multi-thread management.
     

    Almost no algorithms are wait-free.  If I had developed a wait-free stack, queue and ringbuffer, I would be an undiscovered genius.


  • @liblfds_admin said:

    you have a -partial page load- occurring, and there is no more progress after what is shown?
     

    The iframe isn't maxed, is what.



  • @liblfds_admin said:

    @blakeyrat said:

    Yah, but the latter can be done by a free CMS with free templates, so...

    Free and free - but not free, because it takes time.  I'd need to learn a new system of producing web-sites when I already know how to hand-craft sites.  More to the point, I would never want to use a CMS system.  Hand-crafting is what I enjoy.  This is a hobby site. The point is to enjoy yourself.  Failing to do so -means you failed-.

    Yah, well my blog's a hobby site, too. But I use WordPress on it because... duh? If you don't have the time to do it right, why not just use the free off-the-shelf solution? Hobby or not, that's plain common sense.

    I do web usability for a living, so I'm sensitive to things like this:


    (Click image for enbiggenification.)

    Now, this image - do I see it correctly??  you have a -partial page load- occurring, and there is no more progress after what is shown?


    It's fully-loaded, but for whatever reason (I didn't debug it because, you know, you're not paying me) the iframe is only about 100 pixels tall. That's what I see every time I visit the site... I presume the iframe is supposed to be a bit taller, eh?



  • @blakeyrat said:

    It's fully-loaded, but for whatever reason (I didn't debug it because, you know, you're not paying me) the iframe is only about 100 pixels tall.

    I get inconsistent results, sorta like what might happen when you use a buggy lock-free library. Hmm.

    Refresh a few times and it may clear itself up. That is, until you switch "tabs." At that point all bets are off.


Log in to reply