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.
 
  • Locked thread
Star War Sex Parrot
Oct 2, 2003

apparently it is, and the only Bachelor's program for it in California is at Cal Poly SLO

Adbot
ADBOT LOVES YOU

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:
mine was in NZ and i can get into the ieee with it i guess?? thats all i know / care to know

Morkai
May 2, 2004

aaag babbys

Plastic Snake posted:

rewrite those methods to not use EF. done!

that's pretty much exactly what i did.

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Star War Sex Parrot posted:

is "software engineering" an actual ABET degree?

there's an NCEES accreditation exam:

http://cdn1.ncees.co/wp-content/uploads/2012/11/Exam-specifications_PE-Software-Apr-2013.pdf

with, as of last year, a 50% pass rate

Nomnom Cookie
Aug 30, 2009



getting certified in practices no employer would allow me to employ would just be depressing

but it might piss off lousiana civil engineer man which is something

Luigi Thirty
Apr 30, 2006

Emergency confection port.

it's you, the grovergrammer

suffix
Jul 27, 2013

Wheeee!
is it engineers that make those high-quality SCADA and ICS systems?

Corla Plankun
May 8, 2007

improve the lives of everyone
i wish i could post the clusterfuck I just found at work.

the embedded software behind our most successful product is 3100 lines of dynamic c without a single subfunction

there are approximately 200 variables named something like tmp1, temp1, temp01, tp3, etc

every operation is surrounded by an if with very specific constraints like some kind of primative quasi state machine

it is so awful that it fills me with joy to look at. the cure for imposter syndrome is really, really bad code

Bloody
Mar 3, 2013

Corla Plankun posted:

i wish i could post the clusterfuck I just found at work.

the embedded software behind our most successful product is 3100 lines of dynamic c without a single subfunction

there are approximately 200 variables named something like tmp1, temp1, temp01, tp3, etc

every operation is surrounded by an if with very specific constraints like some kind of primative quasi state machine

it is so awful that it fills me with joy to look at. the cure for imposter syndrome is really, really bad code

i didnt know we worked together

CPColin
Sep 9, 2003

Big ol' smile.
code:
for (K key : map.keySet())
{
   V value = map.get(key);

   // ...
}
ugh quit it

also gently caress whoever at Sun decided that Map.get() and containsKey() should take an Object instead of a value of type K.

Brain Candy
May 18, 2006

CPColin posted:

code:
for (K key : map.keySet())
{
   V value = map.get(key);

   // ...
}
ugh quit it

also gently caress whoever at Sun decided that Map.get() and containsKey() should take an Object instead of a value of type K.

officially, this is a maths problem. if you didn't do this you couldn't do set operations. OTOH, this doesn't work at all on comparator based maps, have a runtime exception.

treemaps, a second class citizen

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Corla Plankun posted:

i wish i could post the clusterfuck I just found at work.

the embedded software behind our most successful product is 3100 lines of dynamic c without a single subfunction

there are approximately 200 variables named something like tmp1, temp1, temp01, tp3, etc

every operation is surrounded by an if with very specific constraints like some kind of primative quasi state machine

it is so awful that it fills me with joy to look at. the cure for imposter syndrome is really, really bad code

the software controlling those toyota ECUs that killed people had 10,000 global variables with names like that

Bloody
Mar 3, 2013

Luigi Thirty posted:

the software controlling those toyota ECUs that killed people had 10,000 global variables with names like that

ive had a busy career

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
is a bad design pattern with c to create a struct like uh

code:
struct butt {
int return_code;
int return_value;
};
so that i can indicate that a method failed just by setting return_code to 0? because it's pretty rare that NULL or 0 really work to indicate that a method failed.

Base Emitter
Apr 1, 2012

?

Corla Plankun posted:

i wish i could post the clusterfuck I just found at work.

the embedded software behind our most successful product is 3100 lines of dynamic c without a single subfunction

there are approximately 200 variables named something like tmp1, temp1, temp01, tp3, etc

every operation is surrounded by an if with very specific constraints like some kind of primative quasi state machine

it is so awful that it fills me with joy to look at. the cure for imposter syndrome is really, really bad code

a verrrrrrry long time ago when i was a wee college intern i ported a bunch of fortran data fitting code to c in order to build an interactive ui & graphing around it (this was pre-web) so some guys could run it in the field on a pc instead of submitting measurements to the home office to fit on a vax

the original fortran was from the days of 6-character-max identifiers and there was a naming convention of two-letter module ids followed by 4-digit function ids e.g. FU0666

you can guess what the manager of the team wanted me to do in my beautiful new c code

Doc Block
Apr 15, 2003
Fun Shoe

USSMICHELLEBACHMAN posted:

is a bad design pattern with c to create a struct like uh

code:

struct butt {
int return_code;
int return_value;
};

so that i can indicate that a method failed just by setting return_code to 0? because it's pretty rare that NULL or 0 really work to indicate that a method failed.

if you need to return a value AND an error code, then either have the function return the value and take a pointer to a variable to hold the error code, or vice versa. personally i'd go with the first one (function returns value) so that you can use the function in an expression if need be. returning a struct containing the return value and error code is very non-C and gay and dumb.

as to returning 0, remember that the idiom in C is for an error code of 0 to indicate success rather than failure (except in very specific cases, like for functions that return pointers).

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Doc Block posted:

if you need to return a value AND an error code, then either have the function return the value and take a pointer to a variable to hold the error code, or vice versa. personally i'd go with the first one (function returns value) so that you can use the function in an expression if need be. returning a struct containing the return value and error code is very non-C and gay and dumb.

as to returning 0, remember that the idiom in C is for an error code of 0 to indicate success rather than failure (except in very specific cases, like for functions that return pointers).

OKAY. i've been using a pointer to indicate error status it just seems messier to me than returning a struct.

i guess i'm somewhat confused about how you said 'if you need to return a value AND error code.' should i just be designing my code so that this is a rare situation? the problem i'm having is that due to the static typing, you have to return a value of the type specified, and unless you know that you can restrict the output of the method to some range, you cant pick a return a value to indicate failure.

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

USSMICHELLEBACHMAN posted:

is a bad design pattern with c to create a struct like uh

code:
struct butt {
int return_code;
int return_value;
};
so that i can indicate that a method failed just by setting return_code to 0? because it's pretty rare that NULL or 0 really work to indicate that a method failed.

this is a roundabout approach to option types but as doc block says they're "non-C". iirc the traditional approach to error codes is the errno header: you set errno to zero, make a call, then test errno afterwards to see if it's become nonzero

obviously this doesn't parallelize very well but it's what the library uses so~

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

coffeetable posted:

this is a roundabout approach to option types but as doc block says they're "non-C".
i was thinking 'what i really want here is a maybe', just when i'm 100% convinced i'm an idiot something comes around and knocks me back to 99%

Doc Block
Apr 15, 2003
Fun Shoe
code:
/* If error is non-NULL, will put the error code (if any) in error. If no error, error is set to 0 */
int func_that_returns_a_value(int input1, int input2, int *error);
Caller does something like

code:
int error = 0;        /* Always a good idea to have it set to a known value. */
int ret = func_that_returns_a_value(5, yourmom, &error);
if(error) {
        /* whoopsie */
} else {
        /* OK */
        printf("ret = %d\n", ret);
}

USSMICHELLEBACHMAN posted:

should i just be designing my code so that this is a rare situation?

Yes.

USSMICHELLEBACHMAN posted:

OKAY. i've been using a pointer to indicate error status it just seems messier to me than returning a struct.

If your function returns a pointer, just have it return NULL on error. You can use the above method to clarify exactly what error occurred if need be. Just be nice and have the error code not be required (pass NULL if you don't care), in case the caller of the function doesn't care why the function failed, just that it did.

Doc Block fucked around with this message at 08:07 on Apr 20, 2014

BONGHITZ
Jan 1, 1970

more like P(ee)

power botton
Nov 2, 2011

Morkai posted:

my chickens, they have come home to roost. currently tasked with "performance optimization" of our EF use. lol

lol

distortion park
Apr 25, 2011


CPColin posted:

code:
for (K key : map.keySet())
{
   V value = map.get(key);

   // ...
}
ugh quit it

also gently caress whoever at Sun decided that Map.get() and containsKey() should take an Object instead of a value of type K.

i'm an idiot but would someone mind explaining what's so bad here? it seems important to retain the possible many to one properties of a map, should it be replaced with an entrySet() thing?

CPColin
Sep 9, 2003

Big ol' smile.
yes, it should use entrySet(), so you don't have to do a get() for each iteration.

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

CPColin posted:

yes, it should use entrySet(), so you don't have to do a get() for each iteration.

what like this

http://docs.oracle.com/javase/6/docs/api/java/util/Map.html#entrySet()

CPColin
Sep 9, 2003

Big ol' smile.
yes:

code:
for (Map.Entry<K, V> entry : map.entrySet())
{
   K key = entry.getKey();
   V value = entry.getValue();

   // ...
}
this is annoying, too:

code:
int value = 0;

try
{
   value = Integer.parseInt(string);
}
catch (NumberFormatException e) {}
just put "value = 0;" in the catch block! don't initialize poo poo and then immediately overwrite it!

distortion park
Apr 25, 2011


CPColin posted:

yes, it should use entrySet(), so you don't have to do a get() for each iteration.

cool thanks

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY
ohhh thought you were complainin that sun hadn't included an entrySet method

Bloody
Mar 3, 2013

i want the equivalent of c#'s "using(butt) {}" in c am i a monster if i implement this with a preprocessor macro like
#define USING_BUTTS(X) prepare_butt(); X ; release_butt();

and then later in my code be all like
USING_BUTTS
(
    poorly_written_code;
)

GameCube
Nov 21, 2006

sounds like a pretty cool idea to me

Valeyard
Mar 30, 2012


Grimey Drawer
i feel like its bad, but i cant tell you why

Bloody
Mar 3, 2013

Valeyard posted:

i feel like its bad, but i cant tell you why

same

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Bloody posted:

i want the equivalent of c#'s "using(butt) {}" in c am i a monster if i implement this with a preprocessor macro like
#define USING_BUTTS(X) prepare_butt(); X ; release_butt();

and then later in my code be all like
USING_BUTTS
(
    poorly_written_code;
)

encapsulate the code X as a function x(*state) that takes a pointer to any state it needs to dick about with, then write a method

code:
void try_with_butts(x, *state) {
  prepare_butt()
  x(state)
  release_butt()
}

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Valeyard posted:

i feel like its bad, but i cant tell you why


because you're gonna change the names of prepare_butt and release_butt somewhere down the line and its all gonna stop working

Bloody
Mar 3, 2013

coffeetable posted:

encapsulate the code X as a function x(*state) that takes a pointer to any state it needs to dick about with, then write a method

code:
void try_with_butts(x, *state) {
  prepare_butt()
  x(state)
  release_butt()
}

this is embedded all of my state is global :q:

also changing the function names will cause a compiler error, leaving a random function x(*state) around will tempt future me into using it without calling try_with_butts and the butts are NOT optional!!!

PleasingFungus
Oct 10, 2012
idiot asshole bitch who should fuck off

nrook posted:

poo poo I forgot c# had nice anonclasses like that, it's been too long. also I'm not sure I ever knew there was a select that gave you the indices. in that case yeah the linq way is better

and yeah good code would not require a list of indices ever. But I was passing them into bad code, which wanted the list of indices. doing dumb things with sequences to pass them into various functions is a really, really common thing to have to do, so good languages make it easy

ah well, I (think?) java 8 should make this better anyway

hm, it's almost at though bad code begets bad code :)

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Bloody posted:

i want the equivalent of c#'s "using(butt) {}" in c am i a monster if i implement this with a preprocessor macro like
#define USING_BUTTS(X) prepare_butt(); X ; release_butt();

and then later in my code be all like
USING_BUTTS
(
&nbsp;&nbsp;&nbsp;&nbsp;poorly_written_code;
)

ghetto raii just use cpp

duTrieux.
Oct 9, 2003

coffeetable posted:

code:
butts(x

Star War Sex Parrot
Oct 2, 2003

Malcolm XML posted:

ghetto raii
mooooooooods

Adbot
ADBOT LOVES YOU

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Bloody posted:

this is embedded all of my state is global :q:

also changing the function names will cause a compiler error, leaving a random function x(*state) around will tempt future me into using it without calling try_with_butts and the butts are NOT optional!!!

if butt is something with an address, pass it to x along with the state

or have prepare_butts() return a token representing the fact the butts have been initialized, and pass the token to x(). no token, no execution.

or seeing as you're throwing global state around already just have prepare_butts() set a butts_prepared global flag. then first thing that x() and release_butts() does is check the flag is set; if it isn't, they either return silently or throw an error

  • Locked thread