Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
tef
May 30, 2004

-> some l-system crap ->

TRex EaterofCars posted:

We used to have this nonsense along with making sure we named each class with a public static String MODULE.

A good bit of civil disobedience, mixed with claiming control of the SVN repo and strategic layoffs got rid of that horse poo poo real fast.

We used to have to update version numbers in multiple files in every svn commit. It was the source of frequent conflicts.

Adbot
ADBOT LOVES YOU

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
And you did it more than once before writing a commit hook to do it automatically?

tef
May 30, 2004

-> some l-system crap ->
svn:keywords revision

http://svnbook.red-bean.com/en/1.4/svn.advanced.props.special.keywords.html

tef
May 30, 2004

-> some l-system crap ->

Plorkyeran posted:

And you did it more than once before writing a commit hook to do it automatically?

I wasn't 'allowed' to change it for four months or so.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

tef posted:

I wasn't 'allowed' to change it for four months or so.

That's the best part.

"Listen, you're doing everything totally the wrong way."
"I know but we're not going to change it now"
"Why not, it'll take me 15 minutes to set up"
"Because I said so"
"Please retire :("

tef
May 30, 2004

-> some l-system crap ->

TRex EaterofCars posted:

That's the best part.

"Listen, you're doing everything totally the wrong way."
"I know but we're not going to change it now"
"Why not, it'll take me 15 minutes to set up"
"Because I said so"
"Please retire :("

This is why I maintain a build system written over ten years ago for a startup that's only about 18 months old.

spiritual bypass
Feb 19, 2008

Grimey Drawer

tef posted:

This is why I maintain a build system written over ten years ago for a startup that's only about 18 months old.

Do you like working in a fast-paced dynamic environment?!

Zombywuf
Mar 29, 2008

Today I profiled our code and identified a major hotspot, with about 100,000 calls to the second function per page hit:

code:
public static string MakeUrlFriendly(string text)
{
	text = StringUtilities.AssignNotNullString(text);

	var unicodeChars_192_382 = new List<string> { "A", "A", "A", "A", "A", "A", "AE", "C", "E", "E", "E", "E", "I", "I", "I", "I", "D", "N", "O", "O", "O", "O", "O", "x", "O", "U", "U", "U", "U", "Y", "TH", "ss", "a", "a", "a", "a", "a", "a", "ae", "c", "e", "e", "e", "e", "i", "i", "i", "i", "o", "n", "o", "o", "o", "o", "o", "\\", "o", "u", "u", "u", "u", "y", "th", "y", "A", "a", "A", "a", "A", "a", "C", "c", "C", "c", "C", "c", "C", "c", "D", "d", "D", "d", "E", "e", "E", "e", "E", "e", "E", "e", "E", "e", "G", "g", "G", "g", "G", "g", "G", "g", "H", "h", "H", "h", "I", "i", "I", "i", "I", "i", "I", "i", "I", "i", "IJ", "ij", "J", "j", "K", "k", "k", "L", "l", "L", "l", "L", "l", "L", "l", "L", "l", "N", "n", "N", "n", "N", "n", "n", "N", "n", "O", "o", "O", "o", "O", "o", "OE", "oe", "R", "r", "R", "r", "R", "r", "S", "s", "S", "s", "S", "s", "S", "s", "T", "t", "T", "t", "T", "t", "U", "u", "U", "u", "U", "u", "U", "u", "U", "u", "U", "u", "W", "w", "Y", "y", "Y", "Z", "z", "Z", "z", "Z", "z" };
	var unicodeChars_536_359 = new List<string> { "S", "s", "T", "t" };


	for(int i = 192, j = 0; i <= 382 && j < unicodeChars_192_382.Count; i++, j++)
	{
		text = text.Replace(UnicodeCode(i), unicodeChars_192_382[j]);
	}

	for(int i = 536, j = 0; i <= 539 && j < unicodeChars_536_359.Count; i++, j++)
	{
		text = text.Replace(UnicodeCode(i), unicodeChars_536_359[j]);
	}

	return text;
}

public static string UnicodeCode(int code)
{
	var result = new string((char)code, 1);
	return result;
}

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Man, every time I look at that code, I see something new that's wrong with it :psypop:

Lysandus
Jun 21, 2010
I saw this today and just stared in wonder.

code:
public static final int COLOR_DARK_GREEN = Color.DARKGREEN;
public static final int COLOR_DARK_BLUE  = Color.DARKBLUE;
Color.DARKGREEN and Color.DARKBLUE are already static constants in another class. Why do they need to be re-static-constanted?

:psyduck:

king_kilr
May 25, 2007
If you think that's a coding horror, your codebase is probably ok. I can think of a totally valid reason for that. The Color class isn't under your control and features general color management things, for your app you want to have a consistant UI, and you're starting with their definitions of what constitutes DARK GREEN, but that might be changed in the future.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

king_kilr posted:

If you think that's a coding horror, your codebase is probably ok. I can think of a totally valid reason for that. The Color class isn't under your control and features general color management things, for your app you want to have a consistant UI, and you're starting with their definitions of what constitutes DARK GREEN, but that might be changed in the future.

No, actually, it makes about as much sense as:

code:
public static final int SEVEN = 7;
If it were as you suggest, it should be named:

code:
public static final int COLOR_UI_PRIMARY = Color.DARKGREEN
(or similar)

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Jabor posted:

No, actually, it makes about as much sense as:

code:
public static final int SEVEN = 7;
If it were as you suggest, it should be named:

code:
public static final int COLOR_UI_PRIMARY = Color.DARKGREEN
(or similar)

There's only one "seven"; there's thousands of shades which can be called "dark green".

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

king_kilr posted:

If you think that's a coding horror, your codebase is probably ok. I can think of a totally valid reason for that. The Color class isn't under your control and features general color management things, for your app you want to have a consistant UI, and you're starting with their definitions of what constitutes DARK GREEN, but that might be changed in the future.
..and if that changes in the future, so does COLOR_DARK_GREEN. What?

Nippashish
Nov 2, 2005

Let me see you dance!

Orzo posted:

..and if that changes in the future, so does COLOR_DARK_GREEN. What?

But it can be fixed by just changing the definition of COLOR_DARK_GREEN instead of tracking down the (presumably several) places where a dark green color is used.

Volte
Oct 4, 2004

woosh woosh
Why wouldn't you just specify a particular shade of dark green in the first place if you cared that much

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy
Maybe someone specified "dark green" and the developer just picked the default implementation and left the separate declaration in case it needs to be changed? :shobon:

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
So if Constants.DOT == "."; is in our code (and it is!), that's cool, because someone might decide to change the definition of a period one day. Just in case.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Kilson posted:

So if Constants.DOT == "."; is in our code (and it is!), that's cool, because someone might decide to change the definition of a period one day. Just in case.
it's a lot easier for some picky boss to say "can you make the buttons a bit darker" than to redefine the english language

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Janin posted:

it's a lot easier for some picky boss to say "can you make the buttons a bit darker" than to redefine the english language

Then it should be labelled something like BUTTON_COLOR instead.

...do you write code like this yourself and are trying to defend it, or something?

BigRedDot
Mar 6, 2008

The only place something like that makes sense is if you are writing an abstraction layer to hide several different underlying platform options.

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

Jabor posted:

Then it should be labelled something like BUTTON_COLOR instead.

...do you write code like this yourself and are trying to defend it, or something?

It's not particularly hard to imagine being instructed to "make it dark green", and using that so it can be easily changed in case that isn't the "right" dark green. It might have made more sense to put it under BUTTON_COLOUR or whatever, but for all we know it then actually is - as well as LABEL_COLOR and LINE_COLOR and BORDER_COLOR and ten other ones like it.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Jonnty posted:

It's not particularly hard to imagine being instructed to "make it dark green", and using that so it can be easily changed in case that isn't the "right" dark green. It might have made more sense to put it under BUTTON_COLOUR or whatever, but for all we know it then actually is - as well as LABEL_COLOR and LINE_COLOR and BORDER_COLOR and ten other ones like it.

Then, as I suggested before, we have UI_PRIMARY_COLOR or similar.

All the benefits of COLOR_DARK_GREEN, but even more flexible for if you don't want it to be dark green any more!

A A 2 3 5 8 K
Nov 24, 2003
Illiteracy... what does that word even mean?
Something I think we can all agree on is that dark green is the best color for a bike shed.

Bozart
Oct 28, 2006

Give me the finger.

A A 2 3 5 8 K posted:

Something I think we can all agree on is that dark green is the best color for a bike shed.

The only place something like that makes sense is if you are painting a base layer to hide several different underlying ugly colors.

evensevenone
May 12, 2001
Glass is a solid.
Maybe somewhere else it says that the UI_PRIMARY_COLOR is COLOR_DARK_GREEN and this is just so when some jackass graphic designer comes in and says "Our corporate branding rules specify Pantone 3442 for dark green and on my lovely uncalibrated monitor it doesn't quite match this test patch I am holding next to it under a fluorescent lamp. Also I have no idea how color works. Or monitors. I just need to find a reason for this to fail my review in order to prove to someone that I actually do something around here. FIX IT." you can fix it easily.

adrenaline_junket
May 29, 2005
gotta get a rush!
If we were to follow the rules of CSS class/id naming then that constant is invalid.

One should never write a class (or in this case a variable) where it describes an attribute.

Because COLOUR_DARK_GREEN may end up being changed to return blue and suddenly the variable name is misleading and the code has begun to rot.

Jabor is right, the variable should be named based on what object it represents, not an attribute of that object.

for instance BUTTON_COLOR, TABLE_COLOR, FRAME_COLOR, HIGHLIGHT_COLOR...

Nigglypuff
Nov 9, 2006


BUY ME BONESTORM
OR
GO TO HELL
Color values should never be specified directly in your code. They should always be loaded from an external XML config file.

shrughes
Oct 11, 2008

(call/cc call/cc)

Nigglypuff posted:

Color values should never be specified directly in your code. They should always be loaded from an external XML config file.

NOOOOOOOOOOOOOOO


You are a moron. Don't even speak. Recommending an XML config file???

This is a joke, right? XML config files are for scrubs. Your worldview is, and always has been, obsolete.

