Mistři v programování na #hovnokod

Takový klasický setter :)

public function setStatus($status)
{
    if ($this->status == 'pending' && $status != 'pending') {

        $this->status = $status;
        $this->decided = new \DateTime();
        return true;
    }

    return false;
}

Anonymous,

Kdyz je potreba zmenit boolean

private static class OperationsMap implements Map, Serializable {
	private static final long serialVersionUID = 1L;

	private final Boolean TRUE = Boolean.TRUE;
	private final Boolean FALSE = Boolean.FALSE;

	//dalsi kod
}

Anonymous,

IFDEF pro každý bug

void wifi_start()
{
    #if WOP_A4_WIFI_API_SERVICE
#ifdef JIRA_WIFI0215_288
    uint32_t actual_flags = 0;
#endif //JIRA_WIFI0215_288
    OS_ERROR_CODE_T error;
#ifdef JIRA_WIFI0215_225
#if 0	//Disable the DCT
    /* Init DCT_1 */
    init_dct( );
    wiced_rtos_delay_milliseconds(1000);
#endif
#endif //JIRA_WIFI0215_225
    
#ifdef JIRA_WIFI0215_509	
     wwd_wifi_set_ioctl_value( WLC_SET_INTERFERENCE_MODE, 3, WWD_STA_INTERFACE );
#endif
#ifdef JIRA_WIFI0215_219	
    /* Register callbacks */
    wiced_network_register_link_callback( wifi_link_up, wifi_link_down, WICED_STA_INTERFACE );
#endif //JIRA_WIFI0215_219        

#ifdef JIRA_WIFI0215_288
    wiced_rtos_delay_milliseconds(1000);

    /* init flags for wifi async events */    
    wiced_rtos_init_event_flags( &g_wifiAsynEvent );
#endif     
    
#ifdef JIRA_WIFI0215_387
    wiced_rtos_init_timer  ( &update_radio_level, RADIO_LEVEL_UPDATE_PERIOD_MS, check_radio_level_event, NULL );

    // wiced_rtos_start_timer ( &update_radio_level );
#endif

#ifdef JIRA_WIFI0215_443
    host_rtos_init_semaphore( &scan_connect_semaphore );
    host_rtos_set_semaphore ( &scan_connect_semaphore, WICED_FALSE );
    
    wiced_rtos_init_timer ( &try_to_reconnect, RECONNECT_INTERVAL, reconnect_to_ap, NULL );
#endif //JIRA_WIFI0215_443

    wiced_set_ap_info_callback(wiced_vat_to_ap_info);
    /* finish wifi initialize */        
    g_isWifiInit = 1;

#ifdef JIRA_WIFI0215_288    
    while(1)
    {
        /* waiting for attach/detach event and send unsolict msg */
#ifdef JIRA_WIFI0215_443
        error = OS_EventWait(&g_wifiAsynEvent, &actual_flags, WIFI_ASYNC_EVENT_ATTACH | WIFI_ASYNC_EVENT_DETACH | WIFI_ASYNC_EVENT_RECONNECT, OS_FLAG_EVENT_ANY | OS_FLAG_CLEAR, TX_WAIT_FOREVER);
        assert(error == OS_ERR_OK);
#else      
        tx_event_flags_get( &g_wifiAsynEvent, (WIFI_ASYNC_EVENT_ATTACH | WIFI_ASYNC_EVENT_DETACH), TX_OR_CLEAR, &actual_flags, TX_WAIT_FOREVER );
#endif //JIRA_WIFI0215_443
#ifdef JIRA_WIFI0215_650
	if(g_flagSolicitedResponse == 0)
#endif
        send_Solicited_msg_to_wm( actual_flags );
#ifdef JIRA_WIFI0215_458
	send_keep_alive_data_package(actual_flags);
#endif

        actual_flags = 0;
    }
#endif //JIRA_WIFI0215_288
    #endif
}

Anonymous,

Produkcni kod. A pak se divi, ze je to pomale...

-- Delete User Log
DECLARE @intIdentityLog   as Int
DECLARE curTrans CURSOR
LOCAL FORWARD_ONLY
FOR SELECT
       UserLog_intIdentity
FROM tblUser_Log
WHERE UserLog_dtmDateRec BETWEEN @DateToPurge AND @dtmRetainAfter

OPEN   curTrans
FETCH NEXT FROM curTrans
INTO   @intIdentityLog
WHILE  @@FETCH_STATUS = 0
BEGIN
       SET @Processed = 'Y'
       IF @intTestMode<> 'Y'
       BEGIN
             DELETE FROM tblUser_Log
             WHERE CURRENT OF curTrans
       END
       ELSE
       BEGIN
             PRINT 'ULOGI : ' + CAST (@intIdentityLog AS varchar(10))
       END

       FETCH NEXT FROM curTrans INTO @intIdentityLog
END

CLOSE curTrans
DEALLOCATE curTrans

Lukáš Navrátil,

Ternární operátor v podmínce, ještě navíc má vedlejší účinky a ta podmínka je tam vlastně uplně zbytečně.

<body itemscope itemtype="http://schema.org/WebPage" class="<?php 
if (($homepage)?(print 'homepage '.$language):(print $language)); 
?> ">

Anonymous,