Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 275 276 [277] 278 279 ... 796

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

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #4140 on: March 06, 2013, 11:22:37 pm »

Shitdamn... I've completely forgotten the path to my own svn repo, and I no longer have any links to it.  I can log into the server, but I don't know how to get the information out of the damn thing.

woot. I spoke to soon. I HAVE NOT! Lost access the code for my abandoned projects.
« Last Edit: March 06, 2013, 11:57:39 pm by Nadaka »
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

MadocComadrin

  • Bay Watcher
  • A mysterious laboratory goblin!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4141 on: March 07, 2013, 11:45:55 am »

So, here's a question for the professional programmers that visit here: Web resume: Yay or nay? (...in addition to the traditional paper resume)
Logged

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #4142 on: March 07, 2013, 11:50:00 am »

So, here's a question for the professional programmers that visit here: Web resume: Yay or nay? (...in addition to the traditional paper resume)
Have your resume on linkedin as well as in a word document.

Have a short 1 page resume that hits the highlights. And have a full resume with details of jobs and projects, this one should come in at 2 to 4 pages but not more.

Hosting it on a website or file server is not necessary. Recruiters can find your resume on linkedin if you make it public, and otherwise you would just be emailing the word doc to people you are trying get a job from. Paper resume's only really have a place these days at job fairs.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #4143 on: March 08, 2013, 09:46:16 am »

I am trying OpenCL right now.

My current state of mind can be best represented by my avatar. "What is going on I don't even help aghghh stay calm stay calm-"

>_> For some reason, using the CL_DEVICE_TYPE_DEFAULT makes it correct, but CL_DEVICE_TYPE_GPU yields incorrect answers and I can't tell why. It may be because of how the tutorial writer set up his C code, but I can't really tell. :S
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4144 on: March 08, 2013, 10:45:23 am »

I am trying OpenCL right now.
Making your erosion simulation massively parallel you are?
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #4145 on: March 08, 2013, 10:59:06 am »

Yeah. It's already easy to parallelize, but I kinda broke myself over openCL. It has the worst documentation ever. And the C-style code doesn't help, since I'm not used to it ;_; High level languages spoil ya :v

Anyways, I'll try again whenever I have time. No idea when that'll be ;_; I can't tell why openCL code seems so tangled and hard to understand... And also so much boilerplate.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

olemars

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4146 on: March 08, 2013, 05:21:39 pm »

Cuda has a nicer and better documented API, if you have an NVIDIA gpu that is. Faster than openCL too.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4147 on: March 08, 2013, 07:43:04 pm »

You know, I noticed Magma did something in his game that I kind of like, and I'm wondering if anybody has any good reason for me to not use it. Basically using singleton, but having static methods wrapped around the instance object, a very quick example

Code: [Select]
class Example
{
private static Example _instance;
private static Example getInstance()
{
if(_instance == null) _instance = new Example ();
return _instance;
}

private int x;
private Example ()
{
this.x = 5;
}

public static int GetX()
{
return getInstance().getX();
}

private int getX()
{
return this.x;
}
}

I can still have all the advantages that singleton has over static classes, but I can just call Example.GetX() rather than having to always refer to the instance.
Why should I not do this?

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #4148 on: March 08, 2013, 08:39:14 pm »

Well the implementation there isn't thread-safe, but that aside this is still a fairly standard singleton implementation. You still have all the pros and cons that go along with a singleton, though you do have a lot of what is essentially code duplication.

I'd recommend having the instance as just being a POCO/POJO the static functions use, to remove that duplication. Basically the instance is just a POCO/POJO that contains all the static variables.
« Last Edit: March 08, 2013, 08:47:01 pm by MorleyDev »
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4149 on: March 08, 2013, 08:44:11 pm »

Well yea, that one isn't tread safe, but it could easily be safed. I just wrote it up quickly without any thrills to make it as c#/java ambiguous as I could. I'm pretty sure that example would compile in both.
Although I did use c# naming convention...

As for code duplication, if I need a more complex method other than just returning a value, I have keep it all in the non-static method, so they won't be an issue.

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #4150 on: March 08, 2013, 08:50:15 pm »

As for code duplication, if I need a more complex method other than just returning a value, I have keep it all in the non-static method, so they won't be an issue.

Then you have a bunch of private functions that exist just to be called internally without actually increasing clarity or readability, seems like just adding pointless extra jumps to me.

So more like:
Code: [Select]
class Example
{
private class Instance
{
public Instance()
{
X = 5;
}

public int X { get; set; }
}

private static Instance _instance;
private static Instance getInstance()
{
if( _instance == null )
_instance = new Example ();
return _instance;
}


public static int GetX()
{
return getInstance().X;
}

public static int GetDoubleX()
{
return getInstance().X * 2;
}
}

( And of course I'd always question the situations where you think you gain from using a singleton instead of an injected dependency...should be a very rare thing imho :D )
« Last Edit: March 08, 2013, 08:52:25 pm by MorleyDev »
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4151 on: March 08, 2013, 08:54:34 pm »

Often for inheritance. In the above example I can't sneakily use a subclass of Example to change the function of GetDoubleX(), but if GetDoubleX() returned the value of non-static getDoubleX() I can do as I like.

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #4152 on: March 08, 2013, 08:55:56 pm »

Kinda seems like it's over-engineering a solution to a problem better solved by interfaces and dependency injection, but if you really think you need the singleton then yeah that's a valid reason.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4153 on: March 08, 2013, 09:00:34 pm »

Depends on the problem in question, but always nice to know I can do something in a way that just appeals to me more without shooting myself in the foot. If something is conceptually static, I like to be able to call it in a static manor, even if there is an object hiding in there.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4154 on: March 09, 2013, 02:37:29 am »

Okay, time to figure out a bunch of archaic C++ code to write a DFHack plugin!

Expect to see me often in the near future!
Pages: 1 ... 275 276 [277] 278 279 ... 796