Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

08-16-2016 , 12:42 PM
even with the series i still find it more readable (adding braces and returns just makes it worse), but obviously it's not great either way in that case.

i'd prefer to write it as a multiparam function, and then use a decorator function to curry it.

Code:
const uncurriedLogger = (store, next, action) => {
  console.log("Logged", action);
  return next(action);
};

const logger = curry(uncurriedLogger);
ramda has a utility for exactly this.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 12:47 PM
Quote:
Originally Posted by suzzer99
The guy who makes those videos (which seem like the most popular/comprehensive react tutorial out there) seems to favor inheritance over say closures to solve problems.
i'd avoid the tutorials, in that case.

Code:
I get what you're saying and at anything other than hyper-mega-corp with a team of offshore devs I agree. Unfortunately at my day job you have to consider stuff like - it's a lot easier for most offshore devs to learn a flat structure with a lot of stuff vs. deep JS understanding.
this is totally fair.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 12:49 PM
I find video tutorials a nice way to ease into something new. I'm extremely visual. I learn much better by watching someone code than reading stuff on a page.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 12:52 PM
FWIW we use the google JS style guide, which says that the following are ok:

Code:
if (isCondition) doSomething();
else doSomethingElse();
Code:
if (isCondition && someLongerCondition && someMoreStuff) 
  doSomething();
else 
  doSomethingElse();
I don't like unnecessary curly braces either. Their caveat is that else has to match if. So if one gets curlies the other does too.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 12:53 PM
I feel like A and D could be correct for the second question
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 12:55 PM
Speaking of unnecessary curly braces and wasted vertical space, I saw some code yesterday that made my eyes bleed.

Code:
    all(callback)
    {
        const query = `SELECT session FROM ${this.table} ALLOW FILTERING;`;
        const qParams = [];
        let sessions = [];
        debug(`Query: ${query}`);
        debug(`Query params: ${qParams}`);
        this.client.eachRow(query, qParams, this.clientOptions.queryOptions, (n, row) =>
        {
            debug(`Session [${n}] fetched: ${row}`);
            if (row["session"])
            {
                sessions.push(JSON.parse(row["session"]));
            }
        }, (error, result) =>
        {
            if (error)
            {
                debug(`Sessions cannot be fetched: ${error.message}`);
            }
            else
            {
                if (result && result.rows)
                {
                    debug(`Sessions fetched: ${result.rows.length}`);
                }
            }
            return callback(error, sessions)
        });
    }


Code:
    all(callback) {
        const query = `SELECT session FROM ${this.table} ALLOW FILTERING;`;
        const qParams = [];
        let sessions = [];
        debug(`Query: ${query}`);
        debug(`Query params: ${qParams}`);
        
        this.client.eachRow(query, qParams, this.clientOptions.queryOptions, (n, row) => {
            debug(`Session [${n}] fetched: ${row}`);
            
            if (row["session"]) sessions.push(JSON.parse(row["session"]));

        }, (error, result) => {
 
            if (error) debug(`Sessions cannot be fetched: ${error.message}`);
            else if (result && result.rows) debug(`Sessions fetched: ${result.rows.length}`);
 
            return callback(error, sessions)
        });
    }
Had to do it. Much better use of vertical space imo.

Last edited by suzzer99; 08-16-2016 at 01:02 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 12:56 PM
Quote:
Originally Posted by PJo336
I feel like A and D could be correct for the second question
Um...
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 12:58 PM
Quote:
Originally Posted by suzzer99
FWIW we use the google JS style guide, which says that the following are ok:

Code:
if (isCondition) doSomething();
else doSomethingElse();
Code:
if (isCondition && someLongerCondition && someMoreStuff) 
  doSomething();
else 
  doSomethingElse();
I don't like unnecessary curly braces either. Their caveat is that else has to match if. So if one gets curlies the other does too.
I hate both of these tbh. I should be a python developer =/
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 12:58 PM
Haha, Im thinking in the vein of you get part of the message before the entire thing is finished. Seems like an incredibly poorly designed question
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 01:05 PM
Maybe so. It seemed pretty clear to me that synchronous communication means "I'm going to send this, then wait for a response". Whereas async means "I'm going to go send this and go about my business, when the response comes I will deal with it". But that could just be how I think about it.

In any case it was more designed to make then think than a grilling type question. They seemed to enjoy it. I was more interested in how they responded when we went over the quiz than the answers they gave.

They were shocked though that I asked them things on the final quiz, to try to test their deeper understanding, which weren't explicitly laid out verbatim in the class. Like I said I don't think they're used to that.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 01:11 PM
I suppose that makes more sense. Ive got Akka streaming on the brain right now
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 01:16 PM
Yeah you might have broken it down to a lower more granular level. My question was in the context of a node class, so they should be thinking in terms of node async communication with say a back-end data source.

Also for the record IM is sort of async, so I gave them credit if they put that. But email is the best answer.

Last edited by suzzer99; 08-16-2016 at 01:22 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 01:21 PM
Quote:
Originally Posted by plexiq
I don't know SQL Alchemy in particular, just talking persistence frameworks in general (mostly hibernate).

The added security is quite huge by itself. If you are writing raw SQL queries you need to manually make sure all the parameters are correctly sanitized/escaped and it only takes a relatively minor mistake to open yourself up to SQL injections. If you use the query builders then the framework is responsible for escaping the parameters correctly and SQL injections should not be possible unless there is a bug in the framework.

Caching and easy control over eager/lazy loading of references is another huge plus, but that part usually requires the use of ORM.
What I posted above was (assuming it ran) completely secure. You can screw up security with an ORM as well if you ignore best practices. DSLs don't imply that you are flapping in the wind alone and everything has to be done manually. String interpolation and concatenation is terrible regardless if you are using a DSL or ORM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 01:51 PM
Quote:
Originally Posted by daveT
What I posted above was (assuming it ran) completely secure. You can screw up security with an ORM as well if you ignore best practices. DSLs don't imply that you are flapping in the wind alone and everything has to be done manually. String interpolation and concatenation is terrible regardless if you are using a DSL or ORM.
I probably wasn't very clear, seeing that Rusty and you both interpreted it like this. I was replying to Rusty's question why anyone would ever use a persistence framework like Alchemy.

Of course, you can be completely fine when writing raw SQL assuming you follow some basic best practices. But the chances that a bad or inexperienced dev inadvertently introduces a SQL injection vulnerability have to be magnitudes higher with raw SQL compared to using some query builder. So yes, that would be one reason to use a persistence framework, imo

(Regarding performance of caching and lazy/eager reference loading I really can't comment for SQLAlchemy, but I found them both extremely useful in hibernate.)

Last edited by plexiq; 08-16-2016 at 02:00 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 02:14 PM
I understand that argument... but what happens if our hapless programmer has to use raw-sql (or whatever the analog is)?

I don't believe using components of an ORM is inherently bad. I do believe that allowing an ORM to generate your table schema is bad. I used an ORM / query builder in my first few web apps, and I understand some of the appeal of using your base language as an SQL language, but I think there is far more important considerations when dealing with SQL.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 02:46 PM
me_irl: finally gets around to implementing eslint and the heavily promoted airbnb style guide rules, spends the afternoon manually changing the rules to pass lint with his own way of writing code.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 03:10 PM
It really annoys me that ES Lint with sublime has to be installed for every project. I don't want to check in ES Lint to my package.json for a node app I'm sharing with people using all kinds of different IDEs. Nor do I want to have to re-install it on every project.

jshint which can be installed globally with local config (perfect combo) has most ES6 stuff, but JSX templates break it all over. And it doesn't know the new ...varName syntax for some reason.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 04:50 PM
Python has the worse, most crappy build system. It doesn't even feel real how bad it is. Only took a full day to somewhat figure it all out. setup.py is just horrible, using a ton of conflicting / possibly deprecated settings, and I still can't get the paths on the external .py scripts correct. At least I have something that isn't totally confusing and convoluted to build and run now, but they could do so much better than this.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 05:04 PM
Quote:
Originally Posted by suzzer99
jshint which can be installed globally with local config (perfect combo) has most ES6 stuff, but JSX templates break it all over. And it doesn't know the new ...varName syntax for some reason.
you also can't use async await with jshint, but eslint supports it. and jshint won't support it until it's approved....
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 05:59 PM
Is Webstorm better? Playing around with it - I like what I've seen so far. Having the console window in the IDE - and list of grunt tasks you can just double-click is a potential game changer.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 06:23 PM
While I'm the casualest of casual JS devs, I think Visual Studio with node.js tools (it's an official MS extension you have to install after VS) is pretty rad. I tried Webstorm and really liked it (I use AppCode at work, which is another JetBrains IDE, I think they make really good stuff) but didn't want to buy it for personal use due to my casualness level, and VS is free.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 06:54 PM
Visual Studio also looks really cool these days. I like the built in node debugging. I'm considering jumping from Sublime to WebStorm or VS.

With auto-generated/node-integrated stuff like typescript, babel, webpack, etc I feel like sublime is getting left in the dust. You need a more full featured IDE.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 07:06 PM
Eh I just run gulp along side sublime and I doubt you can have a faster setup than that. Webstorm is a dog.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2016 , 09:44 PM
Quote:
Originally Posted by suzzer99
Seems like you better already be a JS expert to pick up react - with inheritance all over the place, stuff like this.someFunction.bind(this) all over the place, immutability with redux state, a bunch of other pretty high-level JS concepts. Angular has a learning curve too - but I don't remember it needing this level of deep JS understanding.
I think this is to some extent true of all major frameworks. It's in part because the companies that produce these frameworks are top tech companies with extremely high hiring standards who have every reason to believe that their own developers need power and expressiveness over ease of learning and in part because open source frameworks don't become popular by convincing the rank and file to use them - they become popular by picking up early adopters who can contribute and convince others. Because virtually no one makes money off selling frameworks and libraries anymore, there doesn't seem to be any real incentive to make frameworks easy enough for off-shore dev types. The incentives may even be the reverse - because choice of technology is used for signaling, a technology that is too good of an abstraction that lesser developers are able to be productive with it, is often actively avoided by the better developers who have economic incentives to avoid using technologies that are associated with lesser developers. It's kind of like how night clubs work.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-17-2016 , 12:43 AM
atom node debugger look any good?

https://atom.io/packages/node-debugger
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m