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
Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Sagacity posted:

Jabor, just for reference, how big are the projects you are working on? Are they leaning more towards monolith or more towards micro? I assume the former, because then you will definitely have to start reasoning about separate parts of the same projects as black boxes.

A bit over 500k LOC (not counting tests), tens of developers, multiple applications build from the same codebase.

Not a huge project, but big enough that you can't really grok all of it at the same time.

Adbot
ADBOT LOVES YOU

Jethro
Jun 1, 2000

I was raised on the dairy, Bitch!

zergstain posted:

I always thought the reason for mocks was you want to test A, which uses C, but C hasn't been implemented yet.
Or C is your 500 GB database. Or you want to see that A responds properly when C fails in certain ways, so you write a mock C that just behaves like a broken C. Or...

loinburger
Jul 10, 2004
Sweet Sauce Jones
I've got an ActiveMQ queue that's subject to all sorts of transient faults (network, file system, etc). 99% of the tests that use the queue don't care about most of its features (e.g. persistence), and the people who write those tests would be annoyed if their test failed because of some transient fault that breaks the queue but that otherwise wouldn't have broken their test. So, they get a mocked queue (pretty much just a standard ConcurrentLinkedQueue from java.util.concurrent) that isn't going to break on them.

JawnV6
Jul 4, 2004

So hot ...
So targets for mocking include Things That Break and Things That Don't Break?

rarbatrol
Apr 17, 2011

Hurt//maim//kill.

JawnV6 posted:

So targets for mocking include Things That Break and Things That Don't Break?

Mocking is a strategy for isolating the code you want to test from code you do not want to test. It's great for simulating certain error scenarios that you may not otherwise be able to trigger.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

More horrors of code, less missing the point.

Sedro
Dec 31, 2008

loinburger posted:

I've got an ActiveMQ queue that's subject to all sorts of transient faults (network, file system, etc). 99% of the tests that use the queue don't care about most of its features (e.g. persistence), and the people who write those tests would be annoyed if their test failed because of some transient fault that breaks the queue but that otherwise wouldn't have broken their test. So, they get a mocked queue (pretty much just a standard ConcurrentLinkedQueue from java.util.concurrent) that isn't going to break on them.
Your mock can't possibly replicate AMQ's semantics. You're better off embedding the real thing for your tests.

loinburger
Jul 10, 2004
Sweet Sauce Jones
The only semantics that most of the tests care about, and the only semantics I'm replicating, are "add something to the queue" and "remove something from the queue." For that matter, they don't even care that it's a queue - they just want a source and/or sink that's not going to cause them grief. There are a few tests (other than the ones I've written) that care about transactional semantics or persistence or whatever, and they get a non-mocked queue.

loinburger fucked around with this message at 02:42 on Aug 5, 2015

rarbatrol
Apr 17, 2011

Hurt//maim//kill.

Subjunctive posted:

More horrors of code, less missing the point.

At my first job out of college, I discovered that we were making a call to the database for every cell in some sort of a grid control. When I asked somebody about it, the response I got was along the lines of "well they kept changing the requirements on us, so we made it really slow as payback." In this story, "they" are the client services department, and "we" were the internal applications team.

Our DBA was fairly new, and he spent a lot of his spare time figuring out where all the foreign keys and primary keys should have been all along.

IT BEGINS
Jan 15, 2009

I don't know how to make analogies
In TYOOL2015:

php:
<?

    function reader() {
        global $GLOBALS;
        ...
    }

    public function validateDate($date, $format = 'Y-m-d H:i:s')
    {
        $d = \DateTime::createFromFormat($format, $date);
        return $d && str_replace("0","",$d->format($format)) == str_replace("0","",$date);
    }

    public function validDate($date, $format = 'Y-m-d H:i:s')
    {
        $d = \DateTime::createFromFormat($format, $date);
        if($d){
            return $d->format($format);
        }
        else {
            return "";
        }
    }

?>

IT BEGINS fucked around with this message at 04:25 on Aug 5, 2015

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
Pet peeve: when camelCase names get capitals in the middle that aren't appropriate. A library we use has a namespace full of CSS colours and one of them is "DarkGoldenRod". The "rod" is not a separate word you shmucks!! I am extremely disproportionately irritated about this

comedyblissoption
Mar 15, 2006

you should be more triggered by the fact that the industry went with camel case instead of underscore case or hyphen case

stupid_big_thing
stupid-big-thing
stupidBigThing
StupidBigThing

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Hammerite posted:

Pet peeve: when camelCase names get capitals in the middle that aren't appropriate. A library we use has a namespace full of CSS colours and one of them is "DarkGoldenRod". The "rod" is not a separate word you shmucks!! I am extremely disproportionately irritated about this

What if the color is supposed to be a rusty C3P0 dilz, did you ever think of that?

tyrelhill
Jul 30, 2006

Hammerite posted:

Pet peeve: when camelCase names get capitals in the middle that aren't appropriate. A library we use has a namespace full of CSS colours and one of them is "DarkGoldenRod". The "rod" is not a separate word you shmucks!! I am extremely disproportionately irritated about this

You should seek help.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

Hammerite posted:

Pet peeve: when camelCase names get capitals in the middle that aren't appropriate. A library we use has a namespace full of CSS colours and one of them is "DarkGoldenRod". The "rod" is not a separate word you shmucks!! I am extremely disproportionately irritated about this
An ex-colleague of mine would always write BroadCast. The proportion of irritation that this generated was very similar to yours. Unless you meant you were REALLY fine with this kind of thing.

Another peeve: People who misspell "schmuck".

Amberskin
Dec 22, 2013

We come in peace! Legit!

comedyblissoption posted:

you should be more triggered by the fact that the industry went with camel case instead of underscore case or hyphen case

That is way too COBOL or PLI-ish.

Beamed
Nov 26, 2010

Then you have a responsibility that no man has ever faced. You have your fear which could become reality, and you have Godzilla, which is reality.


Amberskin posted:

That is way too COBOL or PLI-ish.

You're right, it is inherently superior.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
Everywhere I've worked and learned has been insistent that underscores only go in names of constants and typedefs. Constants in all upper-case and typedefs in all lower-case.

Edison was a dick
Apr 3, 2010

direct current :roboluv: only
http://www.cs.kent.edu/~jmaletic/papers/ICPC2010-CamelCaseUnderScoreClouds.pdf

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

This is all very well, but generally one is not in a position of sitting down and deciding what convention to use, rather you have an existing codebase and consistency with what came before is much more valuable than "well some study showed that underscore names are 5.2% easier to read"

Also I know I just posted to have a whinge about naming conventions but there was no call for making it into a camelcase vs underscores debate. :mad:

JawnV6
Jul 4, 2004

So hot ...
There should just be one naming convention. Once a year, put it after defcon. Bring all the variables you need to name, have some lecture series and panels, etc.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Tangentially related: why are most languages still case sensitive? Has "String string" ever been anything but a code smell?

Mellow_
Sep 13, 2010

:frog:

LeftistMuslimObama posted:

Some of the teams at my company do Agile or scrums or whatever, and it all seems so loving dumb to me. What's so hard about going to work, and doing the poo poo you need to do at a pace that enables you to meet your deadline? Why do we need special names and paradigms for everything? Just do as much work as you can at a reasonable pace every day. Don't stop until the work is done. The end. I have never organized myself further than "Monday I am doing a code review, Tuesday I'm going to focus on getting a rough version of Module Y knocked out... etc", and I am easily 3x more productive than any of the Agile devotees I've met at work, and I turn out a lot fewer bugs than them too. Half the Agile disciple teams aren't even allowed to do big enhancements right now because they have too many bugs to fix.

The trash the methodology devotees pump out is kinda expected, no? They're probably focusing way harder on their process than actually writing code.

E: I do think that the methodologies have their place and do great things, but at a previous company they embraced scrum as their cure all instead of addressing the more major issues (lovely staff, poor data retention policies, etc. Hell they put a database belonging to the faa on a ram disk that then got corrupted and lost a month of data)

Mellow_ fucked around with this message at 22:08 on Aug 5, 2015

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

NihilCredo posted:

Tangentially related: why are most languages still case sensitive?

Saying "still" presupposes that case insensitivity is an improvement and predominantly a feature of newer languages. Neither of these things are true.

Incidentally, the case of "String string" and similar things isn't only related to case sensitivity - namespaces and lookup rules come into play, too. There are probably languages where you can have an instance of data type x which is named x and not have any problems (except confusion).

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Surely one could make a font that adds a bit of space between a lowercase letter and its subsequent uppercase letter to make camelcase more legible.

qntm
Jun 17, 2009

NihilCredo posted:

Tangentially related: why are most languages still case sensitive? Has "String string" ever been anything but a code smell?

Well, among other things, "case-sensitive" means different things in different locales, leading to one PHP bug:

quote:

There is an odd problem with Turkish language and PHP. To cut it short, in Turkish there are "dotted capital I" and "dotless i" characters, and "i != I".

PHP calls strtolower() on function/class name before function calls. If the system locale is set to tr_TR, functions that contain "I" in their name cannot be found and called.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

pokeyman posted:

Surely one could make a font that adds a bit of space between a lowercase letter and its subsequent uppercase letter to make camelcase more legible.

I'm not sure if this is a subtle troll to get people to spit bile over the implication that they might use a variable-width font. But it does cause me to wonder whether subtle, contextual changes to letter glyphs could enable what you're suggesting while retaining the character grid of a fixed-width font.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Blotto Skorzany posted:

Saying "still" presupposes that case insensitivity is an improvement and predominantly a feature of newer languages. Neither of these things are true.

Incidentally, the case of "String string" and similar things isn't only related to case sensitivity - namespaces and lookup rules come into play, too. There are probably languages where you can have an instance of data type x which is named x and not have any problems (except confusion).

I didn't mean to imply the latter (I'm aware of OLD-TIMEY LANGUAGES), but I do the former. I have curiously googled arguments for case sensitivity a few times, with poor results - many answers were just historical notes or mild technical obstacles.

The most common actual argument seems to be "we can use case to convey information, such as whether a certain token is a constant or a variable", which is certainly true, but which doesn't require case sensitivity at all. Case sensitivity forces the user to adopt consistent casing, sure, but there's no reason why you should do it instead of leaving it to your coding environment, in the same way that you do with consistent indentation lengths (I hope). If there is a constant called BUTTS, typing "butts" should autocorrect to BUTTS instead of letting you declare a probably confusing homonym.


Hammerite posted:

I'm not sure if this is a subtle troll to get people to spit bile over the implication that they might use a variable-width font. But it does cause me to wonder whether subtle, contextual changes to letter glyphs could enable what you're suggesting while retaining the character grid of a fixed-width font.

If you could directly manipulate font width, stretching them without changing anything else, what you suggest would be certainly be possible, but I suspect that that sort of manipulation would require a lot of painful hacking in your operating system's GUI libraries.

Sticking to regular font size manipulation would avoid that problem, but if the width difference between 10pt and 9pt doesn't match the one between 9pt and 8pt, and I presume it doesn't, then you're boned.

I guess you could avoid both problems with styling, e.g. bold the C in camelCase, but that looks like rear end.

Tank Boy Ken
Aug 24, 2012
J4G for life
Fallen Rib
I guess a (more or less) subtle color hue change for each segmet of a camelcase would suffice:

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

NihilCredo posted:

I didn't mean to imply the latter (I'm aware of OLD-TIMEY LANGUAGES), but I do the former. I have curiously googled arguments for case sensitivity a few times, with poor results - many answers were just historical notes or mild technical obstacles.

The most common actual argument seems to be "we can use case to convey information, such as whether a certain token is a constant or a variable", which is certainly true, but which doesn't require case sensitivity at all. Case sensitivity forces the user to adopt consistent casing, sure, but there's no reason why you should do it instead of leaving it to your coding environment, in the same way that you do with consistent indentation lengths (I hope). If there is a constant called BUTTS, typing "butts" should autocorrect to BUTTS instead of letting you declare a probably confusing homonym.


If you could directly manipulate font width, stretching them without changing anything else, what you suggest would be certainly be possible, but I suspect that that sort of manipulation would require a lot of painful hacking in your operating system's GUI libraries.

Sticking to regular font size manipulation would avoid that problem, but if the width difference between 10pt and 9pt doesn't match the one between 9pt and 8pt, and I presume it doesn't, then you're boned.

I guess you could avoid both problems with styling, e.g. bold the C in camelCase, but that looks like rear end.

Possibly relevant (specific to truetype fonts in windows MFC)

Using a smaller font size would look bad I imagine, but it is possible that using a slightly smaller font size and vertically stretching it might look okay.

A variation of Tank Boy Ken's idea of colour would be to give capitals a slightly different hue.

VikingofRock
Aug 24, 2008




NihilCredo posted:

Tangentially related: why are most languages still case sensitive? Has "String string" ever been anything but a code smell?

I think there's a pretty good argument for not treating globAllocations and globalLocations as the same variable. (example courtesy of this MonocQc post)

Bongo Bill
Jan 17, 2012

Type and symbol names changed, but otherwise unaltered:

code:
v.Field = (SomeEnum)15; // this means SomeEnum.Foobar

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

VikingofRock posted:

I think there's a pretty good argument for not treating globAllocations and globalLocations as the same variable. (example courtesy of this MonocQc post)

That's a great example, which makes a pretty good argument indeed! It just happens to be an argument for case insensitivity.

A case-insensitive language won't let you define globAllocations at all, if globalLocations already exists in the same scope. You'll get a nice big compiler error and squiggly line.

A case-sensitive language, on the contrary, will happily let you define both. And then, if at any point your cheeto-encrusted fingers hit Tab on the wrong autocomplete entry, or your caffeine-reddened eyes miss the tiny case difference, the program will raise no objections and will compile and run just fine (barring a lucky type mismatch error).

sarehu
Apr 20, 2007

(call/cc call/cc)
Most languages let you shadow variables or at least global variables. You'd get a warning for that, but there's also function overloading, method names.

Case sensitivity just makes everything more inconvenient. Being able to write String string; is a good thing. The more modern thing to do is to not only be case sensitive, but to have mandatory case conventions followed, like capitalization for type names, to the point where capitalizing or lower-casing a word could have direct semantic consequences.

sarehu fucked around with this message at 01:58 on Aug 6, 2015

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

NihilCredo posted:

Case sensitivity forces the user to adopt consistent casing, sure, but there's no reason why you should do it instead of leaving it to your coding environment, in the same way that you do with consistent indentation lengths (I hope). If there is a constant called BUTTS, typing "butts" should autocorrect to BUTTS instead of letting you declare a probably confusing homonym.

Literally every ide worth its salt already does exactly what you want here. Try typing in something with the wrong case and then hitting your autocompletion key.

Also, every language worth its salt will yell at you if you suddenly start talking about a new variable you didn't explicitly declare somewhere.

sarehu
Apr 20, 2007

(call/cc call/cc)

NihilCredo posted:

(barring a lucky type mismatch error).

You mean a typical type mismatch error.

Athas
Aug 6, 2007

fuck that joker

NihilCredo posted:

Tangentially related: why are most languages still case sensitive? Has "String string" ever been anything but a code smell?

In Haskell, casing is syntactically meaningful. All constructors (both type constructors and value constructors) must have their first letter capitalised, and all variables must have an initial lowercase letter. This makes parsing easier for both man and machine. I base this opinion on also having programmed in Standard ML, which has no such rule, and where it can sometimes be a little confusing whether a name in a pattern is a constructor or a variable binding.

Amberskin
Dec 22, 2013

We come in peace! Legit!

Beamed posted:

You're right, it is inherently superior.

Having been working half of my life typing code in lines of a maximum of 72 columns, using a horrible 3270 emulation font, I tend to favour a compact notation rather than an expanded one. When you get to the point in which a qualified field name takes half of a line real state you start to appreciate the few characters you get using something like camelCase, even when the language is not case sensitive (in my case, PL/I).

Speaking of that, some time ago I found this looking for a code hot spot:

code:
	CONVERT_TO_DECIMAL: PROCEDURE(IN) RETURNS DECIMAL FIXED (15,2);
	DCL IN BINARY FIXED(15);
        DCL I   BINARY FIXED(15);
	DCL RES DECIMAL FIXED(15,2) INIT(0);

		DO I=1 TO IN;
			RES = RES + 1;
		END
		RETURN RES;      

	END;
I almost fell down from my chair...

Pollyanna
Mar 5, 2005

Milk's on them.


None of this would be a problem if we all used snake_case and hyphen-case.

Adbot
ADBOT LOVES YOU

ExcessBLarg!
Sep 1, 2001

NihilCredo posted:

Tangentially related: why are most languages still case sensitive?
There's no technical requirement (i.e., frequent use of computers with only one case available for interactive I/O) that obligates it, and it would contribute to greater style inconsistency.

NihilCredo posted:

That's a great example, which makes a pretty good argument indeed! It just happens to be an argument for case insensitivity.
At best, it's an argument for disallowing ambiguous-when-case-insensitive identifiers, but the language itself could still enforce consistent casing for identifiers and keywords.

Is "preventing errors" the only argument? Given that most languages are case sensitive today, what benefit would be gained from making them case insensitive aside from that one?

Edit:

NihilCredo posted:

Has "String string" ever been anything but a code smell?
How is "Sring string" code smell anyways?

ExcessBLarg! fucked around with this message at 18:56 on Aug 6, 2015

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