Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
isochronous
Jul 15, 2001

*Golf Clap*
I'd just like to chime in and say that as much as I've come to love and rely on underscore in the past couple of years, once I found and evaluated Lo-dash, I'm never going back.

Lodash offers:
  • Major performance improvements over underscore (comparative benchmark results: http://pastebin.com/RkZ51vLE)
  • A command line interface for creating custom builds with compatibility with various frameworks, inclusion/exclusion of certain categories/functions, various module formats (AMD, commonJS, node), ES5+ versions or legacy versions, strict mode versions, configurable module name, and more
  • Enhanced versions of many underscore methods that offer additional options/callbacks
  • A host of additional methods not included in underscore
  • Intuitive/Implicit method chaining

The only thing that keeps its standard build from being a perfect drop-in replacement for underscore (without using an underscore compatibility build) is that a couple of the methods work differently from their underscore counterparts - for example, the _.extend method does not include inherited properties/methods from the extended object, rather only things that pass the "hasOwnProperty" test. It does, however, offer the _.merge method, which acts just like underscore's _.extend method. For this reason, I recommend using Lo-dash from the very beginning of any project, as trying to drop it in later without using the underscore compatibility build (which by default removes any methods not provided by underscore, the implicit chaining, and the extra options added to many methods) requires some major refactoring.

However, if you want to replace underscore with lo-dash on an existing project, and you still want the extra methods that lo-dash provides, you can get the best of both worlds by using the lo-dash CLI and running the following command - this outputs an AMD version with the module name "underscore" - and should be all one line, the browser is just inserting a line break before the "plus" argument:

lodash underscore exports=amd moduleId=underscore plus="at,bindKey,cloneDeep,createCallback,curry,findIndex,findKey,forIn,forOwn,isPlainObject,merge,parseInt,partialRight,pull,remove,runInContext,transform,findLast,findLastIndex,findLastKey,forEachRight,forInRight,forOwnRight"

isochronous fucked around with this message at 17:58 on Oct 18, 2013

Adbot
ADBOT LOVES YOU

isochronous
Jul 15, 2001

*Golf Clap*

Huragok posted:

This is more of a design question, but I'm using a themed version of Bootstrap for Hyperglot. Since it's a desktop app, I'd like to make it more native-feeling with platform-specific UI controls (metro for Win, cocoa for Mac). Anyone know of a framework that can help me out in that regard?

It's not free, but Kendo UI (http://www.kendoui.com/) supposedly offers this (well, at least for mobile devices, not sure about desktops).

Chrome "Packaged Apps" also have Native control styles - http://developer.chrome.com/apps/about_apps.html

Edit: Really, most modern browsers are supposed to style form components with "native" looking controls, as long as you use the proper type attribute. This MDN page has a list of native controls available in HTML, along with supported browsers. I'm not sure how these styles interact with extra styles applied to them via CSS, however. It's frequently considered a... well, not BAD, per se, but maybe undesirable? practice to try making web applications look and act like desktop applications. Each domain has its own strengths and weaknesses, as well as their own established interaction patterns, and blurring those lines can, in some cases, lead to greater confusion among users than devs probably intended.

isochronous fucked around with this message at 18:14 on Oct 18, 2013

isochronous
Jul 15, 2001

*Golf Clap*
Personally I loving hate knockout, but that's because it's full of pseudo-anti-patterns (like obtrusive unobtrusive javascript*) and is a pain in the rear end to figure out if you weren't the one to write the app in the first place. Angular is a bit sexier, but I still don't like writing method calls directly into markup. 15 years worth of web development experience just screams that it's a bad idea. I've been using Backbone with Marionette, requireJS, and plugins as necessary, and I like it a lot other than its total lack of model binding, though Backbone.Stickit is a decent plugin for that.

Ender.uNF posted:

No. We already replaced the Win32 client with a web one, it just has much worse performance than it should because everything does post backs on WebForms, or uses massive callbacks containing the world (that has to run the entire page's post back logic anyway). I managed to get WebForms and MVC to interop and our new features are using MVC, so performance wise we are in much better shape, but my grand plan to make the UI clean and more maintainable was promptly turned into spaghetti code once everyone else was let loose on it.

Honestly whenever I find myself in a position like this, I see what I can convert over to an events-driven pattern. Being able to trigger custom events with data payloads (or just embedding data into elements with jQuery and then retrieving it via $(event.target)) makes decoupling components a LOT easier than trying to define interfaces and getting everyone to implement them properly. Backbone.Wreqr's request-response pattern also comes in incredibly handy - you can trigger an event that requests a resource, and have an event subscriber actually return a variable directly to the requesting code. For example, in the project I'm working on, we have a "Master" model with several sub-models, each of which is a subset of the master. If we ever need to get a reference to the master from code that wouldn't normally have it, we just use the Event Aggregator (which we've modified to also include request-response behavior) to trigger a request for the master model, and the master model itself responds with a reference to itself. That means getting a reference to an object that's in a completely different context/scope/whatever is as easy as doing this:

JavaScript code:
// Define an event aggregator with request-response and command behavior
SuperVent = Marionette.EventAggregator.extend({

    constructor: function(){

        // And here's why it's a Super Vent
        this.commands = new Backbone.Wreqr.Commands();
        this.reqres = new Backbone.Wreqr.RequestResponse();

        // Call the superclass constructor to get event binder mixed in
        Marionette.EventAggregator.prototype.constructor.apply(this, arguments);
    }

});

// In the master model's "initialize" method - this module includes a `vent` supervent instance as a dependency
vent.reqres.addHandler("wizard:model:master", function () {
    return this;
}, this); // this last argument sets the callback context

// Now from any other module that has a reference to the same vent, you can do this:
var master = vent.reqres.request("wizard:model:master");

Dangerllama posted:

^^ For the next two hours, Manning has all their JS books at 50% off, including AngularJS in Action.

I'm also curious if anyone has read Secrets of the JavaScript Ninja and would recommend it for varying levels of JavaScript ability.

I've been pretty happy with ng-Book for learning the fundamentals of Angular.

isochronous fucked around with this message at 22:54 on Mar 27, 2014

isochronous
Jul 15, 2001

*Golf Clap*
As far as templating systems go, my team has been very happy with Dust templates (the linkedin fork), though those have a pretty steep learning curve as well. Dust-linkedin provides (of course) basic token replacement, but also advanced features like loop index tokens, setting custom contexts, template helper methods, conditionals (if, eq [equal], ne [not equal], lt, gt, etc), parameterized partial views, enum support for select elements, token preprocessors, and a lot more that I'm sure I'm forgetting. They've got a basic tutorial, but I still had to play around with the syntax a good bit myself before I got comfortable with it.

isochronous
Jul 15, 2001

*Golf Clap*

Thermopyle posted:

This reminds me.

I'm getting ready to do a UI that will have a ledger in like Quicken or whatever. Anyone know of any good components out there made for this, or easily adaptable to it?

I've been putting it off because I don't really want to build it.

When it comes to grid controls, my favorite so far has been Kendo UI's grid control, but that's like saying my favorite bone to break is my little finger. Overall I think general-purpose grid controls typically indicate a lack of design focus, but if there's one good place for grid controls, it's in spreadsheet-like applications.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply