Click here to Skip to main content
15,888,803 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Recursive methods. Pin
Sander Rossel23-Dec-10 5:15
professionalSander Rossel23-Dec-10 5:15 
GeneralRe: Recursive methods. Pin
RobCroll24-Dec-10 4:46
RobCroll24-Dec-10 4:46 
GeneralRe: Recursive methods. Pin
#realJSOP26-Dec-10 5:04
mve#realJSOP26-Dec-10 5:04 
GeneralWhat a fright!! Pin
_Erik_22-Dec-10 4:55
_Erik_22-Dec-10 4:55 
GeneralRe: What a fright!! PinPopular
fjdiewornncalwe22-Dec-10 5:15
professionalfjdiewornncalwe22-Dec-10 5:15 
GeneralRe: What a fright!! Pin
_Erik_22-Dec-10 5:24
_Erik_22-Dec-10 5:24 
GeneralRe: What a fright!! Pin
Dwayne J. Baldwin27-Dec-10 7:31
Dwayne J. Baldwin27-Dec-10 7:31 
GeneralHow I accidentally slowed gr1d's server to a crawl... [modified] Pin
dawmail33321-Dec-10 22:08
dawmail33321-Dec-10 22:08 
Before I get started, some background:
gr1d[^] is a (very new) persistent multiplayer programming AI game: the idea is you code your agents and upload them, and let them do their thing. (Check it out, if you haven't!)

Now, with these agents, they have to inherit an interface. For brevity, I'll reduce it to the relevant details:
Public Class πRateSapient
Implements gr1d.API.Agent.IPirate1

...

Public Sub Tick(ByVal agentUpdate As Gr1d.Api.Agent.IAgentUpdateInfo) Implements ...
 ' Logic here
End Sub


(VB is NOT the code horror, thank you very much! :P )

Now, in my infinite wisdom, I started some abstractions. This included building it so all AIs under that schema (my search/claim/don't go picking fights) operated under the same logic.
How'd I do this? Well:
Public Module Logic

<Extension()>
Public Sub Tick(ByVal agent As πRateSapient, ByVal update As Agent.IAgentUpdateInfo)
 ' Logic here
End Sub


...
Can you see where this is going? I didn't.

Public Class πRateSapient
Implements gr1d.API.Agent.IPirate1

...

Public Sub Tick(ByVal agentUpdate As Gr1d.Api.Agent.IAgentUpdateInfo) Implements ...
 Me.Tick(agentUpdate)
End Sub


...
No debugging, no thought put into it, I just thought it'd call the extension method.
Whoops. And yeah, it was sloooow.

Moral of the story folks: think about your damn naming conventions, especially if you're using extension methods!!!
D'Oh! | :doh:

(And I was wondering why my agents did nothing!)

(Also, may I mention that running the game logic, and the site, on the same instance is also a bit of a horror?)

Hope you laughed. Laugh | :laugh:

[edit]
To be fair, I wasn't the only one with a recursive loop. But I sure as hell didn't help. xD
[/edit]
Don't forget to rate my post if it helped! Wink | ;)

"He has no enemies, but is intensely disliked by his friends."
"His mother should have thrown him away, and kept the stork."
"There's nothing wrong with you that reincarnation won't cure."
"He loves nature, in spite of what it did to him."
modified on Wednesday, December 22, 2010 6:05 AM

GeneralRe: How I accidentally slowed gr1d's server to a crawl... Pin
Dwayne J. Baldwin27-Dec-10 7:58
Dwayne J. Baldwin27-Dec-10 7:58 
GeneralRe: How I accidentally slowed gr1d's server to a crawl... Pin
dawmail33327-Dec-10 13:14
dawmail33327-Dec-10 13:14 
GeneralRe: How I accidentally slowed gr1d's server to a crawl... Pin
wizardzz27-Dec-10 11:21
wizardzz27-Dec-10 11:21 
GeneralTesting the obvious.... Pin
Rob Grainger16-Dec-10 5:02
Rob Grainger16-Dec-10 5:02 
GeneralRe: Testing the obvious.... Pin
_Erik_16-Dec-10 5:10
_Erik_16-Dec-10 5:10 
GeneralRe: Testing the obvious.... Pin
Mike Winiberg16-Dec-10 20:36
professionalMike Winiberg16-Dec-10 20:36 
GeneralRe: Testing the obvious.... Pin
Brady Kelly16-Dec-10 20:39
Brady Kelly16-Dec-10 20:39 
GeneralRe: Testing the obvious.... Pin
mbb0116-Dec-10 21:25
mbb0116-Dec-10 21:25 
GeneralRe: Testing the obvious.... Pin
R. Erasmus16-Dec-10 21:36
R. Erasmus16-Dec-10 21:36 
GeneralRe: Testing the obvious.... Pin
R. Erasmus16-Dec-10 21:34
R. Erasmus16-Dec-10 21:34 
GeneralRe: Testing the obvious.... Pin
Hosey^16-Dec-10 22:28
Hosey^16-Dec-10 22:28 
GeneralRe: Testing the obvious.... Pin
sjelen16-Dec-10 23:48
professionalsjelen16-Dec-10 23:48 
GeneralRe: Testing the obvious.... Pin
Dietmar Kern17-Dec-10 3:09
Dietmar Kern17-Dec-10 3:09 
GeneralRe: Testing the obvious.... Pin
sjelen17-Dec-10 6:13
professionalsjelen17-Dec-10 6:13 
GeneralRe: Testing the obvious.... Pin
ely_bob17-Dec-10 7:58
professionalely_bob17-Dec-10 7:58 
GeneralIDataAccessLayer Pin
ColinBashBash15-Dec-10 11:46
ColinBashBash15-Dec-10 11:46 
GeneralRe: IDataAccessLayer Pin
GibbleCH16-Dec-10 3:37
GibbleCH16-Dec-10 3:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.