- 1
- 2
- 3
- 4
- 5
- 6
- 7
var Class = function () {
this.method = function () {
/* … */
};
};
Class = new Class();
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+157
var Class = function () {
this.method = function () {
/* … */
};
};
Class = new Class();
+145
$(function(){
oCatalog=new Catalog();
});
Catalog = function (){
function test (data){
alert(data);
}
}
+75
for ( Cluster c : Clusters.getInstance( ).listValues( ) ) {
stopNet.newInstance( ).dispatch( cluster );
}
Суровые калифорнийцы как всегда суровы...
−99
def __init__(self, pth = None):
self._tag = None
self._valid = False
self._pthtofile = pth
if pth != None:
try:
self._tag = tagpy.FileRef(pth).tag()
self._valid = True
except ValueError:
pass
Конструктор класса.
Дальше приходится всё время дёргать объект проверяя его на валидность.
Как переписать не так говнисто?
+145
private TaskScheduler scheduler;
protected TaskScheduler() {
}
public final TaskScheduler getScheduler() {
if (this.scheduler == null) {
this.scheduler = new TaskScheduler();
}
return this.scheduler;
}
мелочь, а смешно получилось ))
+183
table[^>]*((name[^>]*=[^>]*mainTable|id[^>]*=[^>]*mainTable)){1,2}
also check dis
http://govnokod.ru/853#comment2667
рейтинг: −1.8
"1 за и 0 против"
tags: stupid regex, regullar expression, govnokod bugs
−114
bool userNameChanged = true;
[userName isEqualToString:oldUserName]!=YES;
bool passwordChanged = true;
[password isEqualToString:oldPassword]!=YES;
bool retVal = true;
if(userNameChanged)
{
retVal &= setUserNameInPreferences(userName);
}
Чудеса сравнения
+117
widgetPanel.ID = new Guid(String.Format("{0:D32}", widgetInfo.Id));
// в другом месте
var widgetId = Convert.ToInt32(widgetPanel.ID.ToString().Replace('-', '0').TrimStart('0'));
Как узнать что именно надо класть на панель?
Очень просто - брать ее id типа Guid, а искать в списке классов с id типа int
Разумеется, никто не запрещал сделать что бы оба были guid, но это же совершенно не интересно.
+160
class XXX
{
function _item()
{
return $this->val = substr(__FUNCTION__,1);
}
function _lister()
{
return $this->val = substr(__FUNCTION__,1);
}
function item()
{
return ($this->val === __FUNCTION__);
}
function lister()
{
return ($this->val === __FUNCTION__);
}
function __construct()
{
$this->_lister();
}
}
В прицнипе пофиг что оно делает. Но смотреть без слез, имхо нельзя :)
+77
@Entity
@Table(name = "datastore")
public final class Datastore
{
@SequenceGenerator(name="SEQ_GEN", sequenceName="entity_id_seq", allocationSize = 1)
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "SEQ_GEN")
private long entityid;
public float capacity;
public String name;
public float usage;
public short vendor;
public short state;
public short health;
public short vmson;
public short vmsother;
@Transient private String uuid;
@Override public String toString() {
return String.format("Datastore{entityid=%d, capacity=%f, health=%d, name='%s', state=%d, usage=%f, vendor=%d, vmson=%d, vmsother=%d}",
entityid,
capacity,
health,
name,
state,
usage,
vendor,
vmson,
vmsother);
}
public long getEntityid() {
return entityid;
}
public void setEntityid(long entityid) {
this.entityid = entityid;
}
public float getCapacity() {
return capacity;
}
public void setCapacity(float capacity) {
this.capacity = capacity;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public float getUsage() {
return usage;
}
public void setUsage(float usage) {
this.usage = usage;
}
public short getVendor() {
return vendor;
}
public void setVendor(short vendor) {
this.vendor = vendor;
}
public short getState() {
return state;
}
public void setState(short state) {
this.state = state;
}
public short getHealth() {
return health;
}
public void setHealth(short health) {
this.health = health;
}
public short getVmson() {
return vmson;
}
public void setVmson(short vmson) {
this.vmson = vmson;
}
public short getVmsoff() {
return vmsother;
}
public void setVmsoff(short vmsoff) {
this.vmsother = vmsoff;
}
@Transient public void setUuid(String value) { this.uuid = value; }
}
Вот так жесткие швейцарские кодеры объявляют persistent beans.
Самый отжиг это не pubilc fields дублированные с getters/setters, а setter помеченный @Transient