Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?
You are not logged in.
Wasn't this thread for simply stating your coding style, and not arguing about something entirely subjective and case-specific?
Nah, it was also kinda for discussing where people felt like it. Hence the notice to keep this thread friendly.
Zumza wrote:destroyer123 wrote:while (!Generate()) { }
where Generate is a function which returns true when it has finished.
I don't think ending up with such code in production is a good idea. You'd better replace it with async/await pattern or with an event.
Oh, this wasnt a multiple thread thing, in this example, Generate made the generator perform one step of the maze generation algorithm. I think I had a step by step generation option, as well as the one where it just generated completely (the example), which is why I couldnt just have the loop in the Generate function
In that case you probably should've made the function recursive instead.
Offline
In that case you probably should've made the function recursive instead.
I just found something like this much easier than having a recursive function (from memory so probably not correct):
// All at once
while (!Generate()) { }
Draw();
// Step by step (timed)
while (!Generate()) {
Draw();
Thread.Sleep(100);
}
Draw();
//Step by step (button)
on button press:
if (Generate()) // Disable button
Draw();
The Generate while loop thing was the simplest way that I could think of to be able to do all three
Offline
den3107 wrote:In that case you probably should've made the function recursive instead.
I just found something like this much easier than having a recursive function (from memory so probably not correct):
// All at once while (!Generate()) { } Draw(); // Step by step (timed) while (!Generate()) { Draw(); Thread.Sleep(100); } Draw(); //Step by step (button) on button press: if (Generate()) // Disable button Draw();
The Generate while loop thing was the simplest way that I could think of to be able to do all three
I can agree with the last two because they don't have an empty block. (since this was the thing this started from)
Wasn't this thread for simply stating your coding style, and not arguing about something entirely subjective and case-specific?
Coding style doesn't relay only on the way you're aligning your code, but also its logic, way of working etc.
Everybody edits, but some edit more than others
Offline
Why don't we all read some of the Google style guides for other languages and mash them all up for C#? I know there isn't a specific one, but since C# is similar to Java or C, we can use their style guides.
We can avoid (further) arguments on this topic and all live happily ever after.
Offline
Why don't we all read some of the Google style guides for other languages and mash them all up for C#? I know there isn't a specific one, but since C# is similar to Java or C, we can use their style guides.
We can avoid (further) arguments on this topic and all live happily ever after.
Well, C# DOES have a coding convention.
And for the rest, this topic isn't necessarily meant to convince each other into using one uniform style. but just for "funsies". See who does what and maybe people can learn something, like Zumza's nesting avoidance..
Offline
[ Started around 1732966435.8259 - Generated in 0.034 seconds, 12 queries executed - Memory usage: 1.47 MiB (Peak: 1.6 MiB) ]