- 1
- 2
- 3
- 4
- 5
- 6
typedef enum
{
FFALSE = 0,
TTRUE,
MMAYBE
} Truth_t;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+188
typedef enum
{
FFALSE = 0,
TTRUE,
MMAYBE
} Truth_t;
ну почти квантовое программирование.
ЗЫ да, это из С++ программы.
+175
class BalanceValue
{
/* ... */
BalanceValue( int pFamilyGroupId,
int ContractId,
int pProfileId,
int pSncode,
long pPurchaseSeqNo,
int pBundledProductId,
time_t pCreationDate,
time_t pNextresetDate,
char pState,
double pAggregate,
double pCredit,
double pInitialCredit,
double pReservation,
char pColor,
double pProrateFactor,
int pCurrencyId,
int pUomId,
time_t pSnapshotDate,
unsigned long pSequenceNumber,
time_t pValidFrom,
time_t pValidTo,
int pPricingAlternative,
int pCocTariffId,
time_t pLastresetDate,
double pLateCallAggr );
/* ... */
void getAllValues( int& pContractId,
int& pProfileId,
int& pSncode,
long& pPurchaseSeqNo,
int& pBundledProductId,
time_t& pNextResetDate,
char& pState,
double& pAggregate,
double& pCredit,
double& pInitialCredit,
double& pReservation,
char& pColor,
double& pProRateFactor,
int& pCurrencyId,
int& pUomId,
time_t& pSnapShotDate ,
unsigned long& pSequenceNumber,
time_t& pValidFrom,
time_t& pValidTo,
int& pPricingAlternative,
int& pCocTariffId,
time_t& pLastResetDate,
double& pLateCallAggr );
/* ... */
};
чудо интерфейс. 25 параметров у конструктора, 23 параметров (рефернсы!) у геттера. кто больше?
ЗЫ как оба реализованы можете сами догадатся. и еще несколько других методов в подобном стиле.
ЗЗЫ да, есть и нормальные геттеры.
ЗЗЗЫ нет, другого конструктора нету.
ЗЗЗЗЫ нет, разнести значение по мелким структурам, более приемлимым человеческому мозгу, народ не догадывается. не наш так сказать стиль. (да, есть естественная групировка параметров по источнику откуда они берутся.)
+154
<?php
if (isset($_POST['update'])) {
$kolcen=mysql_real_escape_string($_POST['kolcen']);
$tovar=mysql_real_escape_string($_POST['tovar']);
$descr=mysql_real_escape_string($_POST['descr']);
$price=intval($_POST['price']);
$price2=intval($_POST['price2']);
$price3=intval($_POST['price3']);
$id=intval($_POST['update']);
$zag1=mysql_real_escape_string($_POST['zag1']);
$zag2=mysql_real_escape_string($_POST['zag2']);
$zag3=mysql_real_escape_string($_POST['zag3']);
switch($kolcen){
case '3':$updatetovar = mysql_query ("UPDATE `tovar3` SET `tovar`='$tovar',`descr`='$descr',`price`='$price',`price2`='$price2',`price3`='$price3' WHERE `id`='$id' and `id`='$serv'");
break;
case '2': $updatetovar = mysql_query ("UPDATE `tovar2` SET `tovar`='$tovar',`descr`='$descr',`price`='$price',`price2`='$price2' WHERE `id`='$id' and `id`='$serv'");
break;
case '1':$updatetovar = mysql_query ("UPDATE `tovar` SET `tovar`='$tovar',`descr`='$descr',`price`='$price' WHERE `id`='$id' and `pizzaid`='$service'");
break;
case '2images': $updatetovar = mysql_query ("UPDATE `2images` SET `tovar`='$tovar',`descr`='$descr',`price`='$price',`price2`='$price2',`price3`='$price3',`img`='$img',`zag1`='$zag1',`zag2`='$zag2',`zag3`='$zag3' WHERE `id`='$id' and `id`='$serv'");
break;
}
?>
Народ зацените мой код плиз на предмет говнокода, и если чето не так то дайте совет . Этот код для админки добавления товаров. Есть 4 типа категорий, товар с одной ценой, с двумя, с тремя, и товар с двумя картинками. В зависимости от типа категории делаем запрос к базе
+159
protected function readConfig($configPath) {
$ini = parse_ini_file($configPath);
foreach ($ini as $key => $value) {
$config[$key] = $value;
}
return $config;
}
+120
var trimmedKey = Regex.Split(key, @"\.").Last();
if (_options.Any(o => o == ModelBinderOptions.ExpectUnderLineSymbolAsPrefixDelimiter))
trimmedKey = Regex.Split(trimmedKey, "_").Last();
if (_allRequiredParameters.Any(p => p.Key.ToLower() == trimmedKey.ToLower()))
{
var param = _allRequiredParameters.Single(p => p.Key.ToLower() == trimmedKey.ToLower());
try
{
if (param.Value != typeof(string))
{
if (Nullable.GetUnderlyingType(param.Value) != null)
{
try
{
var parseMethod = Nullable.GetUnderlyingType(param.Value).GetMethods().Where(m => m.Name == "Parse").First(m => m.GetParameters().Count() == 1 && m.GetParameters().First().ParameterType == typeof(string));
var value = parseMethod.Invoke(null, new object[] { form[key] });
formValues.Add(param.Key, value);
}
catch(Exception)
{
formValues.Add(param.Key, null);
}
}
else
{
var parseMethod = param.Value.GetMethods().Where(m => m.Name == "Parse").First(m => m.GetParameters().Count() == 1 && m.GetParameters().First().ParameterType == typeof(string));
var value = parseMethod.Invoke(null, new object[] { form[key] });
formValues.Add(param.Key, value);
}
}
else
{
formValues.Add(param.Key, form[key]);
}
}
catch (Exception)
{
// Если произошла ошибка парсинга - печально, но ничего не поделать
}
}
Фееричный парсер
+171
var e=("article,aside,footer,header,nav,section").split(',');
Найдено в дебрях одного сайта.
+150
$black = "eval|file_get_contents|mysql_(.*?)|include|require|readfile|show_source|highlight|import_request_variables|extract|parse_str|assert|passthru|exec|system|shell_exec|proc_open|fopen|echo";
if(preg_match("#\<\?(.*?)($black)(.*?)\?\>#i", $template)){
exit ("1");
break;
}
+159
#include <math.h>
#include <iostream>
using namespace std;
void main()
{ int month,day;
cin>>month,day;
int den=1;
switch(month)
{ case 1: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==31){cout<<"month: "<<month+1<<endl<<den;}
break;
case 2: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==28){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 3:cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 4:cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==30){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 5: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 6: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==30){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 7: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 8: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 9: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==30){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 10: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 11: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==30){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 12: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
}
cin.get();
cin.get();
}
+82
/*
todo it seems that code below will be right, when client will be changed
*/
Вот такой емкий комментарий перед 200 закоментированными строками кода
+147
if ($a = 1) {
...бла-бла-бла
}