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

01-09-2018 , 12:50 PM
I thought the point of objects was to combine data and code together, but that’s 1999’s DeVry thinking and may not be valid anymore.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-09-2018 , 02:30 PM
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** the point of objects is an associative array collection
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-09-2018 , 03:48 PM
Is it bad design to implement a for loop that checks for a condition and then does something and returns out of the loop as soon as the condition is found?

A person on my team said generally speaking it is bad design and to just use something like lodash filter, but this function is more specifically tailored to my needs and is basically just a cheaper implementation of filter.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-09-2018 , 04:21 PM
Quote:
Originally Posted by Larry Legend
Is it bad design to implement a for loop that checks for a condition and then does something and returns out of the loop as soon as the condition is found?

A person on my team said generally speaking it is bad design and to just use something like lodash filter, but this function is more specifically tailored to my needs and is basically just a cheaper implementation of filter.
Definitely be skeptical of the following. I am going to guess that loadash filter is some library method where you call with an input and the output is something the code processes. Setting up the input for the call and using the output will require some changes to your code. Think about someone at a later date in maintenance mode, maybe you in 6 months +, will have an easier time dealing with/reading. Guessing the lodash filter will be easier to understand.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-09-2018 , 04:43 PM
Yea that's a fair point, and it might be a bit easier.

I'm still learning a lot everyday (obv) and it's not always obvious to me about the "optimal" implementation for some stuff and I feel like sometimes I end up using methods from libraries where it seems like overkill, but I can see why overall it's good to have design standards and ways you do things consistently in a project, ideally org-wide but that's probably beyond most companies.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-09-2018 , 04:51 PM
I don't javascript but I'm assuming all this lodash business is their map/filter/reduce iterator type of thing that all languages have these days.

Saying that it's a slightly more optimal/more readable/conforms to company standards better is all great and , but saying in an absolute sense Larry's solution is objectively "bad design" seems wrong and bothers me.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-09-2018 , 05:01 PM
Quote:
Originally Posted by saw7988
Saying that it's a slightly more optimal/more readable/conforms to company standards better is all great and , but saying in an absolute sense Larry's solution is objectively "bad design" seems wrong and bothers me.
Agree 100% with this. With that said, it's important to follow standards and the ability to follow coding standards accurately (even if not formally documented) is an important skill.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-09-2018 , 05:56 PM
Quote:
Originally Posted by kerowo
I thought the point of objects was to combine data and code together, but that’s 1999’s DeVry thinking and may not be valid anymore.
Quote:
Originally Posted by Grue
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** the point of objects is an associative array collection
you're immutable objects can look identical to your mutable ones, but mutator methods will return copies of the object rather than mutating it in place.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-09-2018 , 07:07 PM
Array prototype filter? Find? I haven't written a js for loop in years. Also, **** lodash.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-09-2018 , 10:48 PM
Lodash filter wtf are you guys even going on about. Just exit from your loop early ffs. End old man rant
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-09-2018 , 11:05 PM
Quote:
Originally Posted by Grue
Array prototype filter? Find? I haven't written a js for loop in years. Also, **** lodash.
Lodash is maybe the most useful js library there is. You don't know what you're missing.It's a lot more than just filter, map, reduce.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-09-2018 , 11:08 PM
Does someone who knows about Java land mind pointing me in the right direction for build configuration management and deployment please? Using intellij and deploying to Google Cloud. Thanks!

Last edited by ChrisV; 01-09-2018 at 11:23 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-09-2018 , 11:11 PM
Quote:
Originally Posted by muttiah
Lodash filter wtf are you guys even going on about. Just exit from your loop early ffs. End old man rant
You know what they say... premature optimization is the root of all evil. I am not a fan of for loops because they almost encourage you to be "clever" and do everything in as few for loops as possible. Efficient? Sure. Maintenance nightmare? Absolutely! For loops read like a story that is written out of order where as filter, map, reduce, etc reads more like a regular old story.

The only real use case for me with for loops is exiting early in huge data sets. I don't think most people will really ever encounter that so for loops should really be avoided for the most part. imo.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-09-2018 , 11:17 PM
In lodash, here is an example of something short, clean, and simple that would probably take you 10 lines in regular old js.

Code:
map(myArray, partialRight(pick, ['myKey']))
What this does is iterates through myArray (which is an array of objects), grabs the property called myKey, and returns an object with only that key in it. What if you really just want to grab a single key and return it?

Code:
map(myArray, 'myKey')

Last edited by Craggoo; 01-09-2018 at 11:40 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-09-2018 , 11:22 PM
Does this do the same thing?

