Click here to Skip to main content
15,886,199 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.

 
GeneralAt least... Pin
imagiro19-Apr-15 23:15
imagiro19-Apr-15 23:15 
GeneralIRS Developers gone wild ? Pin
Slow Eddie10-Apr-15 3:25
professionalSlow Eddie10-Apr-15 3:25 
GeneralRe: IRS Developers gone wild ? Pin
Ranjan.D10-Apr-15 3:37
professionalRanjan.D10-Apr-15 3:37 
GeneralRe: IRS Developers gone wild ? Pin
ZurdoDev10-Apr-15 5:31
professionalZurdoDev10-Apr-15 5:31 
GeneralRe: IRS Developers gone wild ? Pin
kmoorevs10-Apr-15 8:51
kmoorevs10-Apr-15 8:51 
GeneralRe: IRS Developers gone wild ? Pin
Ravi Bhavnani10-Apr-15 11:50
professionalRavi Bhavnani10-Apr-15 11:50 
GeneralRe: IRS Developers gone wild ? Pin
charlieg11-Apr-15 6:49
charlieg11-Apr-15 6:49 
GeneralOverpaid, over engineered and totally in-yer-face... Pin
Duncan Edwards Jones9-Apr-15 12:16
professionalDuncan Edwards Jones9-Apr-15 12:16 
One of my own little beauties to show why I should be kept on a short leash...

VB
''' <summary>
''' Projection over the client event stream to summarise the state of a client
''' </summary>
Public NotInheritable Class ClientSummaryProjection
    Inherits ProjectionBase(Of AggregateIdentifiers.ClientAggregateIdentity)
    Implements IEventConsumer(Of AggregateIdentifiers.ClientAggregateIdentity, Events.Client.NewBazaarCreatedEvent)
    Implements IEventConsumer(Of AggregateIdentifiers.ClientAggregateIdentity, Events.Client.BazaarClosedEvent)
    Implements IEventConsumer(Of AggregateIdentifiers.ClientAggregateIdentity, Events.Client.CreatedEvent)
    Implements IEventConsumer(Of AggregateIdentifiers.ClientAggregateIdentity, Events.Client.ClientNameChangedEvent)
    Implements IEventConsumer(Of AggregateIdentifiers.ClientAggregateIdentity, Events.Client.DisabledEvent)
    Implements IEventConsumer(Of AggregateIdentifiers.ClientAggregateIdentity, Events.Client.EnabledEvent)

    ReadOnly m_identity As AggregateIdentifiers.ClientAggregateIdentity
    ''' <summary>
    ''' The aggregate identifier of the client over which this projection applies
    ''' </summary>
    Public Overrides ReadOnly Property Identity As AggregateIdentifiers.ClientAggregateIdentity
        Get
            Return m_identity
        End Get
    End Property


    Private m_openBazaars As Integer
    ''' <summary>
    ''' The number of Bazaars open at this point in time
    ''' </summary>
    Public ReadOnly Property OpenBazaars As Integer
        Get
            Return m_openBazaars
        End Get
    End Property

    Private m_totalBazaars As Integer
    ''' <summary>
    ''' The total number of bazaars ever opened for this client at this point in time
    ''' </summary>
    Public ReadOnly Property TotalBazaars As Integer
        Get
            Return m_totalBazaars
        End Get
    End Property

    Private m_clientName As String
    ''' <summary>
    ''' The full display name to use for the client
    ''' </summary>
    Public ReadOnly Property ClientName As String
        Get
            Return m_clientName
        End Get
    End Property


    Private m_enabled As Boolean = True
    ''' <summary>
    ''' Is the client enabled or not
    ''' </summary>
    ''' <remarks>
    ''' Disabling a client prevents them appearing in the application but does not require deletion of their history
    ''' </remarks>
    Public ReadOnly Property Enabled As Boolean
        Get
            Return m_enabled
        End Get
    End Property

    Public Overrides Sub ConsumeEvent(sequence As Integer, eventToConsume As IEvent(Of AggregateIdentifiers.ClientAggregateIdentity))

        If IsPriorEvent(sequence) Then
            ' This projection ignores out-of-sequence events
            Return
        End If

        'Process the event depending on its type..
        If (TypeOf (eventToConsume) Is Events.Client.NewBazaarCreatedEvent) Then
            ConsumeNewBazaarCreatedEvent(sequence, eventToConsume)
        End If

        If (TypeOf (eventToConsume) Is Events.Client.BazaarClosedEvent) Then
            ConsumeBazaarClosedEvent(sequence, eventToConsume)
        End If

        If (TypeOf (eventToConsume) Is Events.Client.CreatedEvent) Then
            ConsumeCreatedEvent(sequence, eventToConsume)
        End If

        If (TypeOf (eventToConsume) Is Events.Client.ClientNameChangedEvent) Then
            ConsumeNameChangedEvent(sequence, eventToConsume)
        End If

        If (TypeOf (eventToConsume) Is Events.Client.EnabledEvent) Then
            ConsumeEnabledEvent(sequence, eventToConsume)
        End If

        If (TypeOf (eventToConsume) Is Events.Client.DisabledEvent) Then
            ConsumeDisableEvent(sequence, eventToConsume)
        End If

        ' Update the current sequence after the event is consumed
        SetSequence(sequence)
    End Sub


    Public Sub New(ByVal aggregateidentity As AggregateIdentifiers.ClientAggregateIdentity)
        m_identity = aggregateidentity
    End Sub

    Public Sub ConsumeNewBazaarCreatedEvent(sequence As Integer, eventToConsume As Events.Client.NewBazaarCreatedEvent) Implements IEventConsumer(Of AggregateIdentifiers.ClientAggregateIdentity, Events.Client.NewBazaarCreatedEvent).ConsumeEvent

        m_totalBazaars += 1
        m_openBazaars += 1

    End Sub

    Public Sub ConsumeBazaarClosedEvent(sequence As Integer, eventToConsume As Events.Client.BazaarClosedEvent) Implements IEventConsumer(Of AggregateIdentifiers.ClientAggregateIdentity, Events.Client.BazaarClosedEvent).ConsumeEvent

        m_openBazaars -= 1

    End Sub

    Public Sub ConsumeCreatedEvent(sequence As Integer, eventToConsume As Events.Client.CreatedEvent) Implements IEventConsumer(Of AggregateIdentifiers.ClientAggregateIdentity, Events.Client.CreatedEvent).ConsumeEvent

        m_clientName = eventToConsume.ClientName

    End Sub

    Public Sub ConsumeNameChangedEvent(sequence As Integer, eventToConsume As Events.Client.ClientNameChangedEvent) Implements IEventConsumer(Of AggregateIdentifiers.ClientAggregateIdentity, Events.Client.ClientNameChangedEvent).ConsumeEvent
        m_clientName = eventToConsume.ClientName
    End Sub

    Public Sub ConsumeDisableEvent(sequence As Integer, eventToConsume As Events.Client.DisabledEvent) Implements IEventConsumer(Of AggregateIdentifiers.ClientAggregateIdentity, Events.Client.DisabledEvent).ConsumeEvent
        m_enabled = False
    End Sub

    Public Sub ConsumeEnabledEvent(sequence As Integer, eventToConsume As Events.Client.EnabledEvent) Implements IEventConsumer(Of AggregateIdentifiers.ClientAggregateIdentity, Events.Client.EnabledEvent).ConsumeEvent
        m_enabled = True
    End Sub
End Class


I assure you it seemed like a good idea near the top of this rabbit hole...

modified 9-Apr-15 18:38pm.

GeneralRe: Overpaid, over engineered and totally in-yer-face... PinPopular
Marc Clifton9-Apr-15 14:27
mvaMarc Clifton9-Apr-15 14:27 
GeneralRe: Overpaid, over engineered and totally in-yer-face... Pin
Duncan Edwards Jones9-Apr-15 20:23
professionalDuncan Edwards Jones9-Apr-15 20:23 
GeneralRe: Overpaid, over engineered and totally in-yer-face... Pin
User 1013254610-Apr-15 3:53
User 1013254610-Apr-15 3:53 
GeneralRe: Overpaid, over engineered and totally in-yer-face... Pin
Duncan Edwards Jones10-Apr-15 4:27
professionalDuncan Edwards Jones10-Apr-15 4:27 
GeneralRe: Overpaid, over engineered and totally in-yer-face... Pin
User 1013254610-Apr-15 4:31
User 1013254610-Apr-15 4:31 
GeneralRe: Overpaid, over engineered and totally in-yer-face... Pin
Sander Rossel10-Apr-15 9:40
professionalSander Rossel10-Apr-15 9:40 
GeneralRe: Overpaid, over engineered and totally in-yer-face... Pin
User 1013254610-Apr-15 11:55
User 1013254610-Apr-15 11:55 
GeneralRe: Overpaid, over engineered and totally in-yer-face... Pin
Sander Rossel10-Apr-15 12:03
professionalSander Rossel10-Apr-15 12:03 
GeneralRe: Overpaid, over engineered and totally in-yer-face... Pin
Eddy Vluggen11-Apr-15 8:54
professionalEddy Vluggen11-Apr-15 8:54 
GeneralRe: Overpaid, over engineered and totally in-yer-face... Pin
Sander Rossel11-Apr-15 9:10
professionalSander Rossel11-Apr-15 9:10 
GeneralRe: Overpaid, over engineered and totally in-yer-face... Pin
User 1013254612-Apr-15 22:29
User 1013254612-Apr-15 22:29 
GeneralRe: Overpaid, over engineered and totally in-yer-face... Pin
Sinisa Hajnal13-Apr-15 0:24
professionalSinisa Hajnal13-Apr-15 0:24 
GeneralRe: Overpaid, over engineered and totally in-yer-face... Pin
Eddy Vluggen13-Apr-15 0:34
professionalEddy Vluggen13-Apr-15 0:34 
GeneralRe: Overpaid, over engineered and totally in-yer-face... Pin
Nagy Vilmos13-Apr-15 1:51
professionalNagy Vilmos13-Apr-15 1:51 
GeneralRe: Overpaid, over engineered and totally in-yer-face... Pin
Duncan Edwards Jones13-Apr-15 2:12
professionalDuncan Edwards Jones13-Apr-15 2:12 
GeneralWhy do they call it "hard" coding? Pin
Duncan Edwards Jones7-Apr-15 6:37
professionalDuncan Edwards Jones7-Apr-15 6:37 
GeneralRe: Why do they call it "hard" coding? Pin
Tim Carmichael7-Apr-15 7:04
Tim Carmichael7-Apr-15 7:04 

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.