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

No comments: