News for hackers. Stuff that matters.
Re:How to make your code imply responsibilities by thecolorblue on Monday October 21, 2013 @09:29AM (#6585323)
This is a great article. I'm brainstorming how to do this in javascript.
Re:How to make your code imply responsibilities by jxf on Monday October 21, 2013 @10:06AM (#6585586)
Right now, you might have something like:

    ... = function() {
      // set up header
      // set up content
      // set up footer
    };
Segregating the responsibilities might look something like:

    var homepage = (function() {
        function renderHeader() {
            // ...
        };

        function renderContent() {
            // ...
        };
    
        function renderFooter() {
            // ...
        };

        return {
            renderHeader: renderHeader,
            renderContent: renderContent,
            renderFooter: renderFooter
        };  
    })();
Now you can just invoke "homepage.renderHeader()", instead of, say, 5 different methods that conditionally decide what should go in the header.
Re:How to make your code imply responsibilities by saturnflyer on Monday October 21, 2013 @10:02AM (#6585561)
thanks! I'd love to see what you do