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
HoboMan
Nov 4, 2010

Valeyard posted:

Now that you say this, in the python project imbworking on just now, Indont think I've seen many uses of if-then-else, it's all just really crazy inheritance and extreme OOIsm (that makes it hard to understand the flow of what's happening to virgin eyes)

the more i lean about oo dogma the more i realize that i never really liked oo design.
objects are cool and useful, but everything having to be an object in java was really annoying.

Adbot
ADBOT LOVES YOU

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.

HoboMan posted:

the more i lean about oo dogma the more i realize that i never really liked oo design.
objects are cool and useful, but everything having to be an object in java was really annoying.

I love OOP, but the way most books/classes teach OOP is really bad. Typified by the thread title.

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.
Inheritance is pretty bad, and you should avoid it.

Bloody
Mar 3, 2013

JawnV6 posted:

if-else chains are a sequence of conditional checks and jumps. they're executed in order and a lengthy has worse runtime than a switch. LOC is irrelevant

verilog has amazing case statements that don't really make sense outside of hardware. the control expression and case values can be interchanged, i.e. control expressions can be constant and case values variables. there's casex and casez which support dont-care and high-impedance values. there are keywords 'unique' and 'priority', although they just map to simulation assertions and help the synthesizer with optimizations.

like this is perfectly legal:
code:
priority case(3'b101)
    {ISR1_reg, 2'b01}: ...
    {ISR2_reg, 2'b01}: ...
    {2'b10, ISR3_reg}: ...
endcase

many, many things are legal in verilog, and i would not count that as a selling point

Bloody
Mar 3, 2013

Finster Dexter posted:

Inheritance is pretty bad, and you should avoid it.

interfaces, on the other hand, are good

Bloody
Mar 3, 2013

my unit test passes 93% of the time. what the gently caress

Zaxxon
Feb 14, 2004

Wir Tanzen Mekanik

Bloody posted:

my unit test passes 93% of the time. what the gently caress

what's it doing?

Bloody
Mar 3, 2013

interacting with a piece of hardware to update the state of some hardware connected to that hardware then reading back the state of that hardware to see if it matches what was set

there are A Lot of possible failure points in this path and a lot of room for heisenbugs

Luigi Thirty
Apr 30, 2006

Emergency confection port.

lol you can use the Watcom debugger on a dos program running in Dosbox through a serial port emulator

raminasi
Jan 25, 2005

a last drink with no ice

Bloody posted:

interacting with a piece of hardware to update the state of some hardware connected to that hardware then reading back the state of that hardware to see if it matches what was set

there are A Lot of possible failure points in this path and a lot of room for heisenbugs

i was under the impression that a test that actually talks to hardware is not a unit test

Bloody
Mar 3, 2013

call it w/e you want its an automated test

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
i'm not advocating writing a 40-line chain of if-then-else-else-else or whatever, but this guy is pathological to the point that he will not write the word "if", even when the thing he's doing is literally
code:
if (condition) return <value>;
[else] return <other value>
he'll instead do
code:
while(condition){
return value;}
return <other value>:
he will still do that as a while loop, or a crazy one-case switch statement with a default case as the else, etc. in code that will very clearly never be revised in a way that would require extensibility of the conditional. it's crazy.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

LeftistMuslimObama posted:

i'm not advocating writing a 40-line chain of if-then-else-else-else or whatever, but this guy is pathological to the point that he will not write the word "if", even when the thing he's doing is literally
code:

if (condition) return <value>;
[else] return <other value>

he'll instead do
code:

while(condition){
return value;}
return <other value>:

he will still do that as a while loop, or a crazy one-case switch statement with a default case as the else, etc. in code that will very clearly never be revised in a way that would require extensibility of the conditional. it's crazy.

case Foo of
"foo" -> foo;
_ -> bar
end.


seems legit

GameCube
Nov 21, 2006

raminasi posted:

i was under the impression that a test that actually talks to hardware is not a unit test

i interned at a company that made pci cards & poo poo for embedded PCs. my job was to run the tests on each software release, which involved manually hooking up loopback cables to the card's IO pins and running the sample programs to make sure the driver worked properly. given the choice of paying an actual programmer to write some kind of virtual hardware layer that could automate that part, or just having the intern do it, they went with the latter

cinci zoo sniper
Mar 15, 2013




lo and behold bad computre toucher thread, i dont know what unit tests specificaly are. shame me, but also link something to read, python if its oddly specific

GameCube
Nov 21, 2006

kalstrams posted:

lo and behold bad computre toucher thread, i dont know what unit tests specificaly are. shame me, but also link something to read, python if its oddly specific

bam http://pythontesting.net/books/python-testing-ebook/

cinci zoo sniper
Mar 15, 2013




gamecube scores critical hit on chome! chome is leaking pdf file

e: oh they actually want money, time to investigate

cinci zoo sniper fucked around with this message at 20:40 on May 23, 2016

HoboMan
Nov 4, 2010

LeftistMuslimObama posted:

he will still do that as a while loop, or a crazy one-case switch statement with a default case as the else, etc. in code that will very clearly never be revised in a way that would require extensibility of the conditional. it's crazy.

i got single case switches up the rear end over here, most of them don't even have defaults either.
the switch is strange but fine i guess.
those while loops on the other hand are completely insane.

coding dogma in action.

Bloody
Mar 3, 2013

good news i have successfully built tests that verify that my comms backpressure definitely works

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

Bloody posted:

good news i have successfully built tests that verify that my comms backpressure definitely works

i too fart at the office

cinci zoo sniper
Mar 15, 2013




kalstrams posted:

gamecube scores critical hit on chome! chome is leaking pdf file

e: oh they actually want money, time to investigate
yea i cant find anything better both in price and length so getting this, as i doubt id read 400 page tdd book about python

NihilCredo
Jun 6, 2011

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

would this work in C/C++ and related languages? I occasionally do this in .net instead of an if/elseif, when it allows for a clearer visual alignment:

code:
switch (true) {
  case butt.isDirty() : butt.wipe();       break;
  case butt.isRed()   : butt.wipeGently(); break;
  case butt.isClean() : toilet.flush();    break;
}

JewKiller 3000
Nov 28, 2006

by Lowtax

NihilCredo posted:

would this work in C/C++ and related languages? I occasionally do this in .net instead of an if/elseif, when it allows for a clearer visual alignment:

code:
switch (true) {
  case butt.isDirty() : butt.wipe();       break;
  case butt.isRed()   : butt.wipeGently(); break;
  case butt.isClean() : toilet.flush();    break;
}

stop that

HoboMan
Nov 4, 2010

oh, ok. treating a null as a string in javascript yields "null". i was dumb to expect otherwise

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

HoboMan posted:

oh, ok. treating a null as a string in javascript yields "null". i was dumb to expect otherwise

Actually, yes.

Valeyard
Mar 30, 2012


Grimey Drawer

HoboMan posted:

oh, ok. treating a null as a string in javascript yields "null". i was dumb to expect otherwise

this happens in Java too

Bloody
Mar 3, 2013

its actually kind of useful sometimes

JawnV6
Jul 4, 2004

So hot ...

Bloody posted:

many, many things are legal in verilog, and i would not count that as a selling point
there are a lot more instances of "if this thing is hot, nothing else matters" and it makes those easier to write. like expanding a hamming code can be done in a single casex

Bloody posted:

good news i have successfully built tests that verify that my comms backpressure definitely works
what'd you end up doing for that?

LeftistMuslimObama posted:

i'm not advocating writing a 40-line chain of if-then-else-else-else or whatever, but this guy is pathological to the point that he will not write the word "if", even when the thing he's doing is literally
it's confusing, you'd expect someone high on whiles to be using do/while constructs instead of...

uh... "return after while"?

honestly there's some really bad parts of the C spec if something looks like an infinite loop

jesus WEP
Oct 17, 2004


i did proper test-first tdd on the last project i worked on and it was slower to write but quicker to refactor, and the suite of tests ended up being better than what i usually come up with, thanks uncle bob

thuncle bob

Bloody
Mar 3, 2013

JawnV6 posted:

there are a lot more instances of "if this thing is hot, nothing else matters" and it makes those easier to write. like expanding a hamming code can be done in a single casex

what'd you end up doing for that?

it's confusing, you'd expect someone high on whiles to be using do/while constructs instead of...

uh... "return after while"?

honestly there's some really bad parts of the C spec if something looks like an infinite loop

I built up a gigantic packet (>1 megabyte - big enough to overflow every fifo outside of the PC) of operations that would cause delays and attempted to transmit the entire packet at once. the FPGA is counting the number of packets it's processing and the software is counting the number it's sending (and also timing the whole thing). the rx and tx numbers match and the whole transmission took multiple minutes, while a same-size transmission of no-op data took a second

JawnV6
Jul 4, 2004

So hot ...
i meant backpressure implementation, not test case :v:

there's a really good feeling running a test and seeing it go green the first time tho

Bloody
Mar 3, 2013

oh lol

the block talking to the USB hardware monitors the fifo's almost full flag and stops pulling data out of the usb hardware when it trips. the usb hardware + driver apparently handle this correctly (which matches the documentation but now is actually tested) so all is well.

raminasi
Jan 25, 2005

a last drink with no ice

JawnV6 posted:

there's a really good feeling running a test and seeing it go green the first time tho

i actually get worried when that happens, because maybe i wrote the test wrong

Valeyard
Mar 30, 2012


Grimey Drawer

raminasi posted:

i actually get worried when that happens, because maybe i wrote the test wrong

i commited a test a couple weeks back, got a review comment a couple days later like

"this test doesnt have any assertions lol"

looks like I had been looking at the coverage for themethod, saw that it passed and ocver the method, went away and did something else, then forgot and just committed it, fail

weird
Jun 4, 2012

by zen death robot

NihilCredo posted:

would this work in C/C++ and related languages? I occasionally do this in .net instead of an if/elseif, when it allows for a clearer visual alignment:

code:
switch (true) {
  case butt.isDirty() : butt.wipe();       break;
  case butt.isRed()   : butt.wipeGently(); break;
  case butt.isClean() : toilet.flush();    break;
}

no, the cases have to be constant integral expressions

gonadic io
Feb 16, 2011

>>=

Valeyard posted:

i commited a test a couple weeks back, got a review comment a couple days later like

"this test doesnt have any assertions lol"

looks like I had been looking at the coverage for themethod, saw that it passed and ocver the method, went away and did something else, then forgot and just committed it, fail

you verified that the method doesn't throw an exception!

Plorkyeran
Mar 22, 2007

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

GameCube posted:

i'm so freaking poor that i got myself a library card last week.

i should do that. the library is only a block out of the way from my daily commute so it's not like it'd be difficult to just swing by, but i haven't actually gone inside it since high school

Luigi Thirty
Apr 30, 2006

Emergency confection port.

working on my C++ dos toy thing. i have some routines set up to draw lines... I'm trying to feed an array of points into a general polygon drawing routine but pointers are driving me nuts as usual

code:
Point polygonPoints[] = {Point(50, 50), Point(80, 50), Point(110, 50)};
Point *ptrPolygonPoints = polygonPoints;
draw_polygon(layer_background, ptrPolygonPoints, 3, 0x02);

void draw_polygon(char *framebuffer, Point *points[], int num_points, int color);
code:
dosthing\scorched.cpp(21): Error! E473: col(17) function argument(s) do not match those in prototype
dosthing\scorched.cpp(21): Note! N392: col(17) definition: 'void draw_polygon( char *, Point * *, int, int )'
dosthing\scorched.cpp(21): Note! N643: col(17) cannot convert argument 2 defined in: dosthing\scorched.cpp(21) (col 36)
dosthing\scorched.cpp(21): Note! N630: col(17) source conversion type is 'Point * (lvalue)'
dosthing\scorched.cpp(21): Note! N631: col(17) target conversion type is 'Point * *'
what dumb thing am i doing wrong here (besides writing a program targeting protected mode DOS using Watcom C++)

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
you're passing an array of points to something wanting a pointer to an array of points

Adbot
ADBOT LOVES YOU

quiggy
Aug 7, 2010

[in Russian] Oof.


NihilCredo posted:

would this work in C/C++ and related languages? I occasionally do this in .net instead of an if/elseif, when it allows for a clearer visual alignment:

code:
switch (true) {
  case butt.isDirty() : butt.wipe();       break;
  case butt.isRed()   : butt.wipeGently(); break;
  case butt.isClean() : toilet.flush();    break;
}

this is not legal c/c++, no

  • Locked thread