myArray.map(myObj => myObj.myKey);
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-09-2018 , 11:35 PM
Quote:
Originally Posted by suzzer99
Does this do the same thing?

myArray.map(myObj => myObj.myKey);
anybody insisting you use native js would insist at the very least you wrap it in a

Code:
myObject.hasOwnProperty('myKey')
What if you want to return multiple keys? Now you need to construct a new object, assign all the properties to the new object. The lodash solution is one line (or maybe a wrapped line) no matter how many properties you are returning. The native js solution grows at an exponential rate.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-10-2018 , 03:49 AM
While I'm asking for help: I want to use Pinnacle's REST API from an application, but they blacklist US IPs. My cloud server is located in Australia, as am I, but for some reason it resolves as a US IP. Any ideas on workarounds? Are there proxy services I can buy to solve this problem? Accessing the API doesn't require an SSL connection or anything fancy like that, you just put credentials in a header, so it's totally stateless.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-10-2018 , 07:12 AM
Quote:
Originally Posted by Craggoo
You know what they say... premature optimization is the root of all evil. I am not a fan of for loops because they almost encourage you to be "clever" and do everything in as few for loops as possible. Efficient? Sure. Maintenance nightmare? Absolutely! For loops read like a story that is written out of order where as filter, map, reduce, etc reads more like a regular old story.

The only real use case for me with for loops is exiting early in huge data sets. I don't think most people will really ever encounter that so for loops should really be avoided for the most part. imo.
Good post and I think that it illustrates that code efficiency is often incompatible with easy to maintain code.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-10-2018 , 11:31 AM
Quote:
Originally Posted by Craggoo
anybody insisting you use native js would insist at the very least you wrap it in a

Code:
myObject.hasOwnProperty('myKey')
What if you want to return multiple keys? Now you need to construct a new object, assign all the properties to the new object. The lodash solution is one line (or maybe a wrapped line) no matter how many properties you are returning. The native js solution grows at an exponential rate.
You didn't say multiple keys, you said one key. Defensively coding for things you think you might need is the road to hell imo.

How would you even map an array of objects to multiple properties of that object? Are you going to return a new generic object with that # of props? A lot of questions you need to figure out before you decide on how to do it.

And I've almost never used hasOwnProperty in my career. Whenever I see an example that uses that I back up and check my approach to the problem. It just smells bad to me. Same with trying to map an array of objects to some collections that picks multiple properties out of that object. At that point I would almost always back up and look for a cleaner way.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-10-2018 , 11:41 AM
um no one cares about hasownproperty in arrays. And barely in objects. You're writing some bizzaroland JS imo. Lodash does have its uses (_.shuffle, _.uniq) but can be avoided with clean es5/6 array methods like 80-90% of its time.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-10-2018 , 11:56 AM
In my embedded software class, there’s no tests, but we’re going to build and program a small computer from basically the breadboard up. I’m really bad at soldering wires and stuff but it sounds super fun.

computational geometry course is actually a mixed graduate/undergrad course, it seems about 50/50ish.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-10-2018 , 01:39 PM
Quote:
Originally Posted by Craggoo
anybody insisting you use native js would insist at the very least you wrap it in a

Code:
myObject.hasOwnProperty('myKey')
What if you want to return multiple keys? Now you need to construct a new object, assign all the properties to the new object. The lodash solution is one line (or maybe a wrapped line) no matter how many properties you are returning. The native js solution grows at an exponential rate.
Wait, isn't this just:

Code:
myArray.map(x => {
  const { key1, key2, key3 } = x;
  return { key1, key2, key3 };
});
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-10-2018 , 04:24 PM
Quote:
Originally Posted by Barrin6
I’m considered a junior dev so no way I am going to stick my neck out and call out that this senior dev as being lackluster. Also what if my assessment is wrong? I’ll look like an a-hole if so.

Anyways, this person started in September, so I’ll give them a benefit of the doubt. It could be that this person ramps up at a slower pace but will perform at a senior level when the time comes. Also I’ll admit that we don’t have a Netflix or Amazon culture where engineer standards are high and we Fire underperformers quick. So if it does turn out this person is underperforming, I imagine that they will be here for a while. Though I’m basing this off of nothing.
So turns out that the slow typer programmer is actually leaving next week. Confirmed my suspicion that the person was not fitting in quite well.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-10-2018 , 07:20 PM
lol how slow was this guy typing?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-10-2018 , 09:54 PM
Not surprising Barrin, and a good sign for sure.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m