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
Linear Zoetrope
Nov 28, 2011

A hero must cook

Blotto Skorzany posted:

Since it's an online course, probably. Frankly I don't get why they'd go with C over C++ (enjoy casting back and forth with void* and friends to make generic data structures - and I say this as a C guy), but a data structures course is about the last place you'd want to use a language that lacks value semantics or explicit memory allocation.

I like the way my undergrad did it. We had a more abstract "analysis of discrete structures" course which went over all the data structures and some algorithmic stuff both in the abstract (pseudocode/big-O) and with concrete implementation assignments in a managed language (Java, which I don't really like, but it worked). We also had a required "C and Unix Programming" course with that as a prerequisite which, aside from some shell scripting minutiae, could be described as "data structures: the fiddly bits edition." It allowed the course to be more stringent about memory management. For instance, in the class I'm TAing, we're not worrying about memory leaks. In the C course I took in my undergrad, since we were expected to know how the various structures we were using worked, we had added constraints like the fact that no matter how complex our project was, valgrind had to exit cleanly.

It also allowed both classes to have more complex projects. We had some hardcore tree stuff in the abstract course, and since you were expected to know how all the data structures worked in the C course, we could do interesting things with them.

The class I'm TAing is very much an abstract course, and the texts were using are deliberately pseudocodey and non-language specific. We're just using C because our school uses C (and, rarely, C++) for 100-200 level courses. The memory management aspect of data structures isn't emphasized, other than the fact that they have to use malloc instead of realloc.

Linear Zoetrope fucked around with this message at 21:00 on Jan 6, 2015

Adbot
ADBOT LOVES YOU

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

QuarkJets posted:

Using superscripts/subscripts to denote upper/lower bounds on an integral feels intuitive to non-CS majors, a majority of LaTeX users, and there's literally no other reason to use a superscript/subscript on an integral sign. This might be a horror to someone who designs computer languages, but it's also a helpful feature for users.

I don't know where to draw the line between "let's make this programming language as beautiful as possible" and "let's make something that's easy to use and produces nice output", but it seems like a lot of language decisions put these two ideas in conflict

It didn't feel intuitive to me when I wasn't a CS major (actually I've never been one). Most people are going to have to look it up anyway, and things tend to be more intuitive and easier to remember when they're consistent: \frac, \sqrt, \sin \emph etc. all take arguments in curly braces, but this one doesn't.

Zopotantor posted:

The "\int_a^b" notation is inherited from base TeX, while "\frac" is LaTeX specific.
Also, "\int_a^b" is not actually a special case; in an inline formula, the limits will be typeset as sub/superscripts, it's only displayed formulas that are treated specially.

That makes sense in terms of how that came about, although nowadays it's mostly used in displayed formulas. It still seems like a wart to me. Maybe it would have been nice if LaTeX defined it's own integral command that looks more like the rest of the new commands and left the old one as is or something.

LazyArtifact
Mar 23, 2006
Starting working in my first programming job. I found this gem.

code:
public T FindItem(int id, List<string> includes, bool nullOk = false)
{
    T result = null;

    if (includes == null)
    {
        result = _objs.FirstOrDefault(x => x.Id == id);
    }
    else
    {
        switch (includes.Count)
        {
            case 0:
                result = _objs
                            .FirstOrDefault(x => x.Id == id);
                break;
            case 1:
                result = _objs
                            .Include(includes[0])
                            .FirstOrDefault(x => x.Id == id);
                break;
            case 2:
                result = _objs
                            .Include(includes[0])
                            .Include(includes[1])
                            .FirstOrDefault(x => x.Id == id);
                break;
            case 3:
                result = _objs
                            .Include(includes[0])
                            .Include(includes[1])
                            .Include(includes[2])
                            .FirstOrDefault(x => x.Id == id);
                break;
            case 4:
                result = _objs
                            .Include(includes[0])
                            .Include(includes[1])
                            .Include(includes[2])
                            .Include(includes[3])
                            .FirstOrDefault(x => x.Id == id);
                break;
            case 5:
                throw new Exception("4 or less");
            default:
                result = _objs.Single(x => x.Id == id);
                break;
        }
    }

    if (nullOk)
    {
        return result;
    }
    if (result == null)
    {
        throw new Exception();
    }
    
    return result;
}
There were actually a lot more case blocks in the real code. Has this guy never heard of loops or something? Is there some voodoo performance reason to doing this or is this something to inflate the line count and increase insanity? He also writes predicates like: a || (!a && b). Uh, was a || b too simple or something?

itskage
Aug 26, 2003


The weird use of the switch statement aside, if it's 6 or higher then it defaults instead of hitting the "4 or less" exception? Nice!

Polio Vax Scene
Apr 5, 2009



One is great, two is okay, three is nice, four is fine, five is RIGHT OUT (six and everything after is okay.)

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

LazyArtifact posted:

Starting working in my first programming job. I found this gem.

code:
public T FindItem(int id, List<string> includes, bool nullOk = false)
{
    T result = null;

    if (includes == null)
    {
        result = _objs.FirstOrDefault(x => x.Id == id);
    }
    else
    {
        switch (includes.Count)
        {
            case 0:
                result = _objs
                            .FirstOrDefault(x => x.Id == id);
                break;
            case 1:
                result = _objs
                            .Include(includes[0])
                            .FirstOrDefault(x => x.Id == id);
                break;
            case 2:
                result = _objs
                            .Include(includes[0])
                            .Include(includes[1])
                            .FirstOrDefault(x => x.Id == id);
                break;
            case 3:
                result = _objs
                            .Include(includes[0])
                            .Include(includes[1])
                            .Include(includes[2])
                            .FirstOrDefault(x => x.Id == id);
                break;
            case 4:
                result = _objs
                            .Include(includes[0])
                            .Include(includes[1])
                            .Include(includes[2])
                            .Include(includes[3])
                            .FirstOrDefault(x => x.Id == id);
                break;
            case 5:
                throw new Exception("4 or less");
            default:
                result = _objs.Single(x => x.Id == id);
                break;
        }
    }

    if (nullOk)
    {
        return result;
    }
    if (result == null)
    {
        throw new Exception();
    }
    
    return result;
}
There were actually a lot more case blocks in the real code. Has this guy never heard of loops or something? Is there some voodoo performance reason to doing this or is this something to inflate the line count and increase insanity? He also writes predicates like: a || (!a && b). Uh, was a || b too simple or something?

That || thing there looks like a ghetto XOR to me. (a) || ((!a) && (b)) should act like a ^ b.

The Laplace Demon
Jul 23, 2009

"Oh dear! Oh dear! Heisenberg is a douche!"

LeftistMuslimObama posted:

That || thing there looks like a ghetto XOR to me. (a) || ((!a) && (b)) should act like a ^ b.

Not quite. XOR is (a && !b) || (!a && b), so it'd be equivalent to a || (a ^ b).

EDIT:

Dessert Rose posted:

Which is just a || b. I wrote the post you are now making and then took a closer look at what the results will be.
:downs: :eng99:

Soricidus posted:

The horrors are coming from inside the thread
Really?

The Laplace Demon fucked around with this message at 04:03 on Jan 7, 2015

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

The Laplace Demon posted:

Not quite. XOR is (a && !b) || (!a && b), so it'd be equivalent to a || (a ^ b).

Which is just a || b. I wrote the post you are now making and then took a closer look at what the results will be.

For us to be evaluating (a ^ b), a has to be false, which means all that matters is the value of b. If a is true then we don't check b; if a is false then we return the value of b. Therefore, a || b.

LazyArtifact
Mar 23, 2006
I don't know. Maybe I'm going insane too. I thought it just simplified to a || b? https://dotnetfiddle.net/qDAEYH

Soricidus
Oct 21, 2010
freedom-hating statist shill
The horrors are coming from inside the thread

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Yeah guys it's just a convoluted way to say A || B and that guy should be fired (out of a cannon, etc)

http://www.wolframalpha.com/input/?i=a+%7C%7C+%28%21a+%26%26+b%29

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
A patch from our SoC vendor:

C++ code:
/**/
void hdmi_hw_set_powermode(hdmitx_dev_t* hdmitx_device)
{
    int vic = hdmitx_device->cur_VIC;

    switch(vic) {
+   case HDMI_1280x1024:
    case HDMI_480i60:
    case HDMI_480i60_16x9:
    case HDMI_576p50:
    case HDMI_576p50_16x9:
    case HDMI_576i50:
    case HDMI_576i50_16x9:
    case HDMI_480p60:
    case HDMI_480p60_16x9:
    case HDMI_720p50:
    case HDMI_720p60:
    case HDMI_1080i50:
    case HDMI_1080i60:
    case HDMI_1080p24://1080p24 support
    case HDMI_1080p50:
    case HDMI_1080p60:
    default:
        //aml_write_reg32(P_HHI_HDMI_PHY_CNTL0, 0x08c38d0b);
        break;
    }
    //aml_write_reg32(P_HHI_HDMI_PHY_CNTL1, 2);
}

EAT THE EGGS RICOLA
May 29, 2008

Suspicious Dish posted:


C++ code:
    case HDMI_1080p24://1080p24 support

Hey everyone, anyone know what kind of resolution this case might support? I can't tell without the comments.

Linear Zoetrope
Nov 28, 2011

A hero must cook

EAT THE EGGS RICOLA posted:

Hey everyone, anyone know what kind of resolution this case might support? I can't tell without the comments.

My favorite comments are the ones like

code:
y = x*x + 2 // Adds two to the square of x

b0lt
Apr 29, 2005

Jsor posted:

My favorite comments are the ones like

code:
y = x*x + 2 // Adds two to the square of x

itym
code:
y = x*x + 3 // Adds two to the square of x

Plorkyeran
Mar 22, 2007

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

HappyHippo posted:

That makes sense in terms of how that came about, although nowadays it's mostly used in displayed formulas. It still seems like a wart to me. Maybe it would have been nice if LaTeX defined it's own integral command that looks more like the rest of the new commands and left the old one as is or something.

LaTeX is pretty much nothing but a giant mass of historical warts.

apseudonym
Feb 25, 2011

Suspicious Dish posted:

A patch from our SoC vendor:

C++ code:
/**/
void hdmi_hw_set_powermode(hdmitx_dev_t* hdmitx_device)
{
    int vic = hdmitx_device->cur_VIC;

    switch(vic) {
+   case HDMI_1280x1024:
    case HDMI_480i60:
    case HDMI_480i60_16x9:
    case HDMI_576p50:
    case HDMI_576p50_16x9:
    case HDMI_576i50:
    case HDMI_576i50_16x9:
    case HDMI_480p60:
    case HDMI_480p60_16x9:
    case HDMI_720p50:
    case HDMI_720p60:
    case HDMI_1080i50:
    case HDMI_1080i60:
    case HDMI_1080p24://1080p24 support
    case HDMI_1080p50:
    case HDMI_1080p60:
    default:
        //aml_write_reg32(P_HHI_HDMI_PHY_CNTL0, 0x08c38d0b);
        break;
    }
    //aml_write_reg32(P_HHI_HDMI_PHY_CNTL1, 2);
}

Vendors, vendors never change.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Plorkyeran posted:

LaTeX is pretty much nothing but a giant mass of historical warts.

Also TeX itself is not really a programming language; it's almost all macro expansion and text substitution, with a few special horrors like \expandafter thrown in.

Hiowf
Jun 28, 2013

We don't do .DOC in my cave.

Suspicious Dish posted:

A patch from our SoC vendor:

It probably came with strong guarantees that it's fixing whatever problem you complained about?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Skuto posted:

It probably came with strong guarantees that it's fixing whatever problem you complained about?

It came as an attachment to an MS Outlook email with no body text and a subject line of "fix issue"

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

Suspicious Dish posted:

A patch from our SoC vendor:

C++ code:
/**/
void hdmi_hw_set_powermode(hdmitx_dev_t* hdmitx_device)
{
    int vic = hdmitx_device->cur_VIC;

    switch(vic) {
+   case HDMI_1280x1024:
    case HDMI_480i60:
    case HDMI_480i60_16x9:
    case HDMI_576p50:
    case HDMI_576p50_16x9:
    case HDMI_576i50:
    case HDMI_576i50_16x9:
    case HDMI_480p60:
    case HDMI_480p60_16x9:
    case HDMI_720p50:
    case HDMI_720p60:
    case HDMI_1080i50:
    case HDMI_1080i60:
    case HDMI_1080p24://1080p24 support
    case HDMI_1080p50:
    case HDMI_1080p60:
    default:
        //aml_write_reg32(P_HHI_HDMI_PHY_CNTL0, 0x08c38d0b);
        break;
    }
    //aml_write_reg32(P_HHI_HDMI_PHY_CNTL1, 2);
}

*cuts forearm* We are blood brothers, now

itskage
Aug 26, 2003


Did you edit out anything, or is that literally doing nothing?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

itskage posted:

Did you edit out anything, or is that literally doing nothing?

Coding horrors: post the code that makes you laugh (or cry)

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Could it be a workaround for some embedded toolchain compiler bug?

Hiowf
Jun 28, 2013

We don't do .DOC in my cave.

Munkeymon posted:

Could it be a workaround for some embedded toolchain compiler bug?

GCC for embedded architectures often tends to be an outdated version full of weird bugs.

But from experience, no, I don't think that is it.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Munkeymon posted:

Could it be a workaround for some embedded toolchain compiler bug?

We use a standard upstream ARM gcc. This is a patch to the Linux kernel, after all.

Evil_Greven
Feb 20, 2007

Whadda I got to,
whadda I got to do
to wake ya up?

To shake ya up,
to break the structure up!?
I'm beginning to think that the way colleges teach CS - or at least programming - is a horror itself.

Doing a bunch of reading lately, I ended up getting pointed towards ye olde Lisp - specifically, Scheme. I've been learning it over this past week (via Racket implementation), and it seems a hell of a lot more useful for teaching than loving C/C++ or Java.

FlapYoJacks
Feb 12, 2009

Suspicious Dish posted:

A patch from our SoC vendor:

C++ code:
/**/
void hdmi_hw_set_powermode(hdmitx_dev_t* hdmitx_device)
{
    int vic = hdmitx_device->cur_VIC;

    switch(vic) {
+   case HDMI_1280x1024:
    case HDMI_480i60:
    case HDMI_480i60_16x9:
    case HDMI_576p50:
    case HDMI_576p50_16x9:
    case HDMI_576i50:
    case HDMI_576i50_16x9:
    case HDMI_480p60:
    case HDMI_480p60_16x9:
    case HDMI_720p50:
    case HDMI_720p60:
    case HDMI_1080i50:
    case HDMI_1080i60:
    case HDMI_1080p24://1080p24 support
    case HDMI_1080p50:
    case HDMI_1080p60:
    default:
        //aml_write_reg32(P_HHI_HDMI_PHY_CNTL0, 0x08c38d0b);
        break;
    }
    //aml_write_reg32(P_HHI_HDMI_PHY_CNTL1, 2);
}

I love vendor HDMI drivers. :allears: You should take a look at the imx6 hdmi linux stack. :swoon:

Im curious why they just didn't put a return at the top and call it good. :psyduck:

edit* Here is the same function from a different (older version perhaps?) kernel?

code:
/**/
void hdmi_hw_set_powermode(hdmitx_dev_t* hdmitx_device)
{
    struct hdmi_phy_set_data *pdata = NULL;
    int vic = hdmitx_device->cur_VIC;
    power_mode = 1;
    hdmi_phy_wakeup();
    // relate to different board
    if(hdmitx_device->config_data.phy_data){
        pdata = hdmitx_device->config_data.phy_data;
        printk("HDMI: get brd phy data\n");
    }
    printk("hdmi phy setting\n");
#define SET_PHY_BRD(a)                                          \
    do{                                                         \
        pdata = hdmitx_device->config_data.phy_data;            \
        if(pdata){                                              \
            while((pdata->addr != -1)){                         \
                if(pdata->freq == a)                            \
                    hdmi_wr_reg(pdata->addr, pdata->data);      \
                pdata++;                                        \
            }                                                   \
        }                                                       \
      }while(0)            
    // Default Setting
//    hdmi_wr_reg(TX_HDMI_PHY_CONFIG0, 0xfe << HDMI_COMMON_b7_b0);    //0x10
    hdmi_wr_reg(TX_HDMI_PHY_CONFIG1, (0xf  <<HDMI_CTL_REG_b3_b0) |
                                     (0xe  << HDMI_COMMON_b11_b8));    //0x10
    hdmi_wr_reg(TX_HDMI_PHY_CONFIG2, 0xff << HDMI_CTL_REG_b11_b4);   //0xf7
    hdmi_wr_reg(TX_HDMI_PHY_CONFIG3, (0xf << HDMI_MDR_PU)|
                                     (0x7 << HDMI_L2H_CTL));    //0x16
    hdmi_wr_reg(TX_HDMI_PHY_CONFIG4, (0x2 << HDMI_PREM_CTL) |
                                     (0x0 << HDMI_MODE_P) |
                                     (0x1 << HDMI_PHY_CLK_EN) |
                                     (0x0 << HDMI_LF_PD)
                                     );      //0x14 Prem
    hdmi_wr_reg(TX_HDMI_PHY_CONFIG5, (0x7 << HDMI_VCM_CTL) | 
                                     (0x7 << HDMI_PREFCTL));         //0x15 Slew
    hdmi_wr_reg(TX_HDMI_PHY_CONFIG6, (0xa << HDMI_SWING_CTL) | 
                                     (0x0 << HDMI_RTERM_CTL) );
    // relate to different board
    switch(vic)
    {

        case HDMI_480i60:
        case HDMI_480i60_16x9:
        case HDMI_576p50:
        case HDMI_576p50_16x9:
        case HDMI_576i50:
        case HDMI_576i50_16x9:
        case HDMI_480p60:
        case HDMI_480p60_16x9:
            SET_PHY_BRD(27);
            break;
        case HDMI_720p50:
        case HDMI_720p60:
        case HDMI_1080i50:
        case HDMI_1080i60:
        case HDMI_1080p24://1080p24 support
            SET_PHY_BRD(74);
            break;
        case HDMI_1080p50:
        case HDMI_1080p60:
            SET_PHY_BRD(148);
            break;
        default:
            break;
    }
    switch(power_mode){
        case 1:
            hdmi_wr_reg(TX_CORE_CALIB_MODE, 0xc);
            hdmi_wr_reg(TX_CORE_CALIB_VALUE, 0x0);
            break;
        case 2:
            break;
        default:
            break;
    }
}
I have no idea why they stripped it down so much.

Edit* There's just so much wrong in that function. Jesus christ Amlogic.

FlapYoJacks fucked around with this message at 19:37 on Jan 7, 2015

yippee cahier
Mar 28, 2005

Tell me there's more to that patch and this was some incidental thing where they had to insert a case for the new enum value to pass code review.

edit: lol code review on that

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

sund posted:

Tell me there's more to that patch and this was some incidental thing where they had to insert a case for the new enum value to pass code review.

edit: lol code review on that

The local 'vic' is an int rather than an enum, so they won't get a compiler warning about unhandled values in the switch (the default case also prevents this, even if it vic were an instance of an enumerated type). This of course is a lesser issue than the function doing nothing in all cases.

ExcessBLarg!
Sep 1, 2001
Linux? How does the MAINTAINER even accept that poo poo?

Sure, that kind of code is common in SoC vendor trees because holy poo poo they can't write good code. But that's not supposed to make upstream at all.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

ratbert90 posted:

Edit* There's just so much wrong in that function. Jesus christ Amlogic.

Have one more:

C++ code:
void osd_set_osd_antiflicker_hw(u32 index, u32 vmode, u32 yres)
{
	bool osd_need_antiflicker = false;

	switch (vmode) {
		case VMODE_480I:
		case VMODE_480CVBS:
		case VMODE_576I:
		case VMODE_576CVBS:
		case VMODE_1080I:
		case VMODE_1080I_50HZ:
			osd_need_antiflicker = false;
		break;
		default:
		break;
	}

	if (osd_need_antiflicker){
		osd_hw.antiflicker_mode = 1;
		osd_antiflicker_task_start();
		osd_antiflicker_enable(1);
		osd_antiflicker_update_pan(osd_hw.pandata[index].y_start, yres);
	}else{
		if(osd_hw.antiflicker_mode){
			osd_antiflicker_task_stop();
		}
		osd_hw.antiflicker_mode = 0;
	}
}
I actually just rewrote their entire fbdev driver as a DRM driver.

FlapYoJacks
Feb 12, 2009

ExcessBLarg! posted:

Linux? How does the MAINTAINER even accept that poo poo?

Sure, that kind of code is common in SoC vendor trees because holy poo poo they can't write good code. But that's not supposed to make upstream at all.

It isn't upstream. No Kernel maintainer in their right mind would ever ever EVER accept that pile of poo poo.

Welcome to the wonderful world of SOC Kernel forks! :woop:


edit*

Suspicious Dish posted:

Have one more:

C++ code:
void osd_set_osd_antiflicker_hw(u32 index, u32 vmode, u32 yres)
{
	bool osd_need_antiflicker = false;

	switch (vmode) {
		case VMODE_480I:
		case VMODE_480CVBS:
		case VMODE_576I:
		case VMODE_576CVBS:
		case VMODE_1080I:
		case VMODE_1080I_50HZ:
			osd_need_antiflicker = false;
		break;
		default:
		break;
	}

	if (osd_need_antiflicker){
		osd_hw.antiflicker_mode = 1;
		osd_antiflicker_task_start();
		osd_antiflicker_enable(1);
		osd_antiflicker_update_pan(osd_hw.pandata[index].y_start, yres);
	}else{
		if(osd_hw.antiflicker_mode){
			osd_antiflicker_task_stop();
		}
		osd_hw.antiflicker_mode = 0;
	}
}
I actually just rewrote their entire fbdev driver as a DRM driver.


This is a thing of beauty! :allears: I wish I had the touch screen drivers on hand at the place I work at (not right now, no hours. :smith: [ If you need a embedded linux engineer I am willing to relocate. :v: ] ) They where a piece of work.
It had at least 4 functions to initialize the driver. Three of those functions just checked the variables passed to the function and called another init function with the same variables.

FlapYoJacks fucked around with this message at 20:02 on Jan 7, 2015

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Suspicious Dish posted:

We use a standard upstream ARM gcc. This is a patch to the Linux kernel, after all.

Oh :lol:

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Blotto Skorzany posted:

The local 'vic' is an int rather than an enum, so they won't get a compiler warning about unhandled values in the switch (the default case also prevents this, even if it vic were an instance of an enumerated type).

There's a more specific warning -Wswitch-enum which will complain about missing cases even in the presence of default, although of course the index still has to be an enum.

itskage
Aug 26, 2003


Anyone find anything good from the new year? (Besides Twitter!)

code:
void openPDF()
{
    FilePath    pdf;
    int         soYear;
    ;

    soYear = DateTimeUtil::year(salesTable.CreatedDateTime);

    pdf = strfmt(@'%1\%2\%3\%4', SalesParameters::find().PDFArchive, soYear, salesTable.SalesId, salesLine.pdfFileName());

    if (WinAPI::fileExists(pdf))
    {
        WinAPI::shellExecute(pdf);
    }
    else
    {
        pdf = strfmt(@'%1\%2\%3\%4', SalesParameters::find().PDFArchive, soYear + 1, salesTable.SalesId, salesLine.pdfFileName());
        
        if (WinAPI::fileExists(pdf))
        {
            WinAPI::shellExecute(pdf);
        }
        else
        {
            warning(@SYS5778);
        }
    }
}
This was the temp fix to resolve an issue where one system accesses a pdf from a folder that is provided by another system. The folders are based on the year of the sales orders and the ids of the orders. Of course the team that developed the other system used the system's current year when getting the year to write the path, and not something logical and static like the sales order's created date which was defined in the spec. So now I have some PDFs in 2014 orders sitting in 2015 folders. They are going and cleaning them up.

But this what I was given to resolve the issue temporarily so the system still works seamlessly for the users. It works... it just makes me cry.

itskage fucked around with this message at 21:50 on Jan 7, 2015

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

ratbert90 posted:

If you need a embedded linux engineer I am willing to relocate. :v:

We're in SF. If you're serious, send me a PM and I'll tell you more about the gig.

FlapYoJacks
Feb 12, 2009

Suspicious Dish posted:

We're in SF. If you're serious, send me a PM and I'll tell you more about the gig.

I sent you a PM. Thanks!

fritz
Jul 26, 2003

itskage posted:

Anyone find anything good from the new year? (Besides Twitter!)

code:
void openPDF()
{
    FilePath    pdf;
    int         soYear;
    ;

    soYear = DateTimeUtil::year(salesTable.CreatedDateTime);

    pdf = strfmt(@'%1\%2\%3\%4', SalesParameters::find().PDFArchive, soYear, salesTable.SalesId, salesLine.pdfFileName());

    if (WinAPI::fileExists(pdf))
    {
        WinAPI::shellExecute(pdf);
    }
    else
    {
        pdf = strfmt(@'%1\%2\%3\%4', SalesParameters::find().PDFArchive, soYear + 1, salesTable.SalesId, salesLine.pdfFileName());
        
        if (WinAPI::fileExists(pdf))
        {
            WinAPI::shellExecute(pdf);
        }
        else
        {
            warning(@SYS5778);
        }
    }
}
This was the temp fix to resolve an issue where one system accesses a pdf from a folder that is provided by another system. The folders are based on the year of the sales orders and the ids of the orders. Of course the team that developed the other system used the system's current year when getting the year to write the path, and not something logical and static like the sales order's created date which was defined in the spec. So now I have some PDFs in 2014 orders sitting in 2015 folders. They are going and cleaning them up.

But this what I was given to resolve the issue temporarily so the system still works seamlessly for the users. It [i]works[i]... it just makes me cry.


I like that lonely little semicolon there.

Adbot
ADBOT LOVES YOU

itskage
Aug 26, 2003


That's actually best practice. :smith:

quote:

Always place a semicolon ( ; ) on an empty line in front of the first statement in your code (after the variable declarations).

This is particularly important if the statement does not begin with a keyword (select, while, and so on). For example, the first part of the statement is a variable or a type reference.

You should use a semicolon even if the code compiles. Types introduced later (that have the same name as the first part of the statement) might prevent the code from compiling.

http://msdn.microsoft.com/en-us/library/aa636895%28v=ax.50%29.aspx

No longer best practice in AX 2012 though.

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