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
Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
I have been at my first ever real grown up job for 6 weeks now and I'm really enjoying it. They do generally do things "the right way" (version control etc etc) and are a pretty good company to work for. Right now I'm writing some really bad code with their blessing, though. Basically we are building a system for managing the data held by another organisation, which they publish periodically in paper volumes. Up until now they have basically just edited the PDF documents containing the data in a desktop publishing application, and occasionally just sent those files to the printers. Now the data is going to be kept in a source-control-like system and will have to conform to a schema - potentially a quite complicated schema and one that will permit a lot of special-case behaviour, because that's the nature of the data we are working with, but still a schema.

Right now though, the data we have is in the form of XML dumped from the desktop publishing application. I'm writing code to take that "messy" data, try to make sense of it, and spit out properly structured data. I took over a file of C# code that was written by someone else that was a few hundred lines and that kind of handled maybe 85% of what was there but broke on the special cases. And, uh, I started adding special cases. It's now about 2,300 lines and most of the added stuff is along the lines of

code:
if (countryName == "ANTIGUA AND BARBUDA" && (condition that detects some special case or other))
{
    ...
}
peppered around this or that function.

When I started I didn't appreciate quite how much massaging the data would need in order to be made sensible, or I might have tried to do it in a more systematic and readable way. But hey, it ultimately has to run just once, and then it can be thrown away. Well, it will stay in the company's source control for ever, but I put a comment at the top recommending politely that no-one read it...

So there you are, I'm writing code that I know is shocking, with the company's approval. Thankfully, this bit is nearly done, and I should shortly be able to go back to writing code that works with the already-imported data and that needs to be (and is) done properly.

Adbot
ADBOT LOVES YOU

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
I had been given a similar task of cramming some existing data into an editor of ours. The problem was that our tool was put together so badly, it was just a string of hacks. I really had no way to do something properly in the timeframe, the only way to do it was to add more crappy code onto the pile. I explained that I really wasn't happy doing it, but nobody really cared. It actually made me sick. I had to take a week off :(

feedmegin
Jul 30, 2008

Zopotantor posted:

[1] Currently on 4.1 since we're still using RHEL 5. Our customers are very, very conservative and need serious arm-twisting to agree to OS updates.

Feel lucky. We still have customers running RHEL 4. On a Pentium III.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

vOv posted:

What is up with people using CSS classes for things that there will only ever be one instance of?

There is no difference between using CSS class selectors and CSS ID selectors other than the attribute matched.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Suspicious Dish posted:

There is no difference between using CSS class selectors and CSS ID selectors other than the attribute matched.

Id is higher specificity.

vOv
Feb 8, 2014

Suspicious Dish posted:

There is no difference between using CSS class selectors and CSS ID selectors other than the attribute matched.

In addition to ID being more 'specific' (what Plorkyeran said), it's cleaner semantically.

Deus Rex
Mar 5, 2005

The high specificity of IDs can become an enormous pain in the rear end. Overuse of IDs in selectors often leads to developers taking shortcuts like !important or inlining styles, because the burden of determining whether it's safe to reduce specificity on a competing selector is too great.

xtal
Jan 9, 2011

by Fluffdaddy
Object-oriented CSS in most people's minds is stuff like class="red big button" instead of id="submit-order", but that's terrible, non-semantic HTML. Use id="submit-order" and #submit-order { @extend .red; ... } or your favorite preprocessor's equivalent. In addition to separating content from presentation, IDs are also a lot faster to render and all that stuff.

Coffee Mugshot
Jun 26, 2010

by Lowtax

xtal posted:

Object-oriented CSS in most people's minds is stuff like class="red big button"

Woah, the horror is coming from inside the thread!!! I think you meant class="big red button"

Loezi
Dec 18, 2012

Never buy the cheap stuff

xtal posted:

Object-oriented CSS in most people's minds is stuff like class="red big button" instead of id="submit-order", but that's terrible, non-semantic HTML. Use id="submit-order" and #submit-order { @extend .red; ... } or your favorite preprocessor's equivalent. In addition to separating content from presentation, IDs are also a lot faster to render and all that stuff.

Non-semantic CSS is one of my pet peeves and I had a small meltdown when a friend linked me the basscss with its helpful and semantic examples such as:
code:
<div class="clearfix leading-3 mb1 bg-light-gray">
  <div class="left px1 p bold leading-3">Nav bar</div>
  <div class="right px1">
    <a href="#!">Right</a>
    <a href="#!" class="button button-small button-gray ml1">Button</a>
  </div>
</div>
and
code:
<div class="relative p2 mb1 bg-light-gray rounded">
  <h2 class="h3 p4 center">Position anything</h2>
  <p class="absolute t0 l0 p1 mid-gray">Top left</p>
  <p class="absolute r0 b0 p1 mb0 mid-gray">Bottom right</p>
</div>
Yes, that will no doubt be fun and easy to replace when the people in marketing decide to change the layout.

It almost feels like we are taking huge steps backwards with HTML+CSS. The above examples are nothing but inlined styles. There is practically no difference there from a usability or a development standpoint between
code:
<div class="left px1 p bold leading-3">Nav bar</div>
and
code:
<div style="blah">Nav bar</div>
Similarly everyone seems to be plastering their websites with what are in every sense just 90's tables remade with divs and classes instead of the table-family of tags. Isn't that going to be fun to change around. I know it's sometimes really hard (or impossible) to do without defining rows and columns but it's become the default for any kind of layout.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Suspicious Dish posted:

There is no difference between using CSS class selectors and CSS ID selectors other than the attribute matched.

And the fact that ID selectors match with = rather than ~=.

code:

<div id="hi there" class="hi there"/>

.there { /* matches */ }
#there { /* no sir */ }

ID selectors are also higher specificity than their attribute-selector equivalent, whereas class selectors really are just shorthand for [class~=value].

necrotic
Aug 2, 2005
I owe my brother big time for this!

Suspicious Dish posted:

There is no difference between using CSS class selectors and CSS ID selectors other than the attribute matched.

ID selectors are significantly faster than class selectors: http://jsperf.com/id-versus-class/2

edit: Weird... that test case doesn't exist anymore and I can't seem to add anything to jsperf anymore.

The test was simple

code:
<article class="test" id="test"></article>
code:
document.querySelector('#test')
code:
document.querySelector('.test')
Second test case was ~78% slower.

necrotic fucked around with this message at 23:43 on Jun 29, 2014

xtal
Jan 9, 2011

by Fluffdaddy

Subjunctive posted:

And the fact that ID selectors match with = rather than ~=.

code:
<div id="hi there" class="hi there"/>

.there { /* matches */ }
#there { /* no sir */ }
ID selectors are also higher specificity than their attribute-selector equivalent, whereas class selectors really are just shorthand for [class~=value].

They both use =, but the ID attribute is just a string and the class attribute is a a space-separated list of strings. Not to be supremely pedantic, it's very different from substring matching.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

xtal posted:

They both use =, but the ID attribute is just a string and the class attribute is a a space-separated list of strings. Not to be supremely pedantic, it's very different from substring matching.

Be as pedantic as you'd like, but class uses ~=, which is matching on presence of a match in a set of whitespace-tokenized substrings.

w3c posted:

[att~=val]
Represents an element with the att attribute whose value is a whitespace-separated list of words, one of which is exactly "val".
[...]
Thus, for HTML, div.value and div[class~=value] have the same meaning.

http://www.w3.org/TR/selectors/#class-html

(*=, not ~=, is substring match.)

evensevenone
May 12, 2001
Glass is a solid.
code:
    @unittest.expectedFailure
    def test_packet_to_buffer(self):
        # TODO: Figure out why this fails
	. . .

Soricidus
Oct 21, 2010
freedom-hating statist shill
This is in the right thread, but I'm not sure why you didn't post the whole spec.

beuges
Jul 4, 2005
fluffy bunny butterfly broomstick
Fixing something a contractor did before disappearing and came across this:

code:
                string StatsType = CommonFunctions.getParamValue("StatsType", inParams);
                var st = (Common.Statisitics.StatsTypes)Enum.Parse(typeof(Common.Statisitics.StatsTypes), StatsType, true);

                if (st.ToString() == "stats_Ping")
                {
			...

beuges fucked around with this message at 21:51 on Jun 30, 2014

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
Are there misspellings in your code base? It is statisitically likely.

I fixed a method today that parses an "interger", but I'm pretty sure I've at least typed that one myself before.

(yes I can see it is bad for other reasons)

b0lt
Apr 29, 2005

Hammerite posted:

Are there misspellings in your code base? It is statisitically likely

heh

Mogomra
Nov 5, 2005

simply having a wonderful time
I'm working on a project with a lot of "campaigns", and it's really loving easy to type "campaing."

Why do I even call them "campaigns" internality?

:negative:

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
http://pythong.org/

pseudorandom name
May 6, 2007

The only reason I spell unsinged correctly is because it causes a compiler error.

Dr. Stab
Sep 12, 2010
👨🏻‍⚕️🩺🔪🙀😱🙀
I have, on multiple occasions, refactored to avoid variable names containing words that I misspell a lot.

OddObserver
Apr 3, 2009
The important part is to not end up with another "referer".

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

OddObserver posted:

The important part is to not end up with another "referer".

Or my favorite codebase discovery, referfer.

substitute
Aug 30, 2003

you for my mum
At work the consultant's php classes/interfaces all have __destructor methods.

http://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.destructor

ShaunO
Jan 29, 2006

Maybe not really a horror but it did make me laugh/cry for a few minutes. Being somewhat new to day-to-day Javascript, coming from C#, I always terminate my statements with semicolons. Obviously Javascript doesn't require this but it hasn't really bitten me until the other day when my mind decided to do a strange line termination mainly for style.

code:
    var myReasonablyLongVarNameAsTheyAre = 
        _.find(myOtherLongVarName, function(x) { return
            this.isSomehowRelatedTo(x) ||
            this.maybeItsRelatedToThisInstead(x);
        });                                            
I don't normally do this, just an accident in a rush/being lazy I guess, which is why it never came up before.

I debugged it for a couple of minutes wondering why the condition wasn't evaluating to true when it clearly should be.. of course my mistake is that Javascript was returning out of the function immediately without even evaluating the expression..

:pseudo:

Normally would use, and refactored to:

code:
    var myReasonablyLongVarNameAsTheyAre = 
        _.find(myOtherLongVarName, function(x) { 
            return this.isSomehowRelatedTo(x) ||
	           this.maybeItsRelatedToThisInstead(x);
        });                                            

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Hammerite posted:

Are there misspellings in your code base? It is statisitically likely.

Most people working on our code are not native English speakers (me neither). So we get grammatical errors as a bonus.

jneen
Feb 8, 2014
https://github.com/search?l=javascript&q=lenght&ref=cmdform&type=Code

1337JiveTurkey
Feb 17, 2005

There's one particular place in our codebase that drives me up the wall. It's someone being pretentious and deciding to pluralize status as statii. If you're going to be clever with pluralizations, first the sense that the word's being used in is fourth declension, not second declension. Second, even if it were second declension, statius isn't a word. Third, the plural of status is status, just the emphasis is on the second syllable when you pronounce it. Fourth, I took four loving years of Latin and even then I don't waste peoples' time with that bullshit.

Steve French
Sep 8, 2003

Except just this one time

1337JiveTurkey
Feb 17, 2005

Point taken :v:

vOv
Feb 8, 2014

1337JiveTurkey posted:

There's one particular place in our codebase that drives me up the wall. It's someone being pretentious and deciding to pluralize status as statii. If you're going to be clever with pluralizations, first the sense that the word's being used in is fourth declension, not second declension. Second, even if it were second declension, statius isn't a word. Third, the plural of status is status, just the emphasis is on the second syllable when you pronounce it. Fourth, I took four loving years of Latin and even then I don't waste peoples' time with that bullshit.

Every time someone calls the Winklevoss twins the "Winklevii" I want to punch them right in the face.

substitute
Aug 30, 2003

you for my mum

1337JiveTurkey posted:

...If you're going to be clever with pluralizations, first the sense that the word's being used in is fourth declension, not second declension. Second, even if it were second declension, statius isn't a word. Third, the plural of status is status, just the emphasis is on the second syllable when you pronounce it. Fourth, I took four loving years of Latin and even then I don't waste peoples' time with that bullshit.

Add this as a comment in the code please.

Coffee Mugshot
Jun 26, 2010

by Lowtax

vOv posted:

Every time someone calls the Winklevoss twins the "Winklevii" I want to punch them right in the face.

its a joke, based on how ridiculous saying such a thing would be

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Voted Worst Mom posted:

its a joke, based on how ridiculous saying such a thing would be

Also, I understand from people who knew them that it really pissed them off, which is reason enough.

"Virii, on the other hand, is an abomination before man and god.

Edison was a dick
Apr 3, 2010

direct current :roboluv: only

vOv posted:

Every time someone calls the Winklevoss twins the "Winklevii" I want to punch them right in the face.

The correct plural is Winklesvoss. :haw:

Soricidus
Oct 21, 2010
freedom-hating statist shill

1337JiveTurkey posted:

There's one particular place in our codebase that drives me up the wall. It's someone being pretentious and deciding to pluralize status as statii. If you're going to be clever with pluralizations, first the sense that the word's being used in is fourth declension, not second declension. Second, even if it were second declension, statius isn't a word. Third, the plural of status is status, just the emphasis is on the second syllable when you pronounce it. Fourth, I took four loving years of Latin and even then I don't waste peoples' time with that bullshit.
I think I love you.

Coffee Mugshot
Jun 26, 2010

by Lowtax
I refer to a group of walrus as walrii, come at me vOv

Adbot
ADBOT LOVES YOU

canis minor
May 4, 2011

code:
<form class="form-core form-horizontal form_search offset-bottom-1">
...
</form>
<form class="form_centre">
    <a href="#" class="go-home center-map">Centre map <i class="icon orange-arrow"></i></a>
</form>
:bang:

edit: .orange-arrow isn't orange.

canis minor fucked around with this message at 17:53 on Jul 1, 2014

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