Hacker News new | comments | show | ask | jobs | submit login

This is a great article. I'm brainstorming how to do this in javascript.



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.


thanks! I'd love to see what you do




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: