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

using(PennyArcade.Forum){Threads.push(ProgrammingThread())}

2456763

Posts

  • Options
    templewulftemplewulf The Team Chump USARegistered User regular
    edited December 2009
    Infidel wrote: »
    You could simply have class variables in a dbconfig.php file that are assigned directly, and then in your DB open code just reference those followed by blanking them.

    When you say "class variables", do you mean static members? 'Cause you can't reference non-static properties from another php file, right?

    Is it weird that I understand the C++ compilation model but am having trouble with PHP? :lol:

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • Options
    StarfuckStarfuck Registered User, ClubPA regular
    edited December 2009
    Noob question, in regards to AS3, but could apply to anything else I suppose.
    Something I'm trying to "understand" is why use get/set?
    Why
    private var _address : String;

    public function get Address() : String {
    return _address;
    }

    public function set Address( value : String ) : void {
    _address = value;
    }

    as opposed to
    public var Address: String;

    Is it just because I could check for nulls or some other operation in the set function?
    Also, would I place my [Bindable] tag on the get or the set?

    Starfuck on
    jackfaces
    "If you're going to play tiddly winks, play it with man hole covers."
    - John McCallum
  • Options
    SenjutsuSenjutsu thot enthusiast Registered User regular
    edited December 2009
    there's nothing weird about having trouble with PHP. It makes C++ look clean and orthogonal

    Senjutsu on
  • Options
    templewulftemplewulf The Team Chump USARegistered User regular
    edited December 2009
    Senjutsu wrote: »
    there's nothing weird about having trouble with PHP. It makes C++ look clean and orthogonal

    Django looks pretty neat, but PHP is popular enough that I ought to know a little about it. Plus, Wordpress!

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • Options
    zilozilo Registered User regular
    edited December 2009
    Starfuck wrote: »
    Noob question, in regards to AS3, but could apply to anything else I suppose.
    Something I'm trying to "understand" is why use get/set?
    Why
    private var _address : String;

    public function get Address() : String {
    return _address;
    }

    public function set Address( value : String ) : void {
    _address = value;
    }

    as opposed to
    public var Address: String;

    Is it just because I could check for nulls or some other operation in the set function?
    Also, would I place my [Bindable] tag on the get or the set?

    Because what if you start storing addresses in a database someday and have to do a query instead of return a class variable? Then you have to rewrite an unknowably large amount of client code. You should always separate interface from implementation where possible.

    And you would bind on setAddress(), since that's where the value actually changes.

    zilo on
  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited December 2009
    Starfuck wrote: »
    Noob question, in regards to AS3, but could apply to anything else I suppose.
    Something I'm trying to "understand" is why use get/set?
    Why
    private var _address : String;

    public function get Address() : String {
    return _address;
    }

    public function set Address( value : String ) : void {
    _address = value;
    }

    as opposed to
    public var Address: String;

    Is it just because I could check for nulls or some other operation in the set function?
    Also, would I place my [Bindable] tag on the get or the set?

    Well as for get and set itself, honestly in 99% of cases with Flash you don't actually need it, but think of it from the perspective of writing a method for "when this variable is set, I need to do X, Y, or Z", which can be anything.. for example, writing that value to a file, etc, for persistent storage.

    I'm pretty sure you do NOT put the bindable tag on the method because [bindable] is used by GUI controls and you can't control how often it's going to call your [GET] function.

    For example, there's an internal method in the iPhone SDK that calls the same getter 16 goddamn times per user touch. One per frame in the animation.

    You should be binding your member level variables to controls.. in my opinion. You should really consult the Adobe Flex SDK style guide on that matter.

    Jasconius on
  • Options
    zilozilo Registered User regular
    edited December 2009
    Jasconius wrote: »
    For example, there's an internal method in the iPhone SDK that calls the same getter 16 goddamn times per user touch. One per frame in the animation.

    Wow. That's... wow.

    zilo on
  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited December 2009
    That's what I said.

    It's incredible, really. I could hardly believe the debug console.

    Jasconius on
  • Options
    InfidelInfidel Heretic Registered User regular
    edited December 2009
    templewulf wrote: »
    Infidel wrote: »
    You could simply have class variables in a dbconfig.php file that are assigned directly, and then in your DB open code just reference those followed by blanking them.

    When you say "class variables", do you mean static members? 'Cause you can't reference non-static properties from another php file, right?

    Is it weird that I understand the C++ compilation model but am having trouble with PHP? :lol:

    Yes, static members.

    Could do something along these lines:
    class DBConfig
    {
        public static $hostname = 'localhost';
        public static $dbname = 'test';
        ...
        public static function clear()
        {
            self::$hostname = null;
            ...
        }
    }
    
    require_once('../DBConfig.php');
    $db = opendb(DBConfig::$hostname, DBConfig::$dbname, ...);
    DBConfig::clear();
    

    Infidel on
    OrokosPA.png
  • Options
    templewulftemplewulf The Team Chump USARegistered User regular
    edited December 2009
    Infidel wrote: »
    Yes, static members.

    Could do something along these lines:
    class DBConfig
    {
        public static $hostname = 'localhost';
        public static $dbname = 'test';
        ...
        public static function clear()
        {
            self::$hostname = null;
            ...
        }
    }
    
    require_once('../DBConfig.php');
    $db = opendb(DBConfig::$hostname, DBConfig::$dbname, ...);
    DBConfig::clear();
    

    Great! That's pretty much what I was looking to do. I just wanted to make sure you weren't somehow passing a database instance to the dbconfig file through some dark and terrible ritual.

    PHP seems pretty simple; I'm probably just overthinking it.

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • Options
    StarWarsHaterStarWarsHater Registered User new member
    edited December 2009
    Long time lurker, first time poster. Here's what I work on:

    Language: C++
    Framework: Hahahaha.
    Purpose: Reviving a dead horse.

    I agree with Daedalus that C++ is a giant pile of shit. My current (new) job is giving CPR to some very old applications (code comments place it at least 1994-ish). It is a conglomeration of Borland C++ (some before the real "standardization" of C++), OWL, some VCL, a little STL and some terrible maintainers that thought baseball bats were precision tools. It's kinda like code archeology. Libraries are for suckers was one of the core ideals (that or this was when none existed really), so everything is done by hand. Basically, it is a circle of programming hell. If for some reason you want to know about any of those technologies, I could answer them after I get out of the lava bath. I am a warning to CS students/software developers to be careful what you put on your resume.

    Language: C#
    Framework: .NET
    Purpose: Keeping me sane.

    On the side I work some on C#/.NET stuff to keep me anchored in 2009. Since leaving my previous job (Java/C#) I work on a personal project on the side that will manage media (music/TV/stuff). It is mainly a springboard to learn some other stuff such as NHibernate and WPF. There is also a explorer-like file/folder application that does some statistics on directory trees (aggregate size and whatnot) in addition to copying/syncing. At my previous job I did a bunch of large-scale data processing with WinForms, Windows services, remoting, and some ASP.NET. I'm much more willing to answer questions about anything under the .NET umbrella. I really like .NET in general (my first languages were C and Java) and a lot of it just "makes sense."

    Language: Java
    Framework: Nothing specific.

    Way back when I used Java to do some desktop applications, but my skill in it is pretty rusty.

    StarWarsHater on
  • Options
    Alistair HuttonAlistair Hutton Dr EdinburghRegistered User regular
    edited December 2009
    Flex Framework Goodness

    I'm really enjoying using Mate at the moment. it has it's quirks but it makes complicated thing easy and easy things just as easy. Not that enamoured by SmartObjects and what they end up doing to your system though.

    Alistair Hutton on
    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
    StarfuckStarfuck Registered User, ClubPA regular
    edited December 2009
    Mate is on my list of Frameworks to try, but the abundance of mxml is kind of keeping me from diving in. At the moment, I'm using Robotlegs for my current project and I have gotten pretty familiar with Swiz.

    Robotlegs has the benefit of being pure AS3, with no Flex dependencies. IoC works beautifully and in a way really taught me to appreciate component development to take advantage of custom event dispatching.

    Swiz is incredibly simple (or as they say in the google group "Brutally Simple") and I think more flexible in it's use. Once you've built a config file and a bean, you can just use Autowire and Mediate as you please. There's no further need to instantiate Swiz anywhere in your app, unlike with Robotlegs that requires( as far as I can tell ) that you extend their Abstract classes to take advantage of certain tools.

    I have a larger project (built with Cairngorm) where I will be evaluating Robotlegs and Swiz to see which I think would be a better fit. The new Swiz release supports modules now, but is still alpha, so I am waiting to see how that pans out.

    Starfuck on
    jackfaces
    "If you're going to play tiddly winks, play it with man hole covers."
    - John McCallum
  • Options
    InfidelInfidel Heretic Registered User regular
    edited December 2009
    templewulf wrote: »
    Great! That's pretty much what I was looking to do. I just wanted to make sure you weren't somehow passing a database instance to the dbconfig file through some dark and terrible ritual.

    PHP seems pretty simple; I'm probably just overthinking it.

    Maybe, all you need to accomplish is getting the database settings without others being able to, like the example it's a simple thing but a very important one. :lol:

    PHP is known for being "simple" and therefore there's a lot of people writing code for it that have no idea what they're doing necessarily. It's not a horrible language for what it does, it does a fine job and good code will happen if it's written by good coders. It gets a bad rap but that doesn't really matter when it's so pervasive and I know I can use it on pretty much any host without rewriting my shit.

    Infidel on
    OrokosPA.png
  • Options
    zeenyzeeny Registered User regular
    edited December 2009
    templewulf wrote: »
    Senjutsu wrote: »
    there's nothing weird about having trouble with PHP. It makes C++ look clean and orthogonal

    Django looks pretty neat, but PHP is popular enough that I ought to know a little about it. Plus, Wordpress!

    I was writing wordpress modules for a time in 2002 or 2003, Wordpress* was the ugliest codebase I've seen. It's entirely possible that it has improved, but at the time it was an illustration of how not to do PHP.

    *Those were the php4 days.

    zeeny on
  • Options
    InfidelInfidel Heretic Registered User regular
    edited December 2009
    WordPress is pretty slick on the front-end. Pretty nasty on the back-end.

    It makes customers happy though. :^:

    Infidel on
    OrokosPA.png
  • Options
    FodderFodder Registered User regular
    edited December 2009
    It's always fun tracking down bugs to functions you'd tested thoroughly and assumed to be working. It turns out I hadn't tested my garbage collection with arrays that were 0 indexed and it was resetting them to there whenever I ran the collector over it. Hello a solid day and a half of bug fixing at higher levels in the code!

    Fodder on
    steam_sig.png
  • Options
    xzzyxzzy Registered User regular
    edited December 2009
    Fodder wrote: »
    It's always fun tracking down bugs to functions you'd tested thoroughly and assumed to be working. It turns out I hadn't tested my garbage collection with arrays that were 0 indexed and it was resetting them to there whenever I ran the collector over it. Hello a solid day and a half of bug fixing at higher levels in the code!

    I fixed a bug last week on our website that tallied up the number of machines that were offline in a given cluster. The website had been up for over a year, and everyone around here used it daily to measure system health. Turns out the variable never got reset, so the counter was actually a tally of all downed machines, instead of just for the single cluster.

    Management types use the webpage to estimate node retirements and new purchases, so it's possible there's a real dollar amount you could assign to the bug. Using a language that required initializing variables would have prevented this.. but php doesn't do that.

    Is why my scripting language of choice these days is python. My error count has gone way down. :)

    xzzy on
  • Options
    Shazkar ShadowstormShazkar Shadowstorm Registered User regular
    edited December 2009
    i learned some python in the last 2 weeks

    its cool

    i used numpy for a bit to do some things since my matlab borked and some scipy but it was being dumb
    and then i wrote some scripts to do some things

    that about it

    Shazkar Shadowstorm on
    poo
  • Options
    Shazkar ShadowstormShazkar Shadowstorm Registered User regular
    edited December 2009
    does anyone use amazon web services like ec2

    i essentially got a big AWS gift certificate via a class

    what should i do with that

    Shazkar Shadowstorm on
    poo
  • Options
    SenjutsuSenjutsu thot enthusiast Registered User regular
    edited December 2009
    shaz you should give it to me

    Senjutsu on
  • Options
    StarfuckStarfuck Registered User, ClubPA regular
    edited December 2009
    So, I'm working on stuff from home, and rather than keep trying to sync my usb drive with my work pc, I finally decided to try some source control. I don't work in a large team (mostly solo, but I'm hoping to remedy that with some solid pair programming time), so source control was never much of an issue, but I figured I should at least try it. I found ProjectLocker that offers free 500mb with password and it seems to be working pretty good. FlexBuilder is based on Eclipse, so I can use the subversion plug-in.

    I also spent a couple of hours getting ANT to work to build my docs, which is probably overkill for this project, but the geek rush was pretty cool.

    Starfuck on
    jackfaces
    "If you're going to play tiddly winks, play it with man hole covers."
    - John McCallum
  • Options
    xzzyxzzy Registered User regular
    edited December 2009
    Subversion is my weapon of choice. But my machine at work is always on, meaning I have access to it anywhere with a net connection. It's kept safe behind ssh with kerberos authentication.

    It is quite nice to be able to revert to a previous version, instead of having your project directory cluttered with "test" and "old" files all over the place.

    xzzy on
  • Options
    SenjutsuSenjutsu thot enthusiast Registered User regular
    edited December 2009
    How not to have me punch you in the dick in one easy step:

    1) Don't write this:
        public class ListHelper<T>
        {
            public static bool HasItems<T>(List<T> list)
            {
                bool hasItems = false;
    
                if (list != null && list.Count > 0)
                {
                    hasItems = true;
                }
    
                return hasItems;
            }
        }
    

    Senjutsu on
  • Options
    SenjutsuSenjutsu thot enthusiast Registered User regular
    edited December 2009
    Oh also it was completely dead code. So I don't really know what is worse, that somebody wrote that, or having written it, never used it, and left it in trunk anyways.

    Senjutsu on
  • Options
    PracticalProblemSolverPracticalProblemSolver Registered User regular
    edited December 2009
    shaz, only thing I can think of using aws for unless you actually need the services in a professional capacity is using s3 to backup or share your files, I have an rsync type utility that backups up all my datas and I share a bunch of my friends music files for their bands. Otherwise you could use ec2 for proxy stuff or if you need the processing power to do a task, it's fairly complicated to setup though.

    So to go along with all the python love itt, I've been a rails developer for a few years now, recently I started programming using a python game framework, thinking about switching over to django or equivalent, anyone made that kind of switch?

    PracticalProblemSolver on
  • Options
    FodderFodder Registered User regular
    edited December 2009
    I'm not sure if this is getting too off-topic, but on that note, has anyone used s3 for backup? The prices seem pretty good and I'm thinking about backing up all my music and then documents from multiple computers onto it. I haven't looked into any tools for automating it yet, but doing that on windows and linux boxes would be a plus, and I'd like to be able to keep things relatively organized.

    Fodder on
    steam_sig.png
  • Options
    SeolSeol Registered User regular
    edited December 2009
    Senjutsu wrote: »
    Oh also it was completely dead code. So I don't really know what is worse, that somebody wrote that, or having written it, never used it, and left it in trunk anyways.
    i can see, possibly, someone thinking "i'm doing TWO things here on many occasions, which could be ONE thing!!11!" and writing that code in a misguided attempt to improve "code re-use". it would be wrong, but from a certain perspective, it would be understandable.

    but when it's not a "solution" to a specific "problem", i mean... what possesses someone to write that?

    Seol on
  • Options
    templewulftemplewulf The Team Chump USARegistered User regular
    edited December 2009
    Senjutsu wrote: »
    How not to have me punch you in the dick in one easy step:

    1) Don't write this:
        public class ListHelper<T>
        {
            public static bool HasItems<T>(List<T> list)
            {
                bool hasItems = false;
    
                if (list != null && list.Count > 0)
                {
                    hasItems = true;
                }
    
                return hasItems;
            }
        }
    
    You know, reading that code is itself like being punched in the genitals. You know how the initial shock doesn't necessarily hurt, but once you start breathing again you feel an incredible ache creep up on you?

    Yeah, once I realized there was a "ListHelper" class, I doubled over in pain. True story.

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • Options
    MKRMKR Registered User regular
    edited December 2009
    I'm pretty much clueless when it comes to web design, so I come to you, the programming thread: http://mkronline.com/newsitepants/index.php

    Why is the text in the box in the content area hanging out on the right?

    MKR on
  • Options
    InfidelInfidel Heretic Registered User regular
    edited December 2009
    MKR wrote: »
    I'm pretty much clueless when it comes to web design, so I come to you, the programming thread: http://mkronline.com/newsitepants/index.php

    Why is the text in the box in the content area hanging out on the right?

    It's not? You might want to set some padding on #content though.

    Infidel on
    OrokosPA.png
  • Options
    MKRMKR Registered User regular
    edited December 2009
    Infidel wrote: »
    MKR wrote: »
    I'm pretty much clueless when it comes to web design, so I come to you, the programming thread: http://mkronline.com/newsitepants/index.php

    Why is the text in the box in the content area hanging out on the right?

    It's not? You might want to set some padding on #content though.

    It's hanging out in FF 3.5.5. It doesn't seem to do it in most other browsers, but 99% of the people coming to my site use FF.

    And #content does have padding, but for some reason I only put it on the left.

    MKR on
  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited December 2009
    My "what the fuck is this shit" of the day is as followes.

    Extending/modding this rather large iPhone application engine that was written for our eCommerce engine. It's basically the whole damn storefront on the phone.

    It's designed to more or less load in the entire product repository to the phone and let the customer browse the catalog.

    The problem is, our implementation is designed to handle clothing, and the base configuration of the engine is NOT. If you aren't familiar with how clothing in eCommerce works, every single combination of size, color, and any other attribute such as inseam or in our case, the band and cup size (for bras), is a unique row in the database at the SKU level.

    Multiply this by every product we've ever had (we have new lines basically 4 times per year), and that puts the grand total at 800k rows returned for SKU's. The default implementation of the engine also doesn't distinguish "in stock", so it returns a product even if it hasn't been around for a decade.

    So anyway, there was an option in the code to "partially" load parts of the inventory, specifically, just what is requested by the user. So I activated that and it still wasn't working. Checking the debug logs it was actually cancelling my partial request and requesting the full catalog (!!!). There was no explanation in any of the pertinent source code as to why it was canceling my partial request.

    So after about 30 minutes of stepping through a ridiculous amount of code in the debugger, I realize that the getter method for the product array contains a function call to:

    1) Dequeue all pending data requests
    2) Request the entire fucking catalog

    So, the line that was calling all of this bullshit was, roughly:
    if([Category products] count] > 0)
    

    located in a delegate method on a view controller.

    I refuse to believe that was by design.

    REFUSE.

    Jasconius on
  • Options
    InfidelInfidel Heretic Registered User regular
    edited December 2009
    It would look better if you put the same padding on the right, does that also happen to fix your issue?

    Infidel on
    OrokosPA.png
  • Options
    MKRMKR Registered User regular
    edited December 2009
    Infidel wrote: »
    It would look better if you put the same padding on the right, does that also happen to fix your issue?

    I put 5px of padding all around #content and 5px on the right and left of the others. The problem is still there. :(

    MKR on
  • Options
    InfidelInfidel Heretic Registered User regular
    edited December 2009
    MKR wrote: »
    Infidel wrote: »
    It would look better if you put the same padding on the right, does that also happen to fix your issue?

    I put 5px of padding all around #content and 5px on the right and left of the others. The problem is still there. :(

    Screenshot?

    Infidel on
    OrokosPA.png
  • Options
    MKRMKR Registered User regular
    edited December 2009
    Infidel wrote: »
    MKR wrote: »
    Infidel wrote: »
    It would look better if you put the same padding on the right, does that also happen to fix your issue?

    I put 5px of padding all around #content and 5px on the right and left of the others. The problem is still there. :(

    Screenshot?

    125l4eq.png

    MKR on
  • Options
    InfidelInfidel Heretic Registered User regular
    edited December 2009
    Oh, that box. I thought you meant the box for the entire content.

    100% width = width of parent, padding-left 10 px means you'll get that plus 10, so it breaks the parent.

    Set margins or don't set width 100%, it doesn't work that way in CSS.

    Infidel on
    OrokosPA.png
  • Options
    InfidelInfidel Heretic Registered User regular
    edited December 2009
    Actually you probably just want to set padding: 0 10px and then get rid of the width part altogether, for the #infobox-content

    Infidel on
    OrokosPA.png
  • Options
    MKRMKR Registered User regular
    edited December 2009
    Well now I feel silly. It looks right now. Thanks for the help. :rotate:

    MKR on
Sign In or Register to comment.