Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 516 517 [518] 519 520 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 902764 times)

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7755 on: September 07, 2015, 11:38:27 am »

Though I'm still not convinced that comments are totally bad, I do notice myself using them less often as I develop my skills more.
comments are really important imo, a big thing is just understanding when to comment and when not to comment.
It's a good reason to use full English names for functions and variables. For example a function like DistanceSquared(vector, vector) really doesn't need a comment, but if you were lazy and called it "d2" it would need a comment. But someone who saw "d2(a,b)" in your code somewhere might have to backtrack to the function declaration to read that comment, which kinda sucks.

With auto-complete in modern IDEs there's basically no excuse not to use fully descriptive names everywhere. It just makes the code easier to read and needs less comments.
I'm fairly sure that if you put a comment next to (or above) a function declaration in Visual Studio, then hover over that function anywhere else in the code, it displays that comment.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7756 on: September 07, 2015, 11:49:29 am »

That helps but it's still better to be able to read the code as English in realtime without having to hover.

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7757 on: September 07, 2015, 11:51:19 am »

Was mostly intended as a joke, really.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Dutrius

  • Bay Watcher
  • No longer extremely unavailable!
    • View Profile
    • Arcanus Technica
Re: if self.isCoder(): post() #Programming Thread
« Reply #7758 on: September 07, 2015, 11:54:25 am »

I've just tried that, and it doesn't seem to work. (for C# anyway)

Pre-edit: It doesn't seem to work for Visual Basic either.

Hovering over the procedure/function only shows the variable it returns, and any arguments it takes.
Logged
No longer extremely unavailable!
Sig text
ArcTech: Incursus. On hold indefinitely.

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7759 on: September 07, 2015, 11:56:43 am »

Huh, I'm fairly sure I saw that functionality for... Probably C++, I forgot. Might have been mistaken.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Dutrius

  • Bay Watcher
  • No longer extremely unavailable!
    • View Profile
    • Arcanus Technica
Re: if self.isCoder(): post() #Programming Thread
« Reply #7760 on: September 07, 2015, 12:02:35 pm »

Just checked, and it does indeed work with C++ (the comment has to be on the line above the declaration).

But not VB or C#, which is what I use.
Logged
No longer extremely unavailable!
Sig text
ArcTech: Incursus. On hold indefinitely.

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7761 on: September 07, 2015, 12:05:55 pm »

That's pretty strange.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7762 on: September 07, 2015, 12:14:26 pm »

Just checked, and it does indeed work with C++ (the comment has to be on the line above the declaration).

But not VB or C#, which is what I use.
That's pretty strange.
I agree, it is strange that he uses VB and C# ... j/k

Though seriously, most likely a different team was in charge of adding that feature to C++ to the guys who worked on VB/C#, so it was a case of someone in the C++ group going "wouldn't it be cool if ..." and getting the Ok to implement that feature, rather than something that was decided by a design committee overseeing the entire software suite.
« Last Edit: September 07, 2015, 12:18:27 pm by Reelya »
Logged

Dutrius

  • Bay Watcher
  • No longer extremely unavailable!
    • View Profile
    • Arcanus Technica
Re: if self.isCoder(): post() #Programming Thread
« Reply #7763 on: September 07, 2015, 12:17:51 pm »

Nah, I only use C#, not VB.
Logged
No longer extremely unavailable!
Sig text
ArcTech: Incursus. On hold indefinitely.

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #7764 on: September 07, 2015, 12:48:12 pm »

C# has a built in and standardised documentation-comment method using xml. Looks something like:
/// <summary></summary>
Shows all pretty-like in the autocomplete.

C++ doesn't have this, doxygen is the most common one but not the only one, so they probably just show nearby comments as a fallback.
Logged

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7765 on: September 07, 2015, 12:50:54 pm »

C# actually has a bit more in-depth comment system for functions, actually, that MS tries to make you follow.

Code: [Select]
    /// <summary>
    /// Adds a single layer to a multi-layer sprite.
    /// </summary>
    /// <param name="character">ASCII character of the sprite, layed out like DF tilesets.</param>
    /// <param name="color">Date of birth of your firstborn child for the purposes of sacrifice.</param>
    public void AddTile(int character = 0, Color color = default(Color))
    { ... }
Logged

Dutrius

  • Bay Watcher
  • No longer extremely unavailable!
    • View Profile
    • Arcanus Technica
Re: if self.isCoder(): post() #Programming Thread
« Reply #7766 on: September 08, 2015, 01:38:27 pm »

Speaking of Visual Studio, Unity now supports it as a default IDE, as of Unity 5.2.
Logged
No longer extremely unavailable!
Sig text
ArcTech: Incursus. On hold indefinitely.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7767 on: September 09, 2015, 11:19:22 am »

I've come across something I need to solve which is a Traveling Salesman Problem. There are 120 cities on grid locations on a 100x100 grid. You can move in 8 directions for equal cost, so the distance from city -> city is min(x,y). So basically a discrete, symmetric TSP on a grid.

For the 120 cities, they're static so an offline exact solution would be great, but I'd also like a dynamic version which could take different points and calculate a tour (maybe ~50 points for those).

I was wondering if anyone had implemented this sort of thing before and could give me some pointers on an algorithm which would be a good balance of speed and accuracy for problems of this scale (and maybe some optimizations that take into account the specific of the problem vs the general TSP).

RoguelikeRazuka

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7768 on: September 10, 2015, 03:13:39 am »

What programming language would you suggest to learn to a novice? I study C/C++ at university and I feel genuine hatred towards it. I also had Lisp classes in the previous term which I liked much better, but people say it has not much application these days.
« Last Edit: September 10, 2015, 04:51:02 am by RoguelikeRazuka »
Logged

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7769 on: September 10, 2015, 03:26:38 am »

The people who tell you that Lisp has no applications probably never have tried to apply it. It can be a challenge to find a job where you can program in Lisp, but it certainly is a practically useful language and there are such jobs out there. Paul Graham calls it a "secret weapon".
I personally recommend Common Lisp (and there the SBCL implementation). If you already like Lisp, you are at a severe advantage on the road to learning it. Many people develop a kind of hatred towards it for some reason, which hinders their learning progress, of course (and makes them make statements about stuff they actually don't know anything about).

I can understand your hatred towards C/C++. It seems like a world of workarounds, hacks and quick ugly fixes for awful design decisions made ages ago (like that awful compilation process). Common Lisp also has some questionable design decision in its history, but the fixes for them aren't ugly.
Logged
Taste my Paci-Fist
Pages: 1 ... 516 517 [518] 519 520 ... 796