baquerd
Jul 2, 2007

by FactsAreUseless
Instead of XML, I set up a database called "My Objects" and I just add a new table for every CSS element id selector I want to use, then set up individual columns on each table depending on the attributes I want to use. Each of these tables has its own reference table for colors and such so there's no accidents changing a color in one place and having it change in another. For CSS class selectors, I just make a new table referencing all existing element id selectors and I made a trigger to auto-cascade/delete bi-directionally.

Any advice to polish this guy further?

shrughes
Oct 11, 2008

(call/cc call/cc)

baquerd posted:

Any advice to polish this guy further?

You should probably wrap your columns' values inside <column_name></column_name> so that you can serialize them more easily.

baquerd
Jul 2, 2007

by FactsAreUseless

shrughes posted:

You should probably wrap your columns' values inside <column_name></column_name> so that you can serialize them more easily.

Nice, that'll really cut down on the post-processing actually, thanks! I came up with a helpful naming scheme that should improve code readability if you want to borrow it: if the element or object existed in HTML 3 or before, I use perl_syntax and if it's 4.0 or later I use javaSyntax. Still working on some parsing issues though, so I've got it replacing every tag with a block of DHTML that gives me blinking iframes for some visual debugging.

shrughes
Oct 11, 2008

(call/cc call/cc)

baquerd posted:

Nice, that'll really cut down on the post-processing actually, thanks! I came up with a helpful naming scheme that should improve code readability if you want to borrow it: if the element or object existed in HTML 3 or before, I use perl_syntax and if it's 4.0 or later I use javaSyntax.

Let's not forget HTML 3.2, a version number which, the last time I checked, is greater than 3 and less than 4.0. We could use ALLCAPS for HTML 3.2 elements.

baquerd posted:

Still working on some parsing issues though, so I've got it replacing every tag with a block of DHTML that gives me blinking iframes for some visual debugging.

That's M$-specific, it won't work in Netscape 4.



It's better to wrap your elements in a pair of tables, so that you can identify elements with a border.

Like so:
code:
<TABLE BGCOLOR=FF0000 BORDER=0 CELLPADDING=0 CellSpacing=1>
<TABLE BGCOLOR=FFFFFF BORDER=0 CELLPADDING=0 CellSpacing=0>
<TR><TD>
<background>snowflakes.gif</background>
</TABLE>
</TABLE>

baquerd
Jul 2, 2007

by FactsAreUseless

shrughes posted:

That's M$-specific, it won't work in Netscape 4.

Got it covered. JavaScript user agent detection on a per-build basis for maximum compatibility.

quote:

It's better to wrap your elements in a pair of tables, so that you can identify elements with a border.

Like so:
code:
<TABLE BGCOLOR=FF0000 BORDER=0 CELLPADDING=0 CellSpacing=1>
<TABLE BGCOLOR=FFFFFF BORDER=0 CELLPADDING=0 CellSpacing=0>
<TR><TD>
<background>snowflakes.gif</background>
</TABLE>
</TABLE>

This doesn't work :colbert:

Vanadium
Jan 8, 2005

baquerd posted:

This doesn't work :colbert:

Sounds like you are not using AnyBrowser. :smug:

Nigglypuff
Nov 9, 2006


BUY ME BONESTORM
OR
GO TO HELL

shrughes posted:

This is a joke

baquerd
Jul 2, 2007

by FactsAreUseless

Vanadium posted:

Sounds like you are not using AnyBrowser. :smug:

I use Mosaic thanks.

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost
That won't really work in Links, my browser of choice.

baquerd posted:

Any advice to polish this guy further?
Have the color mappings managed by a CMDB so that if someone tries to change the colors without following designated enterprise systems policy, you'll get 15 warning e-mails (one for every affected foreign key constraint) and your boss will fire your rear end not for that but because a monitoring agent on a watchdog timer made it look like you cost your company $10M in SLA agreements because your action caused the database to perform a table lock, which caused the watchdog process to fail because it couldn't get a write lock because some moron DBA configured the CMDB to use the same database as the monitoring agent.

I've gotta quit my job. It's not that far-removed from what keeps me from writing code every day :(

Nevett
Aug 31, 2001

This is in C#, in an ASP.NET project I've inherited.

code:
	public Boolean IsNumeric(String strString)
	{
		Boolean bValid = true;
		for (Int32 nI = 0; nI < strString.Length; nI++)
		{
			String strChar = strString.Substring(nI, 1);
			if (strChar != "0" && strChar != "1" && strChar != "2"
			 && strChar != "3" && strChar != "4" && strChar != "5"
			 && strChar != "6" && strChar != "7" && strChar != "8"
			 && strChar != "9")
			{
				bValid = false;
			}
		}
		return bValid;
	}

Adbot
ADBOT LOVES YOU

SirViver
Oct 22, 2008

Nevett posted:

This is in C#, in an ASP.NET project I've inherited.
[...]
:gonk:

That made me look at what Google would suggest as C# IsNumeric function and to my horror the first two where a Convert.ToInt32() with try/catch around it and the third a friggin' Regexp. Ugggghhhh.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply