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
Lexical Unit
Sep 16, 2003

mr_jim posted:

I don't have a lot of C++ experience. What's the horror here?
STL style containers will offer a number of different kinds of iterators such that they can interop with algorithms. However the writer of that code doesn't appear to understand the meaning of "const_iterator." Think about it. If the iterator itself is const... it's not really an iterator, is it? const_iterator is supposed to be an iterator that doesn't allow algorithms to modify the elements being iterated over. Not an iterator that's conceptually const (which I would take to mean an iterator that only ever points to one thing).

Adbot
ADBOT LOVES YOU

Lexical Unit
Sep 16, 2003

Avenging Dentist posted:

No one uses "volatile" for anything but primitives, and even that is rare, so it's not like anyone would notice.
Yeah volatile is great* for all kinds of things, like thread safety! :pwn:


*: not great.

Lexical Unit
Sep 16, 2003

Please tell me you are a teacher who is grading a high school student's homework.

Lexical Unit
Sep 16, 2003

jarito posted:

I've seen MUCH worse on our exam we give to people applying for jobs.
I'll just assume your company routinely hires kindergartners then.

Lexical Unit
Sep 16, 2003

Yeah I have been interviewed by no less than 6 people over the course of a few hours by a number of companies and not a single one of them seemed interested in my coding ability. Most just wanted to know if I'd "fit the culture." Then one time someone asked me to solve a simple parallelization problem and it took me about 30 seconds, the guy was so surprised it seemed he would faint.

What's funny is usually the 5th or 6th interviewers would start off with something like, "Well I'm sure you've seen enough technical problems and written enough code already, seeing as you've been here for hours..."

"Actually no, I haven't seen any of either."

It's like no one actually wants to ask technical questions or make coding problems if they don't have to.

Lexical Unit
Sep 16, 2003

I'd have to agree with AD. I work with some people who couldn't have a normal conversation with someone outside their field of work (or much of the time inside their field of work), especially if they tried. But they get their job done just fine.

Lexical Unit
Sep 16, 2003

So that pretty much describes my boss :cry:

Lexical Unit
Sep 16, 2003

C++:
code:
int sign = (1, 0, -1);
float f = /* ... */;
float f_neg = (f == fabs (f)) ? 1.0 : -1.0;
float some_calc = fabs (f * /* ... */);
some_calc *= f_neg * sign;
Production code. All I've done is change the names and remove the boring parts.

Lexical Unit
Sep 16, 2003

code:
std::complex<double> d = (0.0, 1.0); // why's it getting it backwards? Whatever.

Lexical Unit
Sep 16, 2003

code:
FOR I = 1 TO 3
	SELECT CASE I
	CASE 1
		SELECT CASE PD(1)
			CASE IS < 1
				FC(I) = 6.167295 / 60
			CASE IS < 4
				 FC(I) = 6.167295 / 60
			CASE IS < 7
				 FC(I) = 6.596425 / 60
			CASE IS <= 10
				FC(I) = 7.065092 / 60
			CASE IS <= 15
				FC(I) = 7.406472 / 60
		END SELECT
	CASE 2
		SELECT CASE PD(2)
			CASE IS < 1
				FC(I) = 5.387361 / 60
			CASE IS < 4
				 FC(I) = 5.387361 / 60
			CASE IS < 7
				 FC(I) = 5.75835 / 60
			CASE IS <= 10
				FC(I) = 6.252539 / 60
			CASE IS <= 15
				FC(I) = 6.595717 / 60
		END SELECT
	CASE 3
		SELECT CASE PD(3)
			 CASE IS < 1
				FC(I) = 7.052662 / 60
			CASE IS < 4
				 FC(I) = 7.052662 / 60
			CASE IS < 7
				 FC(I) = 7.499374 / 60
			CASE IS <= 10
				FC(I) = 7.931458 / 60
			CASE IS <= 15
				FC(I) = 8.203164 / 60
		END SELECT
	END SELECT
NEXT I

Lexical Unit
Sep 16, 2003

Zombywuf posted:

Or simply automate a process to collect the warnings, svn blame to get the developer from the file and line number and email them the relevant lines from the error log.

Bonus points for one email per line with a warning.

I work with BigRedDot, and I have emailed people about warnings and bugs before. Never has an email I sent out about a bug or warning resulted in the bug or warning being fixed. And every time I've fixed a bug or warning in a library I didn't initially write, it's caused my boss to respond with, "you shouldn't be wasting your time with that. Don't compile with -Wall. If the warning isn't on by default then just ignore it."

My boss is the guy who created our build system.

Features of our build system:

  • Dependancies expressed as symlinks or directories (it doesn't distinguish).
  • Only one main() function allowed per directory.
  • Your current directory is your target executable and has the same name as your directory.
  • Each subdirectory (including symlinks) become an individual library named "lib" + directory name + ".a"
  • Directories containing a _ignore file are ignored.
  • Written in mishmash of perl/bash and pre-made Makefiles.
  • The only way to have different behavior is to create a _override file that is-a Makefile that gets concatenated to the end of the generated Makefile.

Lexical Unit
Sep 16, 2003

Janin posted:

code:
for(int i=0;i<workingDir.size();i++){
  if((workingDir[i] < 'a')||(workingDir[i] > 'z'))
    throw Exception("special characters in working dir !!")
}

system("find " + workingDir + "/ -exec rm -rf '{}' ';'" + " >& /dev/null");
:raise: I want to meet the person who wrote this and ask them what they were thinking.

Lexical Unit
Sep 16, 2003

code:
char* data = blarg ();
SomeShittyCppClass o;
unsigned len;
o.Parse (data, len);
f = fopen (o.GetValue ("fileName").c_str (), "wb");
wrote = fwrite ((char*)&o, len, 1, f);
assert (wrote == len);
Dude standing in my office just a few moments ago: "Why is my program asserting?!?" :qq:

Lexical Unit
Sep 16, 2003

TagUrIt posted:

code:
double correctDegrees(double degrees) {
  while (degrees < 0) degrees += 360;
  while (degrees > 360) degrees -= 360;

  return toDegrees(toRadians(degrees));
}

ymgve posted:

code:
        while (positions.last()->pitch - pitch > 180.0) {
            pitch += 360.0;
        }

        while (positions.last()->pitch - pitch < -180.0) {
            pitch -= 360.0;
        }
Y'all must be my coworkers. I work with code like that every day of my life.

Lexical Unit
Sep 16, 2003

My co-worker came to me today asking how he could make it a compile time error to access an element in a map via operator[]() for when that element didn't exist in the map.

He explained the bigger problem to me like this: "I want to be able to be like map[blah] or whatever but the problem is that if there's no entry for blah then it will insert an invalid pointer into my map!"

I told him to check if blah exists in the map before trying to access map[blah]. He actually laughed at me and told me that would be ludicrous.

He is currently trying to figure out how to write a "smart" pointer that will throw an exception when default constructed as a replacement for putting bare pointers in a map.

Lexical Unit
Sep 16, 2003

Your tax dollars at work folks (if you're American that is).

Lexical Unit
Sep 16, 2003

lumberjack4 posted:

Has he ever written error handling in any of his code?
No of course not that would be ludicrous :v:

Lexical Unit
Sep 16, 2003

No sorry there's a currently a hiring freeze in effect. I'm afraid you'll have to go ask non-retarded questions elsewhere for now.

Lexical Unit
Sep 16, 2003

Lexical Unit fucked around with this message at 23:16 on Mar 4, 2020

Lexical Unit
Sep 16, 2003

code:
// foo.h:

#ifndef FOO_H
#define FOO_H

struct foo
{
  foo();
  static void bar();
  static void baz();
  manager m;

  // other stuff ...
};

static foo* HACK;

#endif


// foo.cc:

#include "foo.h"

foo::foo(int id)
{
  HACK = this;
  m.register_event (bar, 3);
  m.register_event (baz, 4);
}

foo::bar(int id)
{
  // uses HACK
}

foo::baz(int id)
{
  // uses HACK
}
Note that it's completely possible and straight forward to use non-static methods for events.

Lexical Unit
Sep 16, 2003

So my boss comes into my office the other day and says that we've sold some Canadian group on our display system. They only have one request, that we change all Imperial units to SI. This is a nightmare because there's no structure or coherence to any of the GUIs we write. Each display and each dialog window is the pet project of someone, some single person, who works on it alone with no peer review, and no standards to guide them.

But I shouldn't fear because my boss has the solution! He picked up a dry erase marker and wrote this on my white board:

ENV_VAR_UNITS_CONVERSION_FACTOR="0.9144"

The solution is so obvious!

Lexical Unit
Sep 16, 2003

NotShadowStar posted:

Sorry about your floating point future hell.

Thank gord my boss doesn't work in finances, because I'm sure he'd use floats to store money. Instead he works in the defense industry where things like "quality" and "corectness" are of no real concern.

Lexical Unit
Sep 16, 2003

I just replaced about 500 lines of lovely C++ with about 10 of Boost.Spirit.
Here's a taste of what I just vanquished (formatting preserved):
code:
string ReadTitle(ifstream& file)
{
while(StripWhiteSpace(file)) ;
if(file.peek()=='[')
{
  file.ignore();
  string ret="";
  while(file.peek()!=']' && !file.eof())
  {
    if(file.peek()=='\n' || file.peek()=='\0' ||file.eof())
    {
      printf("Bad format\n");
      return "";
    }
  file.ignore()
  printf("title = %s\n",ret.c_str());
  return ret;
  else if(file.good()) {printf("invalid file format Title::(%c)[%d/%d]\n", file.peek(), file.peek(), file.good());
  sleep(1);}
  StripComment(file);
  return "";
}

Lexical Unit fucked around with this message at 20:08 on May 19, 2011

Lexical Unit
Sep 16, 2003

We have to submit powerpoint slides each week for a group meeting. For my next slide I added a bullet to the Issues section: "Overcoming the cognitive dissonance I get from seeing yards and meters on the same graph."

I do so love working here. :haw:

Lexical Unit
Sep 16, 2003

NotShadowStar posted:

fffffffffffffff goddamn I'm getting PTSD
Rant could also be about defense contracting. :argh:

Lexical Unit
Sep 16, 2003

My boss just came into my office and told me he's putting using namespace std; in a header file I wrote because his textual parser for some swig whatever doesn't recognize std::string, just string.

Adbot
ADBOT LOVES YOU

Lexical Unit
Sep 16, 2003

TasteMyHouse posted:

can you at least convince him to use using std::string;?
It's not even worth the effort at this point. This is like the least horrible thing he's ever done.

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