As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
Options

[Programming] Kafkaesque rabbits in the queue at the pub

12122242627100

Posts

  • Options
    Grape ApeGrape Ape Registered User regular
    Over time I have become less opinionated about programming languages, and way more opinionated on project management.

  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    Yeah I actually really miss Lockheed Martin. I mean, sure, there were a TON of people there who didn't do their jobs and just floated by... But at least my projects had defined requirements and deadlines. Any issues that came up would get pushed to a separate contract (depending on severity) and we had ACTUAL QA.

    Here our QA is a girl who went to school for marketing.

  • Options
    CampyCampy Registered User regular
    The manager for my previous project was a pedantic arsehole, which made interacting with him a miserable experience.

    However it also meant that the customer didn't get shit unless it was clearly stated in the project requirements or was otherwise paid for as part of an extension to the original work.

  • Options
    OrcaOrca Also known as Espressosaurus WrexRegistered User regular
    I've been working lately with a dude who does his own thing, reporting to one person, on small one-off projects.

    It's awkward as hell! Working within my own team, we all know what we need to do, we can collaborate easily, and we have a process that means we know what our status is, can review each other easily, etc.

    With this guy, he's got his own way of doing things, and rather than collaboration for his chunk of the project, it's more of a client/provider role, which is silly given the scope of the project: 1 developer on at 200% (he likes what he's doing, so he's spending weekends and late nights on this), me at probably 80% right now, and him at like 30%. Instead of a set process, it's just him tossing a binary over the wall every so often, or coming to talk about his status in the cube. Process doesn't need to be a bad thing bro...

    And remember that joke some odd months ago about directories ordered by date?

    Yeah, it wasn't a joke with this guy. It wasn't by date, it was by label, and at least it was backed up on the network, but what. the. hell.

    How does any professional in 2016 not run immediately to version control the moment they start a new project?!

  • Options
    zerzhulzerzhul Registered User, Moderator mod
    I just left a giant corporation for a startup, but the giant corporation didn't have any of the things I would want from a big company. When I worked for the PREVIOUS big corp before the most recent one, things were generally good and made sense even if they weren't exciting. The one I just left, though, nothing was good, nothing made sense, processes were the devil, and standing up for doing things right got you smacked down.

  • Options
    zerzhulzerzhul Registered User, Moderator mod
    One thing I really love about the startup I'm at now is that the engineers are all super on board with implementing good process from the start, so as we grow we aren't trying to force it in later. I've had a lot of ability to do things the "ideal" way without being asked why I am spending time on not coding.

  • Options
    thatassemblyguythatassemblyguy Janitor of Technical Debt .Registered User regular
    Orca wrote: »
    I've been working lately with a dude who does his own thing, reporting to one person, on small one-off projects.

    It's awkward as hell! Working within my own team, we all know what we need to do, we can collaborate easily, and we have a process that means we know what our status is, can review each other easily, etc.

    With this guy, he's got his own way of doing things, and rather than collaboration for his chunk of the project, it's more of a client/provider role, which is silly given the scope of the project: 1 developer on at 200% (he likes what he's doing, so he's spending weekends and late nights on this), me at probably 80% right now, and him at like 30%. Instead of a set process, it's just him tossing a binary over the wall every so often, or coming to talk about his status in the cube. Process doesn't need to be a bad thing bro...

    And remember that joke some odd months ago about directories ordered by date?

    Yeah, it wasn't a joke with this guy. It wasn't by date, it was by label, and at least it was backed up on the network, but what. the. hell.

    How does any professional in 2016 not run immediately to version control the moment they start a new project?!

    I'm feeling you on this. Worked with a person of similar inclinations (probably some of my rants are in my post history about mundane shit they'd fuck up).

    In my limited anecdotal experience, the only reason why a "professional" in 2016 doesn't use source control, and other types of collaborative methods is for a few reasons, most of them related to developing through the 80s and 90s, and the rest can be attributed to megalomania.

    Good luck and hopefully you can finish the project and move on before his lack of cooperation leads to your loss of sanity.

  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    zerzhul wrote: »
    One thing I really love about the startup I'm at now is that the engineers are all super on board with implementing good process from the start, so as we grow we aren't trying to force it in later. I've had a lot of ability to do things the "ideal" way without being asked why I am spending time on not coding.

    This is our problem right now. When I first came in we had a great Startup vibe, lots of process to follow, fun atmosphere (going to change the world!, etc). But now? The entire thing is a drag. Releases go out.. I hear shortly about bugs and fix them and move on. No positive feedback, just phone calls about shit broken and how we obviously don't test the software, etc, etc.

    I mean, Jesus Christ, this is a home-grown Specimen tracking software written by a SINGLE developer. Most LIS softwares are written by large teams with coordination and structure. We can't keep treating this application like it's a simple, small application. It's fucking gigantic and we don't even have QA.

  • Options
    admanbadmanb unionize your workplace Seattle, WARegistered User regular
    Nogs wrote: »
    urahonky wrote: »
    I love when I get a ticket that basically says "Hey the lab called. They want <station> to show Specimen details and not Case details. It'll help them out." and then they set the priority to Highest and set the release date to 10/25 without even considering talking to me or realizing that I have 40 tickets due on 10/25 already and this new ticket is a COMPLETE change from what the original requirement was.

    Get ye to a big corporation.

    For real, I mean it. People like to shit on big corps because they arent "cool startups" and shit. But in a big corp, everything goes through a process, everything is generally planned out, etc. I used to get emails and calls all time of the night. Then I went and did dev for like 1.2k person company, and it was so much better. Clearly defined job and boundaries, etc.

    but when a giant corporation doesn't have process or good planning...

    I don't think this is really a universal rule either way. What you should do is ask everyone you interview with about their dev process. If they're happy with it, they'll be happy to tell you about it.

  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    admanb wrote: »
    Nogs wrote: »
    urahonky wrote: »
    I love when I get a ticket that basically says "Hey the lab called. They want <station> to show Specimen details and not Case details. It'll help them out." and then they set the priority to Highest and set the release date to 10/25 without even considering talking to me or realizing that I have 40 tickets due on 10/25 already and this new ticket is a COMPLETE change from what the original requirement was.

    Get ye to a big corporation.

    For real, I mean it. People like to shit on big corps because they arent "cool startups" and shit. But in a big corp, everything goes through a process, everything is generally planned out, etc. I used to get emails and calls all time of the night. Then I went and did dev for like 1.2k person company, and it was so much better. Clearly defined job and boundaries, etc.

    but when a giant corporation doesn't have process or good planning...

    I don't think this is really a universal rule either way. What you should do is ask everyone you interview with about their dev process. If they're happy with it, they'll be happy to tell you about it.

    Yep and I certainly will now.

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    pt0ZiR9.jpg

  • Options
    RendRend Registered User regular
    edited October 2016
  • Options
    admanbadmanb unionize your workplace Seattle, WARegistered User regular
    So... Python programmer? Really really insane Python programmer?

  • Options
    bowenbowen How you doin'? Registered User regular
    oh my god

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    bowenbowen How you doin'? Registered User regular
    that is both awesome and terrifying at the same time

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    KhavallKhavall British ColumbiaRegistered User regular
    Like on the one hand that's kiiiind of awesome and I kind of love it.

    On the other, what the fuck is that

  • Options
    RendRend Registered User regular
    It's like that code is about to get eaten up by the Langoliers

  • Options
    crimsoncoyotecrimsoncoyote Registered User regular
    I like the ends of a few of those that are just like

    ;}

    as if to say, "it's OK, just go with it"

  • Options
    LD50LD50 Registered User regular
    That is so beautiful. I kinda want to know the story about how they ran into that.

  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    Question: If you guys were designing a thing where if a person pressed a "rewind" button and it rewinds as they hold it... How would you handle the speed? Would it be 1x (so if they held it for 1s it would rewind 1s) or something else? I feel like 1x is too slow, but I'm not sure what "feels" right.

  • Options
    bowenbowen How you doin'? Registered User regular
    rewind twice the playback speed, then double it every time they press rewind up to 4 presses

    play stops and plays immediately

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    DehumanizedDehumanized Registered User regular
    I could imagine a system where it rewinds faster the longer you hold it, but bowen's suggestion seems just as good for way less effort.

  • Options
    Mr_RoseMr_Rose 83 Blue Ridge Protects the Holy Registered User regular
    Most rewinds go at about 15:1 or so it seems. Try it and see what works best?
    Or you could go with a static "skip-back" type rewind where it steps back a fixed amount with every click; 30s is typical there.

    ...because dragons are AWESOME! That's why.
    Nintendo Network ID: AzraelRose
    DropBox invite link - get 500MB extra free.
  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    I'll try double and see how it feels. This is for dictation audio from a Pathologist to a transcriptionist so I don't want to make it go too fast... they just need to be able to have them repeat something over and over again.

  • Options
    Mr_RoseMr_Rose 83 Blue Ridge Protects the Holy Registered User regular
    Oh then you probably definitely want a static skip-back, but probably not more than ten seconds if it's mostly speech.

    ...because dragons are AWESOME! That's why.
    Nintendo Network ID: AzraelRose
    DropBox invite link - get 500MB extra free.
  • Options
    bowenbowen How you doin'? Registered User regular
    yeah that's about all you can do for audio

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    Currently they use foot pedals and they want to press and hold to rewind.

  • Options
    KhavallKhavall British ColumbiaRegistered User regular
    edited October 2016
    Ok I am having... just... the weirdest problem, with something that should be super simple.
    and in fact works perfectly in a slightly different context.

    Disclaimer that this has sort of been constantly the result of throwing stuff together and hoping that they work, so eventually I will re-do this in a way that doesn't rely on like 5 functions in a row that take each other as arguments within a function within an object

    Hell, that might be my next move if I can't figure this out.
    So I've got a function which takes in an Object "RhythmBeat", which contains 3 variables:
    Int Seed
    List<int[]> Result
    bool Tie

    Tie isn't currently working, so let's just focus on seed and result.

    Rhythms are stored as single integers, which are the index in a list of int[] arrays which contain all possible subdivisions of a beat. So basically there's a list that's just [4], [-4], [3,1], [2,2], etc.
    The result is just a weighted int[2], so it'll have [4,2], [6,22], etc. The first value is the Index of the rhythm in the rhythm list, and the second value is the weight.
    The seed is the index of the last beat's rhythm.

    The function, in theory is supposed to go through the potential results of the RhythmBeat given to it. The rhythmbeat is selected by another function which selects that specific rhythmbeat based on the seed. RhythmActual just returns the array that is the actual rhythm based on the index.

    So basically in the function which builds out the rhythm I have the following:
    //Initialization:
    		var BeatObject = findRhythm(CurrentRhythms[0].Seed, CurrentRhythms); //Finds the RhythmBeat object based on the seed, from a list of RhythmBeats(CurrentRhythms)
            var WeightedBeatObject = WeightedRhythmCell(BeatObject, Density); //Returns a (in theory, new) RhythmBeat object that has the weights for the results changed.
    		var BeatCell = RhythmResult(WeightedBeatObject); //Picks one of the results at random, based on the new weights(returns int)
    		var Beat = RhythmActual(BeatCell); //Creates a list of the actual resultant rhythm based on the integer returned
    		//Also checks for next beat, to deal with ties and rests at beginning of beat.
    		var nextBeatObject = findRhythm(BeatCell, CurrentRhythms); //Returns RhythmBeat
            var WeightedNextBeatObject = WeightedRhythmCell(nextBeatObject, Density); //Returns RhythmBeat
    		var nextBeatCell = RhythmResult(WeightedNextBeatObject); //Returns int
    		var nextBeat = RhythmActual(nextBeatCell); //Returns int[]
    
    
    //Then, when going through the melody:
    
    if (RhythmCounter >= Beat.Count())
                {
                    //RhythmCounter subtracts the nubmer of rhythms in the beat(-1), so that if the RhythmCounter is 2 above(in the case of a tied measure), the next rhythm will be the second note, rather than the first. 
                    //Debug.WriteLine("RhythmCounter was > than Beat.Count.  RhythmCounter was: " + RhythmCounter + ", Beat.Count was: " + Beat.Count());
                    RhythmCounter -= Beat.Count();
                    //Debug.WriteLine("RhythmCounter reduced by Beat.Count+1. New RhythmCounter is: " + RhythmCounter);
                    BeatObject = nextBeatObject; //Turns next rhythms into current rhythms.
                    BeatCell = nextBeatCell;
                    Beat = nextBeat;
    
                    nextBeatObject = findRhythm(RhythmSeed, CurrentRhythms); //Finds next rhythmbeat based on the seed(int) and the list of current rhythms.
                    WeightedNextBeatObject = WeightedRhythmCell(nextBeatObject, Density); //Returns rhythmbeat with weights.
                    nextBeatCell = RhythmResult(WeightedNextBeatObject); //Returns int - which beat index was chosen
                    nextBeat = RhythmActual(nextBeatCell); //Returns int[] actual rhythms in the beat
                    RhythmSeed = nextBeatCell; //Rhythmseed is the int that was chosen as the seed for the next generation
                    i++; //Increases the beat count
                }
    
    

    Which is fine, in theory. It's gotten a little messy, but it works without the weighted parts.
    The WeightedRhythmCell is where I start to run into problems, which basically is this:
    	RhythmBeat WeightedRhythmCell(RhythmBeat rhythmSeed, int Density) //Takes rhythmbeat and desired Density
    	{
    		var WeightedResult = rhythmSeed; //Creates local variable of rhythmbeat so as to not interfere with current beat.
            //Weights towards number of notes meeting density.
            Debug.WriteLine("Number of results to check =" + WeightedResult.Result.Count()); //Debugging since I can't figure this out.
    		foreach (int[] potentialResult in WeightedResult.Result)  //Weights the results towards beats which contain numbers equal to or close to the desired density.
    		{
                Debug.WriteLine("Incoming Potential Result Weight = " + potentialResult[1]);
    			if (RhythmActual(potentialResult[0]).Count() == Density){
    				potentialResult[1] *= 5;
    			}
    			else if (Math.Abs(Density - RhythmActual(potentialResult[0]).Count()) <=1){
    				potentialResult[1] *= 2;
    			}
                if (potentialResult[1] <= 0) { potentialResult[1] = 1; } //Makes sure the weight can't go below 0 - in theory I don't need this since I'm not un-weighting anything in this function, but it's a safety thing.
                Debug.WriteLine("Outoing Potential Result Weight = " + potentialResult[1]); //Debugging because I cannot figure this damn thing out.
    		}
    		return WeightedResult; //Returns the 
    	}
    		}
    }
    


    So what's the problem? Well, somehow, the result weights are going from an expected range of about 1-200 or so, to a range of about 1-2,000,000,000.

    It seems that even though this is supposed to create a new RhythmBeat, and not in any way affect the RhythmBeat that it's taking in, that for some reason it totally is affecting the rhythmbeat that it's taking in.

    The debug output looks like this:
    Number of results to check =1
    Incoming Potential Result Weight = 1
    Outoing Potential Result Weight = 5
    Number of results to check =3
    Incoming Potential Result Weight = 31
    Outoing Potential Result Weight = 155
    Incoming Potential Result Weight = 5
    Outoing Potential Result Weight = 10
    Incoming Potential Result Weight = 10
    Outoing Potential Result Weight = 20
    Number of results to check =5
    Incoming Potential Result Weight = 9
    Outoing Potential Result Weight = 45
    Incoming Potential Result Weight = 5
    Outoing Potential Result Weight = 5
    Incoming Potential Result Weight = 7
    Outoing Potential Result Weight = 14
    Incoming Potential Result Weight = 22
    Outoing Potential Result Weight = 44
    Incoming Potential Result Weight = 4
    Outoing Potential Result Weight = 4
    Number of results to check =3
    Incoming Potential Result Weight = 155
    Outoing Potential Result Weight = 775
    Incoming Potential Result Weight = 10
    Outoing Potential Result Weight = 20
    Incoming Potential Result Weight = 20
    Outoing Potential Result Weight = 40

    It's clearly re-writing the incoming RhythmBeat's Weights, and it is absolutely not supposed to do that even a little. I've tried changing pretty much every step of the process where it returns the actual RhythmBeat so that it creates a new one and writes new results but... nothing. It keeps ballooning the weights like crazy, while just trying to complete a single line.
    And in theory, the only thing that gets passed around per note, and not over-written is the integer that's the seed, so I have no idea what is possibly even happening.

    I'm going to take a lunch break and hope that maybe clearing my head will help, but if anyone has any ideas as to why this thing is deciding to exponentially increase numbers on a thing that should never change I'd much appreciate any help.

    Khavall on
  • Options
    ecco the dolphinecco the dolphin Registered User regular
    edited October 2016
    Real quick, but is this C#?
    var WeightedResult = rhythmSeed; //Creates local variable of rhythmbeat so as to not interfere with current beat.
    

    If so, then the above does not do what you commented it to do.

    It does not create a local copy - it creates a local variabled called "WeightedResult" which holds a reference to the existing instance - i.e. WeightedResult still refers to the original rhythmSeed.

    If you've got something similar in your function, then when you modify WeightedResult, you end up modifying the original rhythmSeed, which is what you're experiencing.

    ecco the dolphin on
    Penny Arcade Developers at PADev.net.
  • Options
    KhavallKhavall British ColumbiaRegistered User regular
    edited October 2016
    Real quick, but is this C#?
    var WeightedResult = rhythmSeed; //Creates local variable of rhythmbeat so as to not interfere with current beat.
    

    If so, then the above does not do what you commented it to do.

    It does not create a local copy - it creates a local variabled called "WeightedResult" which holds a reference to the existing instance - i.e. WeightedResult still refers to the original rhythmSeed.

    If you've got something similar in your function, then when you modify WeightedResult, you end up modifying the original rhythmSeed, which is what you're experiencing.

    That's what I thought too, which is why I then also changed it to:
    var WeightedResult=new RhythmBeat{
    Seed=rhythmSeed.Seed;
    Result = rhythmSeed.Result;
    Tie = rhythmSeed.Tie;
    }
    

    Would that still have the same effect?

    EDIT: Also to clean it up a little, since I only need the List<int[]>, it now, instead of taking a rhythmbeat, takes a list<int[]> (and returns a list<int[]>) and opens with
    var WeightedList = new List<int[]>(rhythmSeed);
    
    with the same problem.

    Khavall on
  • Options
    bowenbowen How you doin'? Registered User regular
    I'm fairly positive that setting properties like that is "pass by value" in c#'s case.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    hippofanthippofant ティンク Registered User regular
    Khavall wrote: »
    Real quick, but is this C#?
    var WeightedResult = rhythmSeed; //Creates local variable of rhythmbeat so as to not interfere with current beat.
    

    If so, then the above does not do what you commented it to do.

    It does not create a local copy - it creates a local variabled called "WeightedResult" which holds a reference to the existing instance - i.e. WeightedResult still refers to the original rhythmSeed.

    If you've got something similar in your function, then when you modify WeightedResult, you end up modifying the original rhythmSeed, which is what you're experiencing.

    That's what I thought too, which is why I then also changed it to:
    var WeightedResult=new RhythmBeat{
    Seed=rhythmSeed.Seed;
    Result = rhythmSeed.Result;
    Tie = rhythmSeed.Tie;
    }
    

    Would that still have the same effect?

    Depends on what type rhythmSeed.Result is. If it's not a primitive, you'll have the same problem.

  • Options
    KhavallKhavall British ColumbiaRegistered User regular
    hippofant wrote: »
    Khavall wrote: »
    Real quick, but is this C#?
    var WeightedResult = rhythmSeed; //Creates local variable of rhythmbeat so as to not interfere with current beat.
    

    If so, then the above does not do what you commented it to do.

    It does not create a local copy - it creates a local variabled called "WeightedResult" which holds a reference to the existing instance - i.e. WeightedResult still refers to the original rhythmSeed.

    If you've got something similar in your function, then when you modify WeightedResult, you end up modifying the original rhythmSeed, which is what you're experiencing.

    That's what I thought too, which is why I then also changed it to:
    var WeightedResult=new RhythmBeat{
    Seed=rhythmSeed.Seed;
    Result = rhythmSeed.Result;
    Tie = rhythmSeed.Tie;
    }
    

    Would that still have the same effect?

    Depends on what type rhythmSeed.Result is. If it's not a primitive, you'll have the same problem.

    rhythmSeed.Result is a List<int[]>

  • Options
    ecco the dolphinecco the dolphin Registered User regular
    Khavall wrote: »
    Real quick, but is this C#?
    var WeightedResult = rhythmSeed; //Creates local variable of rhythmbeat so as to not interfere with current beat.
    

    If so, then the above does not do what you commented it to do.

    It does not create a local copy - it creates a local variabled called "WeightedResult" which holds a reference to the existing instance - i.e. WeightedResult still refers to the original rhythmSeed.

    If you've got something similar in your function, then when you modify WeightedResult, you end up modifying the original rhythmSeed, which is what you're experiencing.

    That's what I thought too, which is why I then also changed it to:
    var WeightedResult=new RhythmBeat{
    Seed=rhythmSeed.Seed;
    Result = rhythmSeed.Result;
    Tie = rhythmSeed.Tie;
    }
    

    Would that still have the same effect?

    Aha! You're 80% of the way there!

    Both Seed and Tie will be copies, because they are int/bool - or more generally known as "Value Types"
    Assigning one value type variable to another copies the contained value.

    But Result is a List<int[]>, which is a Reference type to a Reference type. List<> is a reference type, and int[] is a reference type.

    So what you've done there is made copies of Seed and Tie, but made a reference to the original Result.

    Now, the tricky part is that even if you make a separate copy of the Result list, you need to make sure that you haven't kept the same references to the arrays. So in other words, you'll also need to make a copy of the arrays as well.

    Does that make sense?

    I'm just starting my work day, but I can draw a diagram in a few hours which might explain things better.

    Penny Arcade Developers at PADev.net.
  • Options
    hippofanthippofant ティンク Registered User regular
    Khavall wrote: »
    hippofant wrote: »
    Khavall wrote: »
    Real quick, but is this C#?
    var WeightedResult = rhythmSeed; //Creates local variable of rhythmbeat so as to not interfere with current beat.
    

    If so, then the above does not do what you commented it to do.

    It does not create a local copy - it creates a local variabled called "WeightedResult" which holds a reference to the existing instance - i.e. WeightedResult still refers to the original rhythmSeed.

    If you've got something similar in your function, then when you modify WeightedResult, you end up modifying the original rhythmSeed, which is what you're experiencing.

    That's what I thought too, which is why I then also changed it to:
    var WeightedResult=new RhythmBeat{
    Seed=rhythmSeed.Seed;
    Result = rhythmSeed.Result;
    Tie = rhythmSeed.Tie;
    }
    

    Would that still have the same effect?

    Depends on what type rhythmSeed.Result is. If it's not a primitive, you'll have the same problem.

    rhythmSeed.Result is a List<int[]>

    Then, as per my understanding of C# - which isn't great, you'll have the same issue.

    Your problem is that when you x = y, and y is not a primitive, x and y are both pointers/references to the same object, such that if you modify x, you will also modify y.

    If y is a primitive, then x will be a copy of y. (And then you can't modify x or y, since they're primitives anyways.)

  • Options
    IlpalaIlpala Just this guy, y'know TexasRegistered User regular
    Rend wrote: »

    Oh god. I didn't see the braces the first time.

    I DIDN'T SEE THEM!

    FF XIV - Qih'to Furishu (on Siren), Battle.Net - Ilpala#1975
    Switch - SW-7373-3669-3011
    Fuck Joe Manchin
  • Options
    InfidelInfidel Heretic Registered User regular
    This is one reason why I like C.

    Having to use pointers means you have to understand pointers. While it is harder to get going, you don't get stuck with "mysterious" behaviour that no one ever explained right and that is usually not intuitive at all.

    I really like Javascript but I also understand this stuff from old C/etc. dev work, so I can recognize when I am dealing with a mutation or not. Most of my mentoring in Javascript is teaching people about mutability and what it will do and how to sniff it out.

    OrokosPA.png
  • Options
    KhavallKhavall British ColumbiaRegistered User regular
    Aha!

    Well that was a pain in the butt!

    Thanks guys! It now correctly copies the results as a separate thing.

    That is a lot of work to create a new list of the arrays, but hey, it works!

  • Options
    hippofanthippofant ティンク Registered User regular
    Infidel wrote: »
    This is one reason why I like C.

    Having to use pointers means you have to understand pointers. While it is harder to get going, you don't get stuck with "mysterious" behaviour that no one ever explained right and that is usually not intuitive at all.

    I really like Javascript but I also understand this stuff from old C/etc. dev work, so I can recognize when I am dealing with a mutation or not. Most of my mentoring in Javascript is teaching people about mutability and what it will do and how to sniff it out.
    free Infidel
    

  • Options
    ecco the dolphinecco the dolphin Registered User regular
    edited October 2016
    Khavall wrote: »
    Aha!

    Well that was a pain in the butt!

    Thanks guys! It now correctly copies the results as a separate thing.

    That is a lot of work to create a new list of the arrays, but hey, it works!

    Damn, I had just gotten a proof of concept to work haha

    Well, here it is anyway, if you're interested:
            static void Main(string[] args)
            {
                var originalData = new List<int[]>();
                originalData.Add(new int[] { 1, 2 });
                originalData.Add(new int[] { 3, 4 });
    
                //var copiedData  = a.ConvertAll(array => array); // Incorrect - keeps a reference to the original array
                var copiedData = originalData.ConvertAll(array => (int[])array.Clone()); // Makes a copy of the original array
    
                originalData.ElementAt(0)[0] = 9; // Modify the original data - see if the copied data also changes
    
                copiedData.ForEach(array => Console.WriteLine(String.Join(",", array.Select(val => val.ToString()))));
    
                Console.ReadLine();
    
                return;
            }
    

    ecco the dolphin on
    Penny Arcade Developers at PADev.net.
This discussion has been closed.