Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 20 21 [22] 23 24 ... 796

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

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #315 on: January 09, 2012, 08:50:50 pm »

In what ever application you decide to employ it.

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #316 on: January 09, 2012, 08:52:09 pm »

This
Code: [Select]
public Bottle this[int index]
{
get
{
return this.fridge[index];
}
}
is invoked by this
Code: [Select]
int x = GetSomeInt();
Bottle stolenBottle = max[x];

Where exactly?

You're asking where the call is, right?  It's the
Code: [Select]
max[x]
Logged

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #317 on: January 09, 2012, 08:56:28 pm »

This
Code: [Select]
public Bottle this[int index]
{
get
{
return this.fridge[index];
}
}
is invoked by this
Code: [Select]
int x = GetSomeInt();
Bottle stolenBottle = max[x];

Where exactly?

You're asking where the call is, right?  It's the
Code: [Select]
max[x]

What's with the max? Is that a keyword or a Drink?
Logged

Darvi

  • Bay Watcher
  • <Cript> Darvi is my wifi.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #318 on: January 09, 2012, 08:57:22 pm »

It's Max.

It's him.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #319 on: January 09, 2012, 09:00:58 pm »

What's with the max? Is that a keyword or a Drink?

It is an variable.

For example, for a more complete bit of code...

Code: [Select]
Person max = new Person();
int x = GetSomeInt();
Bottle stolenBottle = max[x];

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #320 on: January 09, 2012, 09:03:21 pm »

It's Max.

It's him.

You don't post in here enough, Darvi.

So the interdimensional fridge that you conjure drinks out of thin air from is a part of your Person definition...where are you carrying an interdimensional fridge?  Your pocket?

What other neat tricks can C# do?
Logged

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #321 on: January 09, 2012, 09:03:38 pm »

So the index method is a member of Person.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #322 on: January 09, 2012, 09:09:16 pm »

So the interdimensional fridge that you conjure drinks out of thin air from is a part of your Person definition...where are you carrying an interdimensional fridge?  Your pocket?
It's insides occupy the same dimensional space as your standard police box...
What other neat tricks can C# do?
Fucking everything man, including partial classes.

If you had this is one file
Code: [Select]
    partial class Person
    {
        int age;
    }

and then this in a separate file
Code: [Select]
    partial class Person
    {
        public int Age
        {
            get
            {
                return age;
            }
        }
    }

It would compile just fine.

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #323 on: January 09, 2012, 09:14:39 pm »

So the interdimensional fridge that you conjure drinks out of thin air from is a part of your Person definition...where are you carrying an interdimensional fridge?  Your pocket?
It's insides occupy the same dimensional space as your standard police box...
What other neat tricks can C# do?
Fucking everything man, including partial classes.

If you had this is one file
Code: [Select]
    partial class Person
    {
        int age;
    }

and then this in a separate file
Code: [Select]
    partial class Person
    {
        public int Age
        {
            get
            {
                return age;
            }
        }
    }

It would compile just fine.

While it's really cool that such a thing works, it seems to me like it would be a terrible idea to actually do that...

Quote
It's insides occupy the same dimensional space as your standard police box...
So it's the TARDIS?
Logged

Darvi

  • Bay Watcher
  • <Cript> Darvi is my wifi.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #324 on: January 09, 2012, 09:16:20 pm »

No, it's big enough to contain one.

So, I have a programming exam next week and I feel like I should do something to keep my skills from getting rusty. Somebody please give me something to do.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #325 on: January 09, 2012, 09:18:51 pm »

While it's really cool that such a thing works, it seems to me like it would be a terrible idea to actually do that...
Can't add to a partial class after it compiles, so it is safe.
It pretty much tells the compiler to look for all partial classes of the same name and concat them together. Shit makes dealing with large, bulky classes a lot easier, especially once inner classes get involved.

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #326 on: January 09, 2012, 09:22:45 pm »

While it's really cool that such a thing works, it seems to me like it would be a terrible idea to actually do that...
Can't add to a partial class after it compiles, so it is safe.
It pretty much tells the compiler to look for all partial classes of the same name and concat them together. Shit makes dealing with large, bulky classes a lot easier, especially once inner classes get involved.

Wouldn't that make it dramatically harder to debug?  Especially if, like in your quick example, you have some of the same things defined twice?  I'm all for breaking up code for simplicity, but duplicate data scares me and I think I can achieve reasonable cleanliness of massive classes with inner classes and whatnot just fine with whitespace and comments.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #327 on: January 09, 2012, 09:26:59 pm »

How so?
Visual studio takes you to the cause of an uncaught exception, so you don't find yourself scanning through two classes in that case, otherwise I find it makes debugging a lot faster.
For example, I often have half a class for functionality, and half a class that handles persistence, so if I want to change how something is persisted I don't need to even look at the functionality. If a problem comes up while saving stuff, I know exactly where to look, otherwise I can safely ignore it, cutting down on the code I need to scan through.

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #328 on: January 09, 2012, 09:31:12 pm »

How so?
Visual studio takes you to the cause of an uncaught exception, so you don't find yourself scanning through two classes in that case, otherwise I find it makes debugging a lot faster.
For example, I often have half a class for functionality, and half a class that handles persistence, so if I want to change how something is persisted I don't need to even look at the functionality. If a problem comes up while saving stuff, I know exactly where to look, otherwise I can safely ignore it, cutting down on the code I need to scan through.

I was more referring to glitches such that the code compiles and runs fine, but doesn't run as expected.  Then you have to know where in your code to look.  Usually that's easy, but sometimes it's not.  If you intelligently divide code as your described, that probably helps, though.  Also, how good is Visual Studio about zooming to the correct place, finding relevant errors, and giving meaningful error messages?
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #329 on: January 09, 2012, 09:35:09 pm »

Yes to the first.
Yes to the second.
Depends to the third.

If you are using only the .net framework than it gives very meaningful error messages, but if you are using a third party library? Depends on how well they set it up. Normally when you get an exception it tells you the cause and gives you several tips to fix it, or even a link to the MSDN documentation that might be helpful, but if libtcod for example throws an error, good fucking luck.
Pages: 1 ... 20 21 [22] 23 24 ... 796