Wednesday, October 31, 2007

VB. It's good for something...

For better or worse, I spend a lot of time trying to explain real life situations in code.
Below is the thought process of Paul McCartney when writing "Let it Be".

Public Class Beatles

Private hardship As New Death(Of Mother)
Protected help As Mother
Private WithEvents life As New Paul()

Public Sub New()
If help Is Nothing Then
life.Experiece(hardship)
life.Experiece(New Hour(Of Darkness))
End If
End Sub

Public Sub Sing() Handles life.TimeExperienced
While life.Contains(hardship)
Me.help = hardship.Help
Whisper.Words(Of Wisdom)(help)
life.RecoverFrom(hardship)
End While
End Sub
End Class

Class Trouble

End Class
Class Death(Of T)
Inherits Time(Of Trouble)

End Class

Class Time(Of T)

Private _help As Mother = New Mary()
Public Property Help() As Mother
Get
Return _help
End Get
Set(ByVal value As Mother)
_help = value
End Set
End Property
End Class

Class Hardship
Inherits Time(Of Trouble)

Public ReadOnly Property Cause() As Time(Of Trouble)
Get
Return New Darkness()
End Get
End Property
End Class

Class Darkness
Inherits Time(Of Trouble)

End Class

Class Hour(Of T As Time(Of Trouble))
Inherits Time(Of Trouble)
End Class

Class Times(Of T)
Inherits List(Of Time(Of T))
End Class


Class Life(Of T)
Private times As New Times(Of T)

Function Contains(ByVal time As Time(Of T)) As Boolean
Return times.Contains(time)
End Function
Sub Experiece(ByVal time As Time(Of T))
times.Add(time)
RaiseEvent TimeExperienced()
End Sub
Sub RecoverFrom(ByVal time As Time(Of T))
times.Remove(time)
End Sub

Default Public ReadOnly Property Time(ByVal index As Integer) As Time(Of T)
Get
Return times(index)
End Get
End Property

Public Event TimeExperienced()
End Class
Class Paul
Inherits Life(Of Trouble)
End Class


Public Class Whisper
Shared Sub Words(Of T)(ByVal m As Mother)
Console.WriteLine(m.Advice)
End Sub
End Class

Public Class Mother

Private _advice As String
Public Property Advice() As String
Get
Return _advice
End Get
Set(ByVal value As String)
_advice = value
End Set
End Property
End Class
Class Mary
Inherits Mother
Public Sub New()
Advice = "let it be"
End Sub
Public Overrides Function ToString() As String
Return Advice
End Function
End Class

Public Class Wisdom
Inherits Knowledge
End Class
Public Class Knowledge

End Class


Public Class Hit
Public Shared Sub Create()
Dim b As New Beatles
End Sub
End Class

Thursday, October 25, 2007

Wanted:

Programmer.
Must work be able to work unreasonable amounts of time, on impossible deadlines, with insufficient resources, inadequate compensation, conflicting orders, and be have ability to read boss's mind and accept responsibility for everything that goes wrong.

Wednesday, October 3, 2007

Finally! Someone with a brain!

This post should be put on a pedestal and bowed down to by millions.
I think every developer on the planet that has had to dip into legacy code has been in the same situation as I was a month ago: "It's my fault that the stored proc sent out 15,000 of the same email? How was i supposed to know it was in a while loop? The loop itself was nested 300 lines deep with 300 lines within it! It took 10 seconds of scrolling to get from the declaration to the end!"

Monday, October 1, 2007

An Eternal Paradox

/*
* Why the Internet cannot stop making references to MC Hammer.
*/
namespace Paradox
{
using System;
using The90s;

static class Program
{
static void Main()
{
Hit og = Hit.Create();
Console.WriteLine(og.StillCool.ToString()); // PM NOTE: fails unit tests.
Hit meme = new Hit(true);
Console..WriteLine(meme.StillCool.ToString()); / PM NOTE: fails unit tests.
}
}

namespace The90s
{
public class
Hit
{
bool _stillCool = false;

public Hit(bool stopUse)
{
_stillCool = stopUse;
}
static bool Stop()
{
return false;
}
static bool Collaborate()
{
return false;
}
static bool Listen()
{
return false;
}
public static Hit Create()
{
if (Stop())
return new Hit(Collaborate() && Listen());
else return new Hit(true);
}
public bool StillCool
{
get { return _stillCool; }
}
}
}
}