As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
Options

SELECT * FROM posts WHERE tid = 'PA PROGRAMMING THREAD'

1457910100

Posts

  • Options
    jackaljackal Fuck Yes. That is an orderly anal warehouse. Registered User regular
    GnomeTank wrote:
    What the hell do private functions have to do with being adults? Private functions are about hiding away pieces of encapsulation not meant for public consumption. Most private methods will have a lot less error checking and basic defensive programming, because they are generally called in ways the original programmer intended...he wrote them!

    It's a quote from Guido van Rossum (although I can't find a direct reference) explaining why Python doesn't have truly private functions. To be fair I think he's saying an unenforced convention for private functions is just as good private functions that are enforced by the compiler or interpreter. I guess the idea is that if you try hard enough you can find a way to call private functions so they may as well make it trivial to shoot yourself in the foot if you really insist (I still think it is a cop out though). For example in pretty much any .Net Framework language you can call a private function if you are willing to write a whole bunch of lines of reflection code.

  • Options
    GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    Sure, but you are knowingly making the leap from "I know which public methods I can call safely" to "I am knowingly going to call this private method that could be completely unsafe". That's completely different than "Here's this private method, and you really shouldn't call it, but hey, we won't stop you or even slow you down!"

    Also, there are ways to stop that from happening using the .NET security bit stuff. You can tell .NET that no one is allowed to call your private functions, even via reflection. Most people don't because it's not that important, but some security packages do this.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    Concrete method signatures and such are a major advantage of C# over Python

    I've written a reasonably sized Python app in the past and seriously after a certain point, keeping all of the state of the application in your brain every time you sit down to program is really hard


    Python is a super great scripting tool, but I don't see myself ever writing serious production software with it ever again

  • Options
    IncindiumIncindium Registered User regular
    edited February 2012
    GnomeTank wrote:
    Also, there are ways to stop that from happening using the .NET security bit stuff. You can tell .NET that no one is allowed to call your private functions, even via reflection. Most people don't because it's not that important, but some security packages do this.
    You are talking about using Strong Naming in .NET right to protect your assemblies? Yeah well that can be bypassed as well. Basically if they have access to your assemblies and someone wants to they can call your members whether they be private or not via reflection.

    Incindium on
    steam_sig.png
    Nintendo ID: Incindium
    PSN: IncindiumX
  • Options
    GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    Incindium wrote:
    GnomeTank wrote:
    Also, there are ways to stop that from happening using the .NET security bit stuff. You can tell .NET that no one is allowed to call your private functions, even via reflection. Most people don't because it's not that important, but some security packages do this.
    You are talking about using Strong Naming in .NET right to protect your methods? Yeah well that can be bypassed as well. Basically if they have access to your assemblies and someone wants to they can call your members whether they be private or not via reflection.

    No, there is actually a security attribute you can set on your assembly that says "Private members can't be reflected". I'll look it up, but I am pretty sure even code with full trust can't reflect the private methods of an assembly with that attribute.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Options
    jackaljackal Fuck Yes. That is an orderly anal warehouse. Registered User regular
    Then I will rewrite the IL like a boss.

  • Options
    GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    Yes, you could do that, unless of course they have NGen'ed their assemblies, which anyone who is using that security attribute is very likely to do.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Options
    jackaljackal Fuck Yes. That is an orderly anal warehouse. Registered User regular
    Then I shall decompil... errr... good point.

  • Options
    Joe KJoe K Registered User regular
    GnomeTank wrote:
    What the hell do private functions have to do with being adults? Private functions are about hiding away pieces of encapsulation not meant for public consumption. Most private methods will have a lot less error checking and basic defensive programming, because they are generally called in ways the original programmer intended...he wrote them!

    The OP was slightly off-target.

    It's a complaint that every effing OO language wants you to have a
    private var foo
    that has a setter and getter
    E.G. setFoo() and getFoo()
    where
    setFoo(arg) {
    foo = arg; // or whatever, but usually its a straight up assignment
    }

    Since this sort of code spammage is kindof pointless, all python members and methods are public by default. If you need to write a setter in a special way, you have the opportunity to do so, but by default, you can just write to the classes variable, because that's mostly what you're going to be doing with setFoo() anyway.

    The expression is "we're all adults, and don't go around touching each others private parts". If you need to do special massaging of data collected, go ahead, but it isn't the default expected implementation method.

  • Options
    IncindiumIncindium Registered User regular
    edited February 2012
    GnomeTank wrote:
    Yes, you could do that, unless of course they have NGen'ed their assemblies, which anyone who is using that security attribute is very likely to do.

    NGen doesn't get rid of the actual CLR assemblies does it though?

    Incindium on
    steam_sig.png
    Nintendo ID: Incindium
    PSN: IncindiumX
  • Options
    Alistair HuttonAlistair Hutton Dr EdinburghRegistered User regular
    I like the Camel book's description of the Perl philosophy (which is similar to Python's) when it comes to lack of privates

    "a Perl module would prefer that you stayed out of its living room because you weren't invited, not because it has a shotgun."

    I have a thoughtful and infrequently updated blog about games http://whatithinkaboutwhenithinkaboutgames.wordpress.com/

    I made a game, it has penguins in it. It's pay what you like on Gumroad.

    Currently Ebaying Nothing at all but I might do in the future.
  • Options
    GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    Incindium wrote:
    GnomeTank wrote:
    Yes, you could do that, unless of course they have NGen'ed their assemblies, which anyone who is using that security attribute is very likely to do.

    NGen doesn't get rid of the actual CLR assemblies does it though?

    If you never let the original CLR assemblies touch the system, it does. This is an option with many installer systems.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Options
    CantidoCantido Registered User regular
    Oh my god, I just saw a senior design project that made a webapp with jQuery Mobile and it was the sexiest thing ever. I am a shit artist, I must learn this for my app.

    3DS Friendcode 5413-1311-3767
  • Options
    admanbadmanb unionize your workplace Seattle, WARegistered User regular
    jQuery mobile looks good and works surprisingly well.

  • Options
    templewulftemplewulf The Team Chump USARegistered User regular
    Does anyone have any recommended reading for the soup-to-nuts of setting up an ASP.NET WCF service? I'm getting back to writing a Lync service, and svcutil just will not connect to the service.

    I'm working through this series, but I feel like there's some extra setup in the web.config or in IIS that I'm missing.

    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • Options
    Jimmy KingJimmy King Registered User regular
    jQuery mobile is great. We've been using it for a lot of projects here at work over the last couple of months.

    Also, along the lines of templewulf's question, do any of you have experience with accessing wcf services? I just talked to a potential business partner yesterday who appears to be under the assumption that we're a .net shop (we're not, but I'm fairly sure they've been lead to believe we are by people who are not me and need punched in the dick) and so seemed to be making some assumption about our ability to integrate with them. How are wcf services normally accessed in the ideal MS way?

  • Options
    Hi I'm Vee!Hi I'm Vee! Formerly VH; She/Her; Is an E X P E R I E N C E Registered User regular
    Hello programming thread, I am very new to programming, and somehow I have ended up in a math course that uses a fair amount of it. Simple stuff, usually, but I have pretty big holes in my basic knowledge. I could really use some help to finish this homework assignment (don't worry, I'm not asking you to do my homework for me).

    I'm coding in C# on Microsoft Visual Studio.

    I need to know how to force the program to display numbers with a specific precision (i.e. scientific notation with 15 significant digits)

    So like, instead of 0.0000000000046, I want it to display 4.60000000000000e-12

    More specifically, I have this:
    Console.Write("k = " + i + ", x = " + x + ", val = " + w + "\n");
    

    This code gets repeated a bunch of times, with different values for k, x, and w each time.

    x and w are numbers with a ton of significant digits, but x starts off being just 1. I need it to show up as 1.000000000000000e+00

    This seems like something I should be able to find in a reference online somewhere, but I'm having stunningly poor luck so far. Thanks in advance for any help you can give me!


    vRyue2p.png
  • Options
    GrobianGrobian What's on sale? Pliers!Registered User regular
    @visiblehowl this is the relevant reference: http://msdn.microsoft.com/en-us/library/8a7aswa4.aspx and probably also http://msdn.microsoft.com/en-us/library/0c899ak8.aspx because the default scientific notation does only 6 digits.

  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    Converting one of our TableModels to a TreeTableModel... I know this is going to break everything.

  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    Yeah I'm going to have to spend an iteration getting this to work. I don't have time to spend on it.

  • Options
    Joe KJoe K Registered User regular
    urahonky wrote: »
    Yeah I'm going to have to spend an iteration getting this to work. I don't have time to spend on it.

    I always love this discussion. I always try to answer it with "If I don't have time to do it right NOW, when will I?".

  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    Joe K wrote: »
    urahonky wrote: »
    Yeah I'm going to have to spend an iteration getting this to work. I don't have time to spend on it.

    I always love this discussion. I always try to answer it with "If I don't have time to do it right NOW, when will I?".

    Yeah I'm in the middle of research and analysis for my current plug-in. And our program doesn't really support multiple objects on the table with the same ID, so I thought I'd just switch it to a JXTreeTable since it would look better, but at this point I don't want to spend my 15 hours of research just trying to implement it.

  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    Is it possible to only have a Menu Bar only extend roughly half the screen and not push everything down?

  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    In case anyone was wondering: It is, in fact, possible in Java. In the other languages I'm not sure, but I'm going to just stick with Java for now.

    (You create a JPanel using BorderLayout, set the MenuBar to WEST and the other objects to the EAST)

  • Options
    zeenyzeeny Registered User regular
    Absolutely everything is possible in UI with panels.

  • Options
    DrunkMcDrunkMc Registered User regular
    Hello programming thread, I am very new to programming, and somehow I have ended up in a math course that uses a fair amount of it. Simple stuff, usually, but I have pretty big holes in my basic knowledge. I could really use some help to finish this homework assignment (don't worry, I'm not asking you to do my homework for me).

    I'm coding in C# on Microsoft Visual Studio.

    I need to know how to force the program to display numbers with a specific precision (i.e. scientific notation with 15 significant digits)

    So like, instead of 0.0000000000046, I want it to display 4.60000000000000e-12

    More specifically, I have this:
    Console.Write("k = " + i + ", x = " + x + ", val = " + w + "\n");
    

    This code gets repeated a bunch of times, with different values for k, x, and w each time.

    x and w are numbers with a ton of significant digits, but x starts off being just 1. I need it to show up as 1.000000000000000e+00

    This seems like something I should be able to find in a reference online somewhere, but I'm having stunningly poor luck so far. Thanks in advance for any help you can give me!


    I'm a JAVA guy, but this seems to have what you're looking for.

    http://msdn.microsoft.com/en-us/library/586y06yf.aspx

  • Options
    CantidoCantido Registered User regular
    Oh my god, learning jQuery Mobile is so awesome, I think I'm gonna cry.

    3DS Friendcode 5413-1311-3767
  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    Welp. Looks like our team is being moved into a new room in which the supervisor's desk will be facing towards our desks so he has full view of our computer monitors. That means I'll be spending a lot less time here. :(

  • Options
    bowenbowen How you doin'? Registered User regular
    Apparently urahonky's supervisor is a PAer.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    zeenyzeeny Registered User regular
    edited February 2012
    Cantido wrote: »
    Oh my god, learning jQuery Mobile is so awesome, I think I'm gonna cry.

    I believe it was Crockford who said that JS is a language that programmers prefer "to use" instead of "to learn". I'm mentioning this simply because I haven't gotten the impression that you are comfortable with the language(from your posts so far), yet you are learning JQuery.
    Somehow, JS is the only language that's acceptable in. Nobody will advise you to start with zend, instead of php or plunge into web2py before having an understand of python, but hey, it's Js, it's all good!

    Edit: After they are done "using", they go straight to bitching about how bad it is too.

    zeeny on
  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    bowen wrote: »
    Apparently urahonky's supervisor is a PAer.

    Haha that would be hilarious if true.

  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    There's a company around here in Dayton known for it's terrible treatment of developers. (I actually interviewed there a few times) Anyway the new guy starting today went in yesterday to turn in his two week notice... And they just escorted him out that moment.

  • Options
    bowenbowen How you doin'? Registered User regular
    Hope he sues them for severance pay if they don't give it to him.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    bowen wrote: »
    Hope he sues them for severance pay if they don't give it to him.

    I do too. What a bunch of clowns.

  • Options
    bowenbowen How you doin'? Registered User regular
    How come some people get -> for their quotes. Did I miss another option?

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    I think they finally added that post-update so we can actually go to the post that's being quoted now.

  • Options
    jaziekjaziek Bad at everything And mad about it.Registered User regular
    how good are some people here at C? I see no reason why the following code shouldn't work, but it doesn't.
    
    typedef struct line { 
    			unsigned char* characters; 
    		     } LINE;
    
    //line array containing characters for a given line.
    LINE lines[7];
    	LINE line1;
    	LINE line2;
    	LINE line3;
    	LINE line4;
    	LINE line5;
    	LINE line6;
    	LINE line7;
    	LINE line8;
    
    //sets up the inital home screen and menu options.
    
    void menu_setup(){
    
    	
    	lines[0] = line1;
    	lines[1] = line2;
    	lines[2] = line3;
    	lines[3] = line4;
    	lines[4] = line5;
    	lines[5] = line6;
    	lines[6] = line7;
    	lines[7] = line8;
    	line1.characters = "   welcome      ";
    	line2.characters = " press any key  ";
    
    	index = 0;
    	recorded = 0;
    	hrzpos = 0;
    	vpos = 0;
    	  
    	int i;
    	for(i = 0; i < 16; i++){
    		print_lcd_char(line1.characters[i]);
    	}
    	lcd_xy(0,1);
    	for(i = 0; i < 16; i++){
    		print_lcd_char(line2.characters[i]);
    	}
    
    	keypad_read();
    	delay(200);
    	line1.characters = "messaging       ";
    	line2.characters = "settings        ";
    	line3.characters = "contacts        ";
    	line4.characters = "dialler         ";
    	line5.characters = "help            ";
    
    
    void main_menu(){
    
    	int i;
    	for(i = 0; i < 16; i++){
    		print_lcd_char(lines[currentLine].characters[i]);
    	}
    	lcd_xy(0,1);
    	for(i = 0; i < 16; i++){
    		print_lcd_char(lines[currentLine+1].characters[i]);
    	}
    	
    
    	while(1){
    		key_functions(keypad_read());
    	}
    
    
    


    the idea here is that the strings line1 and line2 get printed to the LCD screen, but instead I just get a garbled mess of random characters.
    In the menu_setup function, the printing of the initial 2 lines, "welcome, press any key" goes off without a hitch, but when you try and get at the strings through the line array, in the main_menu function, it doesn't work.

    So basically, this comes down to me not knowing how arrays work in C, I think. But I have no idea what I'm doing wrong.

    Steam ||| SC2 - Jaziek.377 on EU & NA. ||| Twitch Stream
  • Options
    bowenbowen How you doin'? Registered User regular
    urahonky wrote: »
    I think they finally added that post-update so we can actually go to the post that's being quoted now.

    There it goes. Weird.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    zeenyzeeny Registered User regular
    edited February 2012
    jaziek wrote: »
    how good are some people here at C? I see no reason why the following code shouldn't work, but it doesn't.
    
    typedef struct line { 
    			unsigned char* characters; 
    		     } LINE;
    
    //line array containing characters for a given line.
    LINE lines[7];
    	LINE line1;
    	LINE line2;
    	LINE line3;
    	LINE line4;
    	LINE line5;
    	LINE line6;
    	LINE line7;
    	LINE line8;
    
    //sets up the inital home screen and menu options.
    
    void menu_setup(){
    
    	
    	lines[0] = line1;
    	lines[1] = line2;
    	lines[2] = line3;
    	lines[3] = line4;
    	lines[4] = line5;
    	lines[5] = line6;
    	lines[6] = line7;
    	lines[7] = line8;
    	line1.characters = "   welcome      ";
    	line2.characters = " press any key  ";
    
    	index = 0;
    	recorded = 0;
    	hrzpos = 0;
    	vpos = 0;
    	  
    	int i;
    	for(i = 0; i < 16; i++){
    		print_lcd_char(line1.characters[i]);
    	}
    	lcd_xy(0,1);
    	for(i = 0; i < 16; i++){
    		print_lcd_char(line2.characters[i]);
    	}
    
    	keypad_read();
    	delay(200);
    	line1.characters = "messaging       ";
    	line2.characters = "settings        ";
    	line3.characters = "contacts        ";
    	line4.characters = "dialler         ";
    	line5.characters = "help            ";
    
    
    void main_menu(){
    
    	int i;
    	for(i = 0; i < 16; i++){
    		print_lcd_char(lines[currentLine].characters[i]);
    	}
    	lcd_xy(0,1);
    	for(i = 0; i < 16; i++){
    		print_lcd_char(lines[currentLine+1].characters[i]);
    	}
    	
    
    	while(1){
    		key_functions(keypad_read());
    	}
    
    
    


    the idea here is that the strings line1 and line2 get printed to the LCD screen, but instead I just get a garbled mess of random characters.
    In the menu_setup function, the printing of the initial 2 lines, "welcome, press any key" goes off without a hitch, but when you try and get at the strings through the line array, in the main_menu function, it doesn't work.

    So basically, this comes down to me not knowing how arrays work in C, I think. But I have no idea what I'm doing wrong.

    There are a lot of things wrong with the structure of that code, but a glance says your "lines" array's indexes are not pointing where you think they are. Test it.

    Edit: Uuuh wait, I read it in full. currentLine is undefined. There are honestly too many things wrong with this code;o/

    zeeny on
  • Options
    jaziekjaziek Bad at everything And mad about it.Registered User regular
    edited February 2012

    There are a lot of things wrong with the structure of that code, but a glance says your "lines" array's indexes are not pointing where you think they are. Test it.

    such as? I am still very much a beginner to coding in general, so much so that even this, which is essentially just defining strings, is problematic.


    I just don't see where the problem is...

    define the line type.
    create an array of lines.
    create individual lines
    store them in the array.
    access a given index of the array to retrieve the characters on a line.

    where am I not doing what I think I'm doing?

    jaziek on
    Steam ||| SC2 - Jaziek.377 on EU & NA. ||| Twitch Stream
This discussion has been closed.