Official Everybody Edits Forums

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.

#51 2017-04-28 01:44:35

den3107
Member
From: Netherlands
Joined: 2015-04-24
Posts: 1,025

Re: So what's your coding style?

Tomahawk wrote:

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.

destroyer123 wrote:
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

#52 2017-04-28 07:58:06

LukeM
Member
From: England
Joined: 2016-06-03
Posts: 3,009
Website

Re: So what's your coding style?

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

Offline

#53 2017-04-28 11:16:17

Zumza
Member
From: root
Joined: 2015-02-17
Posts: 4,645

Re: So what's your coding style?

destroyer123 wrote:
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)

Tomahawk wrote:

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

#54 2017-04-29 04:47:54

1448
Formerly alkazam1448
From: Numberland
Joined: 2015-04-12
Posts: 683
Website

Re: So what's your coding style?

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

#55 2017-04-29 13:26:57

den3107
Member
From: Netherlands
Joined: 2015-04-24
Posts: 1,025

Re: So what's your coding style?

1448 wrote:

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

den31071493468817657283

Board footer

Powered by FluxBB

[ Started around 1714164097.2015 - Generated in 0.054 seconds, 12 queries executed - Memory usage: 1.47 MiB (Peak: 1.59 MiB) ]