Page 27 of 28 FirstFirst ... 1725262728 LastLast
Results 261 to 270 of 274

Thread: Programmer's Den

  1. #261
    Now we know... Asteroids Champion ACow's Avatar
    Type
    INTP
    Join Date
    Dec 2013
    Location
    Melbourne, Australia
    Posts
    3,092
    I admit a subjective distaste for ternary operators in general.

    I mean, everything's a function anyway, but then we gotta give ground for this stupid cultural thing we have with binary operators which means now we have to worry about PEMDAS and implicit order of operations and non simple evaluation rules and all that what not, and then after losing that battle someone's like "let's have a threesome!".

    I'm like a sweet little Christian boy who left the movie theatre because there was a kissing scene only to find someone's been shooting porno in my apartment.

    don't worry, its my problem, I'll deal with it...

  2. #262
    Senior Member
    Type
    intp
    Join Date
    Dec 2013
    Posts
    1,826
    Quote Originally Posted by ACow View Post
    I'm not a JavaScript person, so first I have to ensure my interpretation is correct, and it might be that some of the edge cases don't apply to the language.

    my interpretation is that there's a block "do something". You execute this block if:

    a) somevariable is false

    OR

    b) somevariable is true, and the return value of setSomeValue() is true, assuming evaluation is lazy, and hence you also want setSomeValue() to only fire after the conditional check on somevariable is true, and that there's a possible distinction between complication between setSomeValue()'s side-effect, its possible state after the conditional check on somevariable, and its return value.

    Phew...

    That might seem pedantic to write it all out like that, but those are the conditions where I can see such code existing, because I agree that is general form has a bad code-smell about it.

    And if those relatively few conditions don't hold or aren't required, I can see there being so many simpler (albeit possibly slightly more verbose, but clearer) ways of telling the program to do something.

    And honestly, although I'm not a JavaScript guy, so take my opinion with a grain of salt here, if those conditions do hold, that suggests to me bad code smell in the programs design, since the number of times you'd actually want to have to think about state interaction and evaluation order like that should be extremely limited.

    I'm guessing that actually there is just a piss easy basic procedural code that gets you to the same place you need to be in practice.

    let me know how close I am to being right
    You're right, yeah. When I first saw this at work I didn't consider that setSomeValue() might have a return value. I think because the naming of it implies there shouldn't be one ("set"). Probably. But there could be... Further confusion. Is it supposed to have a return value? Does it return a true/false under different situations?

    I definitely prefer a bit more code if it means I can read it and understand it pretty easily and if length is the only negative factor.

    somevariable is true, and the return value of setSomeValue() is true, assuming evaluation is lazy, and hence you also want setSomeValue() to only fire after the conditional check on somevariable is true, and that there's a possible distinction between complication between setSomeValue()'s side-effect, its possible state after the conditional check on somevariable, and its return value.
    Hmm, setSomeValue() will definitely only fire after someValue is checked, and maybe not at all (if it's false). It could alter the value of someValue, but only after it's already been used in that conditional check. JavaScript is very focused on performance, because it's got to both compile and run in front of the user, so any code that doesn't need to run, will not (if it can be detected).

    Quote Originally Posted by ACow View Post
    I admit a subjective distaste for ternary operators in general.

    I mean, everything's a function anyway, but then we gotta give ground for this stupid cultural thing we have with binary operators which means now we have to worry about PEMDAS and implicit order of operations and non simple evaluation rules and all that what not, and then after losing that battle someone's like "let's have a threesome!".

    I'm like a sweet little Christian boy who left the movie theatre because there was a kissing scene only to find someone's been shooting porno in my apartment.

    don't worry, its my problem, I'll deal with it...
    Ah, I like ternary operators in some situations! Setting values, they can be a lot cleaner. It's got to be a very basic condition though.

    Otherwise, just make it a proper fucking if/else.

    I once came across something like:
    b ? c ? d : e : f
    i.e. nested if conditioned two or three levels deep, as ternary operators, on one line. Each a decently complex statement to also comprehend. Completely unreadable. I stripped that fucker out of there.

  3. #263
    schlemiel Faust's Avatar
    Type
    INTP
    Join Date
    Dec 2013
    Posts
    3,401
    Quote Originally Posted by scarydoor
    You're right, yeah. When I first saw this at work I didn't consider that setSomeValue() might have a return value. I think because the naming of it implies there shouldn't be one ("set"). Probably. But there could be... Further confusion. Is it supposed to have a return value? Does it return a true/false under different situations?
    It looks as though it should return a bool if successful, but you can't see the actual function? The author should have left a comment.

  4. #264
    Perfect is Shit LowIQLogan's Avatar
    Type
    InTP
    Join Date
    Dec 2013
    Posts
    592
    Yesterday I was doing the first code review with my team at a new job. I brought this macbook with me instead of the dell laptop that I am more comfortable with because it was much easier to get the docker containers working on the mac and therefore I had my code actually running on the mac (where as I could not get it to run on my dell). The ability to alt-tab and prove that it actually works gives me great confidence, like a huge dong in my pants even though I'll never get the opportunity to actually show it to them. I didn't really know what to expect but shortly after entering the conference room my team had booked I was pointed towards the hdmi cable and encouraged to go first. I fumbled looking for the port on the machine. Then when the screen rendered tiny and unreadable I struggled to remember cmd+= to zoom (which everyone will say aloud as "command plus" btw and since I'm using a medium predisposed to pedantry I'll point out that there technically is no command plus, only command = and command shift =, and so now that you've looked down at your keyboard it is self evident that I have truly wasted a few precious seconds of both of our lives. I then continued to struggle to find the git repo where I had committed code. A git repository is quickly becoming the only solid evidence acceptable for having done any work at all in a programming profession. Being unable to find your own code in a git repo is akin to saying a dog ate your homework. After someone graciously reminded me what repo I should be looking at I held up the three files I had added proudly, knowing that the git software would support my assertion that I had personally added these files during a process that can only be defined as work. This victory was short lived as I then struggled to walk through my decision making process in each file. Why are you loading this on the payment_server container? It was the only container that already had node.js so that made it the easiest to use. Why do you need this node package? Because without it I would have to write 4 of 5 lines of code instead of the 2 using a package would require (1 to install the package, 1 to use the package, ~6000 not written by me so dgaf). Why do you need that other node package? ... ... ... Will this work on production if your mysql queries return thousands of records instead of just the two rows in the test env? Uhhh errr I can constrain the queries but if the response is over 500mb my shit will crash. (here the contrarian in the group is satisfied and stops paying attention to my code review, soon walking out to take a call)
    "A new immortal appeared in front of you. Would you like preparations of inception?"

  5. #265
    Meae Musae Servus Hephaestus's Avatar
    Type
    eNTP
    Join Date
    Dec 2013
    Location
    Ceti Alpha V
    Posts
    15,272
    Thought experiment--I think it's an interesting project, I have something in mind, but it's way out of my league, nonetheless, I'm curious how other people might handle it:

    Let's say you have a piece of software that you like to use. In my case, it's a form of word processor. However, you want it on a dedicated device. How would you go about making an embedded system version of software written for a general purpose OS like Windows? Without access to the source code?

    My meta thinking on it are you would need to know what innies and outies of the OS the software used, but I have no idea how to reverse engineer that. But once done, you'd make a specialized driver to run on an embedded device like an Arduino.

    This would of course be easier to do if I used a Raspberry Pi, but the problem there is that the Pi is a general purpose computer. Granted, we sort of fake embedded devices like that all the time, judging by the number of touchscreen kiosks I've seen crash to Windows attest, but I want a dedicated device.
    I'm suspicious of people who say they'll die for a flag but won't wear a mask for their neighbor.

  6. #266
    Senior Member
    Type
    intp
    Join Date
    Dec 2013
    Posts
    1,826
    Quote Originally Posted by Hephaestus View Post
    Thought experiment--I think it's an interesting project, I have something in mind, but it's way out of my league, nonetheless, I'm curious how other people might handle it:

    Let's say you have a piece of software that you like to use. In my case, it's a form of word processor. However, you want it on a dedicated device. How would you go about making an embedded system version of software written for a general purpose OS like Windows? Without access to the source code?

    My meta thinking on it are you would need to know what innies and outies of the OS the software used, but I have no idea how to reverse engineer that. But once done, you'd make a specialized driver to run on an embedded device like an Arduino.

    This would of course be easier to do if I used a Raspberry Pi, but the problem there is that the Pi is a general purpose computer. Granted, we sort of fake embedded devices like that all the time, judging by the number of touchscreen kiosks I've seen crash to Windows attest, but I want a dedicated device.
    So, I'm a web programmer. Which means I don't think about operating systems all that much. But I programme in c# sometimes. I'm also a bit drunk right now. You need to think how does a programme run on a computer? The programme is originally written in some language (c / c++ / c# / whatever) and then compiled into binaries or whatever. Those binaries are then read by some translation service on the machine, into more like machine code (i.e. the c++ RE I guess...). I think that translation is unique to each operating system. (it's not something I much think about. But, I mean, it's common knowledge one of the advantages of the new c# core thing is that it's built to be supported on other operating systems, not just windows. Given that this is such a talked about feature, it implies that the feasibility of hacking your own solution to running a windows program on a non-windows machine to be unfeasible) Therefore if you wanted to run a windows program on an arduino, I think you're going to need some kind of emulator, to emulate that windows environment. One of those ones written by many people that still runs like shit. I think it's going to be a messy process.
    Last edited by scarydoor; 04-09-2020 at 08:13 AM.

  7. #267
    Senior Member
    Type
    intp
    Join Date
    Dec 2013
    Posts
    1,826
    Over the last couple of days I wrote a ray tracing algorithm, which so far can render spheres like this:



    The instructions come from this book: https://www.amazon.com/Ray-Tracer-Ch...dp/B07Q84TQ91/

    I wrote this in a bit over a day. Behind this is a bunch of javascript classes modelling different parts of linear algebra, a bunch of linear algebra operations, some classes which extend base linear algebra stuff like rays of light transformations, and spheres, and then some utility functions which calculate interceptions of rays of light and spheres. Then the image above is rendered by considering the ray of light from the camera origin to each point in the grid of the rendered image, and determining if it intercepts the sphere, and then calculating what colour it should be based on that Phong reflection model.

    I implemented this in javascript, and then rendered the thing using the html canvas api.

    It's been a really fun process. The book presents this in a very language agnostic sense. Each chapter presents some concepts and writes down test cases you should make pass. Test based development is such a divisive topic. Thankfully I found a testing framework which doesn't suck too much: jasmine.

    It took me a little while to get started on this book, mainly because the book suggested using the testing framework cucumber, which I found to be super shit for some reason. But I finally made another go at it with Jasmine.

    I like that this book really drives home the point that you can take a complicated topic and break it apart into little fragments, solve each small problem properly, and after you solve each one you can do some things. It's inspired me to look at some bigger projects, see if I can break them apart into individual test cases and make some progress.

  8. #268
    Senior Member Tetris Champion notdavidlynch's Avatar
    Type
    INFP
    Join Date
    Dec 2013
    Location
    LA County
    Posts
    2,777
    I've been staying up all night with my axe hacking away at a serverless repo.

    Not much to say that would make sense to many ... I simplified the GraphQL schema by dozens of lines, removed 14 AppSync mapping templates, and wrote 3 frankenstein node scripts to convert the data from 3 tables into a format for one.

    We're now using the "single table design" approach that Dynamo recommends, but which you'd be hard-pressed to find decent examples for how to actually implement until relatively recently.

    The backbone for what we're doing is overloading global secondary indexes and utilizing hierarchical sort keys for the bulk of our queries.

    Now I just have to ... reconcile all of these changes in the front-end code base ... Should take a few days.

    ---

    Now that I've gotten past the learning curve of most of our AWS services, the front-end is now the most "complicated" part.

    ... and DynamoDB is a bit of a mind-fuck once you learn how to use it.
    Last edited by notdavidlynch; 04-09-2020 at 09:07 AM.

  9. #269
    Senior Member
    Type
    intp
    Join Date
    Dec 2013
    Posts
    1,826
    I think for my next job I will avoid "agile".

    We're building an online form, which is mainly angular front end with some extra stuff randomly thrown on top. So naturally we're using an external agency specialised in a back end framework to build it for us, plus some internal people with limited angular knowledge.

    It's starting to appear that every web dev project is a mess.

    Weirdly, I'm being seen as someone who can find the proper design solutions to things, and be a bit of a technical consultant at different stages, which I feel amounts to just having base knowledge about the frameworks and languages we're using, and using some common sense. But I'm feeling a little stressed at this. I don't have enough experience to avoid sometimes causing extra bugs. So we go from a solution that has no visible bugs, but actually doesn't function, to a system that functions but has a few bugs, and people say they are "regression bugs" and then don't have the base knowledge of the frameworks to fix the minor issues themselves, and then it's up to me. Usually it's literally "how do you write a form in angular". One external developer asked me for an example on how he could add field validation, because he didn't think what I was proposing was possible.

  10. #270
    schlemiel Faust's Avatar
    Type
    INTP
    Join Date
    Dec 2013
    Posts
    3,401
    ^ we dropped agile when the boss himself didn't want to keep up with it.

    I have some projects on the side but it's all slowed down once work started to pick up the pace.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •