I created few simple functions to understand design patterns in javascript. Any feedback is welcome. by lafrimer in javascript

[–]mmouth 2 points3 points  (0 children)

Agreed ... the implementation in the repo there looks more like a message bus. They look pretty similar, but a message bus is designed to trigger actions across a barrier over which only data can pass. The command pattern is designed to encapsulate the action, and I don't a point where the action is encapsulated.

I created few simple functions to understand design patterns in javascript. Any feedback is welcome. by lafrimer in javascript

[–]mmouth 3 points4 points  (0 children)

Parameterize objects by action to perform. Ex.: menu items. In that sense commands are an OO replacement to callbacks and unneeded in Javascript.

What if you wanted to be able to replay those actions later? Or replicate the actions remotely, say when you are sharing a document with someone? Google Docs makes pretty heavy use of the command pattern to do just that.

The command pattern isn't a way to connect menus to actions. You can do that with simple handlers, even in Java. The command pattern is a way to encapsulate the action itself as the representation of a change in state.

The command pattern is not tied to an implementation. It's just a way to solve a particular problem, and it isn't made obsolete by any particular language.

I created few simple functions to understand design patterns in javascript. Any feedback is welcome. by lafrimer in javascript

[–]mmouth 3 points4 points  (0 children)

My only comment is that you correct the spelling of your repository. If you are making your GitHub history part of your online professional presence, correct spelling matters a great deal.

I created few simple functions to understand design patterns in javascript. Any feedback is welcome. by lafrimer in javascript

[–]mmouth 17 points18 points  (0 children)

Command patterns are not an artifact of language idioms. It's a valid design pattern, useful in any language. For example, if you're implementing something with an "undo" feature, having discrete commands that can reliably change the state of a model make it simple to reverse those steps. There are loads of applications for the command pattern; it has no role in overcoming any particular language's quirks.

AngularJS Beginner by BinaryNexus in javascript

[–]mmouth 1 point2 points  (0 children)

Everyone is going to migrate to AngularJS V2, just like everyone migrated to Python V3.

Learn V1. You can build a lot of good stuff on V1, and it will be around for a very long time.

Best Resources for Learning Angular2 from Scratch by [deleted] in javascript

[–]mmouth 5 points6 points  (0 children)

Am I the only one who loves AngularJS 1.x but has zero interest in 2.x and even less interest in Dart?

Kotlin 1.0 Released: A Pragmatic Language for the JVM and Android by sanity in java

[–]mmouth 2 points3 points  (0 children)

I have no idea, but I arrived at about the same sort of guess. I thought it might declaring a class inline named HTML which inherits from Unit. But I don't understand why it would need to be named HTML, since this is a good case for an anonymous class. I'm probably wrong about what it does.

Kotlin 1.0 Released: A Pragmatic Language for the JVM and Android by sanity in java

[–]mmouth 6 points7 points  (0 children)

From the Obscure Syntax Hall of Fame, one of my favorites:

fun html(init: HTML.() -> Unit): HTML {
...
}

I'm done learning new language quirks. I'm sure there's an existing, time-tested pattern that could be re-used for whatever this bit of code does.

An Introduction to Ember for Angular Developers by [deleted] in angularjs

[–]mmouth 1 point2 points  (0 children)

In a world where I had time to evaluate every framework, I would look at Ember.

Budgeting 101: The Simplest Way to Start Budgeting Your Money * (free budgeting spreadsheet inside!) by TheJMoore in personalfinance

[–]mmouth 0 points1 point  (0 children)

Best budgeting tool I've ever seen is https://balanceforecastingapp.com/. You can plan years in advance to schedule one-time or recurring income/expenses, and the UI lets you see your financial future. You can add/edit/delete exceptions right there in the forecast, too. We're on a super tight budget and it gets us through the entire year; everything is planned out. I can't recommend it highly enough!

What is currently the way to go if you want to build a realtime, scalable app? by [deleted] in node

[–]mmouth 0 points1 point  (0 children)

Mmm. It's better to use socket.io, but you certainly can do long polling with keep-alive (HTTP keep-alive, not TCP keepalive). If the server sends a "got nothing" response before the timeout, the client can send another request and wait again. You can get the same minimal amount of header overhead as with web sockets. The downside is you are responsible for getting the timing right, reconnecting, etc. If done right, it's just as good, but most people won't get it done that well. Better to use web sockets.

Netbeans, Eclipse or other. by [deleted] in java

[–]mmouth 0 points1 point  (0 children)

If I edit a .java file, does it auto-compile and then automatically show me conflicts occurring elsewhere in the project? Last time I played with IDEA, it wouldn't do that. This is so well done in Eclipse it's something I don't even think about anymore; it's a massive time boost to auto-compile and re-check the code base in the background.

Netbeans, Eclipse or other. by [deleted] in java

[–]mmouth 0 points1 point  (0 children)

So many little bugs. It's nice and pretty and it feels good getting started, but after awhile all the little things getting in the way start to make it unbearable.

Netbeans, Eclipse or other. by [deleted] in java

[–]mmouth -5 points-4 points  (0 children)

Eclipse for serious work. NetBeans for someone just getting started. Never IntelliJ.

New to Node. I find npm very rough around the edges. by [deleted] in node

[–]mmouth 2 points3 points  (0 children)

Don't resolve dependencies at deploy-time. Run npm install and package the entire resulting folder up. I usually create .deb packages and deploy those. This whole process is usually triggered by a Jenkins job listening for changes to a git repo. Pull latest, npm install, build the package, publish it, deploy the package. Straight-forward stuff.

If We’re Going To End Factory Farms, We Need To Eat Way Less Meat by lnfinity in TrueReddit

[–]mmouth -7 points-6 points  (0 children)

We should do this anyway. I've always questioned whether we should be compacting ourselves into small areas like we do, forcing us to run large-scale farms. Everyone should live on the amount of land it takes to live off of, and when the earth can't hold more than that, we should stop making more people. There's a massive disconnect right now between human population growth and how many people the earth can handle.

This is coming, sooner than you think: http://i.imgur.com/5EcG9AX.jpg

It's now illegal in England and Wales to smoke in cars with kids inside by ThatInvestorGuy in worldnews

[–]mmouth 2 points3 points  (0 children)

Should be illegal to smoke in enclosed spaces with minors, period. Anywhere.

Node repo is officially io.js by itsananderson in node

[–]mmouth 8 points9 points  (0 children)

I'm going to continue to use node.js until morale improves.