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
Volmarias
Dec 31, 2002

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

Illusive gently caress Man posted:

Tbqh there is no 'prod' because this is kind of a proof of concept project. it's a 4 person team and when it works someone just tags the commit 'it works' but the plan is somehow that we will be able to demonstrate and let people use this in a few months?

I would love some kind of code review or automated testing but that would be like a whole job for somebody to set up and organize and none of us even know how to set up Jenkins sooo

gently caress

Jenkins is actually shockingly easy to set up. A year ago, the .deb set it up as a service automatically, so you just needed to point it to your repo and let it go.

Anyway, unless people are checking in things that break the build, or you have a suite of tests, Jenkins won't help much. You need a code review service which you can post your patches to and have people on your team comment on them and demand stuff get fixed before submission. Even if you're all coding übermensch, it helps catch dumb typos and such.

Adbot
ADBOT LOVES YOU

Slash
Apr 7, 2011

Volmarias posted:

Jenkins is actually shockingly easy to set up. A year ago, the .deb set it up as a service automatically, so you just needed to point it to your repo and let it go.

Anyway, unless people are checking in things that break the build, or you have a suite of tests, Jenkins won't help much. You need a code review service which you can post your patches to and have people on your team comment on them and demand stuff get fixed before submission. Even if you're all coding übermensch, it helps catch dumb typos and such.

We're currently trying to implement a code review process such as this. Can you suggest any software which allows us to do this, and preferably integrates with Subversion. We're currently evaulating ReviewBoard, but I was wondering if there are any other software solutions people can recommend?

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

StorrowS posted:

We're currently trying to implement a code review process such as this. Can you suggest any software which allows us to do this, and preferably integrates with Subversion. We're currently evaulating ReviewBoard, but I was wondering if there are any other software solutions people can recommend?

We use http://phabricator.org/ at work, it's pretty great.

hobbesmaster
Jan 28, 2008

Subjunctive posted:

We use http://phabricator.org/ at work, it's pretty great.

Phabricator includes applications for:

reviewing and auditing code;
hosting Git/Hg/SVN repositories;
browsing repositories;
tracking bugs or "features";
hiding stuff from coworkers; and
also some other things,
like meme generators.


:raise:

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Animated GIFs in review comments are a nice touch.

bpower
Feb 19, 2011

dwazegek posted:

A colleague of mine does something similar. He'll first outline the different steps a method has to do in comments, then write the code. Which, in general is fine, except he leaves all the comments in, and never adds any actually useful comments. So all his code looks like this:
code:
//Create bar for foo
CreateBar(foo);

//Set foo active
SetActive(foo);
It's not the worst thing in the world, but it's utterly pointless, and it's everywhere.

And its always these guys who have

code:
// declare i as an integer
int i;

i = x * 15 / min_j

// print i
printf(i);

Thanks dude thats great.

edit: actually my dude is a different type. Your dude just needs to keep his psude-code more abstract and start coding a little earlair. He might end up with

code:
// Set up foo
CreateBar(foo);
SetActive(foo);

bpower fucked around with this message at 17:53 on Nov 14, 2014

FlapYoJacks
Feb 12, 2009

Subjunctive posted:

Looks like an early-out optimization to avoid a function call to strcmp in the presumably-common case where first chars differ. Usually means "strcmp prolog/epilog showed up in a profile once" (possibly on a previous project, and is carried forward superstitiously).

Often an unnecessary optimization, but I wouldn't say it was a horror.

The real horror is using strcmp instead of strncmp.

Xenoveritas
May 9, 2010
Dinosaur Gum
.

Xenoveritas fucked around with this message at 18:12 on Nov 14, 2014

sarehu
Apr 20, 2007

(call/cc call/cc)

ratbert90 posted:

The real horror is using strcmp instead of strncmp.

There's nothing wrong with using strcmp and it's the right thing to use here because you've got two null-terminated strings you're comparing.

(Just because strncpy is better than strcpy, that doesn't mean every C string function should use the "n" version.)

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

sarehu posted:

There's nothing wrong with using strcmp and it's the right thing to use here because you've got two null-terminated strings you're comparing.

(Just because strncpy is better than strcpy, that doesn't mean every C string function should use the "n" version.)

strncpy is definitely not better than strcpy, but you're right that slavishly strncmping is silly. Those are C strings, strcmp works on C strings, and strncmp would mean that a prefix would be considered equal.

(strncpy is a horror, definitely.)

FlapYoJacks
Feb 12, 2009

Subjunctive posted:

strncpy is definitely not better than strcpy, but you're right that slavishly strncmping is silly. Those are C strings, strcmp works on C strings, and strncmp would mean that a prefix would be considered equal.

(strncpy is a horror, definitely.)

What? Strncmp compares up to n bytes of two strings. Usually used in conjunction with the size of the first or second string so that way if the null does get dropped for some reason you don't start trolling around memory you ought not to.

Illusive Fuck Man
Jul 5, 2004
RIP John McCain feel better xoxo 💋 ðŸ™Â
Taco Defender

ratbert90 posted:

What? Strncmp compares up to n bytes of two strings. Usually used in conjunction with the size of the first or second string so that way if the null does get dropped for some reason you don't start trolling around memory you ought not to.

if the null gets dropped for some reason, that's probably a really bad bug that should be fixed and it's probably gonna wreck something somewhere anyway.

The only way strncmp makes sense is if
A. you don't want to compare the entire string (a prefix or something).
B. you know for certain that neither string will actually be longer than N AND that neither string will occupy an piece of memory allocated smaller than N.

It's not really that common for B to be true unless all your strings are stored in fixed size arrays.

FlapYoJacks
Feb 12, 2009

Illusive gently caress Man posted:

if the null gets dropped for some reason, that's probably a really bad bug that should be fixed and it's probably gonna wreck something somewhere anyway.

The only way strncmp makes sense is if
A. you don't want to compare the entire string (a prefix or something).
B. you know for certain that neither string will actually be longer than N AND that neither string will occupy an piece of memory allocated smaller than N.

It's not really that common for B to be true unless all your strings are stored in fixed size arrays.

Never underestimate people not zeroing out memory or conditioning their code. Unless it's your code and you know for certain it will be conditioned prior to getting to the compare.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Zeroing out memory doesn't tend to eliminate NULs? In fact you *have* to zero out the target buffer for strncpy to be safe. (Otherwise it's a great way to end up with the non-terminated case, because it was designed for mucking with Unix directory structures, not as a general tool for C strings.)

How do you determine n? It needs to be the length of the longest string to have the same semantics as strcmp. If you're using C strings one uses strlen, but...

Illusive Fuck Man
Jul 5, 2004
RIP John McCain feel better xoxo 💋 ðŸ™Â
Taco Defender

ratbert90 posted:

Never underestimate people not zeroing out memory or conditioning their code. Unless it's your code and you know for certain it will be conditioned prior to getting to the compare.

If you're comparing a string that isn't null terminated, how do you know what the N should be for strncmp? If it's always in an N size buffer and you're comparing to a constant shorter than N or something, sure, strncmp works. You're likely still going to have a serious bug if that string is used after the strncmp though. There isn't much you can safely do with a non-null terminated string without knowing the length of the string.

FlapYoJacks
Feb 12, 2009
This is why all of my strings are in arrays. :colbert: Mallocs are for people with fancy things like "heaps".

The Laplace Demon
Jul 23, 2009

"Oh dear! Oh dear! Heisenberg is a douche!"
EDIT: Dead Horse

FlapYoJacks
Feb 12, 2009

I stand corrected. Thank you for that. :unsmith:

sarehu
Apr 20, 2007

(call/cc call/cc)

Subjunctive posted:

strncpy is definitely not better than strcpy,

Oh right. Oh god no. Well, I wouldn't know because I don't use them!

My Rhythmic Crotch
Jan 13, 2011

Imagine a Python library where the API is constructed like this:
code:
class SuperCoolAPI(object):

	def DoSomething(self, *args, **kwargs):
		return self._privateMethod(Doodle(), *args, **kwargs)

	def DoThatOtherThing(self, *args, **kwargs):
		return self._privateMethod(Dingle(), *args, **kwargs)

	def _privateMethod(self, derp, *args, **kwargs):
		return self._otherPrivateMethod(derp, *args, **kwargs)
	
	... etc etc
Only buried a few layers deep do you actually start getting to the real action. And there's no documentation, hardly any comments. What's going on? Who knows!

Kiwi Ghost Chips
Feb 19, 2011

Start using the best desktop environment now!
Choose KDE!

I wish I could only imagine a single library like that.

MrMoo
Sep 14, 2000

I see a lot of that in Enterprise code, it takes ages to trace down what anything is actually doing.

My Rhythmic Crotch
Jan 13, 2011

What's frustrating about this is that most of the real work gets done by passing stuff through the kwargs, but because it's not documented, you'd never know what you're supposed to send in.

Karate Bastard
Jul 31, 2007
Probation
Can't post for 13 hours!
Soiled Meat
That's entry level code obfuscation in python. Oh, did I say entry I meant enterprise.

HFX
Nov 29, 2004

ratbert90 posted:

This is why all of my strings are in arrays. :colbert: Mallocs are for people with fancy things like "heaps".

Embedded programming for fun and profit.

Sometimes I miss it, but then I remember all the headaches.

Mellow_
Sep 13, 2010

:frog:

HFX posted:

Embedded programming for fun and profit.

Sometimes I miss it, but then I remember all the headaches.

Embedded programming is fun until you're burning code onto one off ROMs.

Then it's just stress.

Che Delilas
Nov 23, 2009
FREE TIBET WEED

Karate Bastard posted:

That's entry level code obfuscation in python. Oh, did I say entry I meant enterprise.

Look man, it's not the enterprises' faults if they don't want to pay enough to attract more than entry-level talent.

Oh wait.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Che Delilas posted:

Look man, it's not the enterprises' faults if they don't want to pay enough to attract more than entry-level talent.

I don't think you get the enterprise. The whole "gotta pay big money or you'll get lovely people" principle only applies to executives. Regular employees don't care about the money, they just want secure jobs with good benefits so the executives can save even more money when they outsource them, and get an even fatter bonus

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Soricidus posted:

I don't think you get the enterprise. The whole "gotta pay big money or you'll get lovely people" principle only applies to executives. Regular employees don't care about the money, they just want secure jobs with good benefits so the executives can save even more money when they outsource them, and get an even fatter bonus

The people who don't care about being paid a fair market value for their skills are almost always lovely; the reason they don't care is because they're just grateful that they were able to convince someone to hire them.

Heavy_D
Feb 16, 2002

"rararararara" contains the meaning of everything, kept in simple rectangular structures

Subjunctive posted:

Looks like an early-out optimization to avoid a function call to strcmp in the presumably-common case where first chars differ. Usually means "strcmp prolog/epilog showed up in a profile once" (possibly on a previous project, and is carried forward superstitiously).

Often an unnecessary optimization, but I wouldn't say it was a horror.

Then someone goes in and increments the pointers you feed to strcmp - because hey, we already KNOW the first characters are the same! Years down the line an empty string appears on a page boundary and boom...

Soricidus
Oct 21, 2010
freedom-hating statist shill

Ithaqua posted:

The people who don't care about being paid a fair market value for their skills are almost always lovely

You know that. I know that. The people who make hiring decisions for enterprise software development apparently don't.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Heavy_D posted:

Then someone goes in and increments the pointers you feed to strcmp - because hey, we already KNOW the first characters are the same! Years down the line an empty string appears on a page boundary and boom...

Yes, you can introduce bugs into code.

Plorkyeran
Mar 22, 2007

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

Heavy_D posted:

Then someone goes in and increments the pointers you feed to strcmp - because hey, we already KNOW the first characters are the same! Years down the line an empty string appears on a page boundary and boom...

That would be fine if the table of strings being searched will never contain an empty string. If not, then someone made an obviously invalid change. Hurrah.

Heavy_D
Feb 16, 2002

"rararararara" contains the meaning of everything, kept in simple rectangular structures
Don't worry, not arguing the original is wrong, just re-living past errors...

Literally Elvis
Oct 21, 2013

535 ways to reload the page with JavaScript

Polio Vax Scene
Apr 5, 2009



Hard to take that seriously when I only got to #7 and they're already reusing the same stuff just written differently.

Hell #3 is the same as #1 if you consider scope.

Xenoveritas
May 9, 2010
Dinosaur Gum
View Source on the page. It's generated with JavaScript, so yes, a lot of them are basically "there are a ton of different ways of accessing the same property in JavaScript."

Although considering they're going that way, they might as well go all the way down the rabbit hole and start counting:

JavaScript code:
location = location;
self.location = location;
self.self.location = location;
self.self.self.location = location;
self.self.self.self.location = location;
// And so on

Mogomra
Nov 5, 2005

simply having a wonderful time
What is the reasoning behind:

JavaScript code:
someObject['some_property']
vs

JavaScript code:
someObject.some_property
It's purely style, but why access the object like that when you know the property name? Do people just want their code to look weird?

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

Mogomra posted:

What is the reasoning behind:

JavaScript code:
someObject['some_property']
vs

JavaScript code:
someObject.some_property
It's purely style, but why access the object like that when you know the property name? Do people just want their code to look weird?

someObject['name' + i] and someObject[anotherVariable]. ;)

Adbot
ADBOT LOVES YOU

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

KARMA! posted:

someObject['name' + i] and someObject[anotherVariable]. ;)

Also someObject['!+#%'] works but someObject.!+#% will definitely not.

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