Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
R

RooN3y

@RooN3y
About
Posts
5
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Closures (C#)
    R RooN3y

    ChatGPT explained this to me. I feel bad that I couldn't figure this one out :( Question to ChatGPT:

    In this example c# code "i" can equal 11. can you fix it?

    for (int i=0; i <= 10; i++)
    {
    var task = Task.Run(async () =>
    {
    var convertResp = await StartTestConvert(i);
    ... other stuff
    });
    }

    Response:

    Yes, in the provided code, the variable i is captured by the async lambda expression, which means by the time the async operations inside the lambda complete, the value of i may have changed. To fix this, you need to capture the loop variable correctly. Here's a way to do it:

    for (int i = 0; i <= 10; i++)
    {
    int current = i; // Capture the current value of i
    var task = Task.Run(async () =>
    {
    var convertResp = await StartTestConvert(current);
    // ... other stuff
    });
    }

    By capturing the loop variable inside the loop, you ensure that each async operation receives its own copy of the loop variable, preventing the issue where the value of i changes before the async operation completes.

    The Lounge csharp com performance help question

  • We're not all in the US: Annual rant about dates
    R RooN3y

    Feel your pain with AWS. We have to set the culture code at the start of every Lambda we have because our main website sends dates in the british dd/mm/yyyy format and lambdas default to US format regardless of the region. The first 2 weeks of January where fun! I'm blaming AWS but to be honest it's probably the Linux image they use to spin up the lambda. But I don't want to blame Linux. Stupid AWS

    The Lounge database cloud json question

  • Git Question
    R RooN3y

    Could it be worth completely separating them? So put each in their own git repository and then set your framework project up to create a nuget package that the other project can simply reference. You can make private nuget packages and have this all handled by a CI solution like Github Actions

    The Lounge question visual-studio collaboration help

  • I don't like code reviews
    R RooN3y

    One thing not mentioned in the other replies is the readability from the very first word. In your example of

    a = b + c

    If a was named better then I wouldn't need to read the rest of the code to understand what I'm dealing with. So in the long run I can gain general understanding at a glance. You should only need to dig deeper if you need to, and with each well described method and variable I can gain a better understanding. Personally a = b + c is a bit lazy and I wouldn't want to have to maintain your code. This talk on Clean code really hits the nail on the head for me when it comes to clean code - JeremyBytes Live! - Clean Code: Homicidal Maniacs Read Code, Too! - YouTube[^]

    The Lounge csharp com performance tutorial question

  • Code Reviews
    R RooN3y

    Assuming this is at work. Have a discussion and vote on the syntax you all want to use and document it as a standard in your workplace only. These debates happen all the time and the only way to move forward is to all agree on a single way. The code is easy to understand when it's all int he same format, There's less time thinking about what option to take, and no one will reformat files to their own preferred way. Just make it clear that there is no "right" or "wrong" way of doing this. All accepted syntax by the IDE is correct, but being aligned is more important. and when voting make sure to include an option for "no preference". Make sure you document these decisions in a "[Company name] Best practices". Eventually the debates will stop and you will have some awesome best practices for new starters to just pick up

    The Lounge question discussion
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups