Our new Indie Games subforum is now open for business in G&T. Go and check it out, you might land a code for a free game. If you're developing an indie game and want to post about it, follow these directions. If you don't, he'll break your legs! Hahaha! Seriously though.
Our rules have been updated and given their own forum. Go and look at them! They are nice, and there may be new ones that you didn't know about! Hooray for rules! Hooray for The System! Hooray for Conforming!

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

15556586061100

Posts

  • bowenbowen Registered User regular
    Lux782 wrote: »
    using(MyClass obj =MyClass(stuff))
    {
        obj.PerformAction();
        while(obj.Results().Read())
        {
        // do stuff
        }
    }
    

    I still don't like that...This appears to do lots of stuff. I would probably attempt to refactor it out more, potentially into its own class. You essentially have 2 actions you are doing. First you are doing something then you processing the results of that action.
    Spoiler:

    Probably could refactor out more stuff, if the pattern is repeated as often as you say, you may be able to abstract a lot of things out and get some good reuse out of it.


    I'd disagree. Generally you have to iterate through the results either way. Mostly this is a UI attachment so iterating through it is to show it on the screen in some fashion. In this case it tosses it in a list view from an array.

    But that's been changed .PerformAction() returns an array of objects and then I do :
    ListView.Items.AddRange(obj.PerformAction());
    

  • urahonkyurahonky Registered User regular
    Okay I've run into a snag and I'm hoping someone here can help out.

    I used a Scene (which is imported from org.netbeans.api.visual.widget.Scene) as a tabbed pane component. Mainly because I need to be able to drag/drop a widget into it. I've tested it, and it works. I'm able to put two tabs, each with Scenes and change the background color of each and they show up properly.

    The problem now is adding to that Scene. I thought using tabbedPane.getSelectedComponent() would give me a Scene since that's the component inside. But it doesn't. This is the code I'm using:
    System.out.println("CLASS: " + getJTabbedPane().getSelectedComponent().getClass());
    

    This outputs:
    CLASS: class org.netbeans.api.visual.widget.SceneComponent

    So I figure I could typecast the SceneComponent to a Scene, right? Nope. When I do that I get an inconvertable types error. Then I try to typecast it as a SceneComponent, but it doesn't know what a SceneComponent is. So I'm stuck. How do I get the original scene that is inside the tabbed pane?

    Games completed recently: Dragon's Crown, Knights of Pen and Paper, Castlevania: Symphony of the Night (20th time), Defender's Quest, The Witcher
  • bowenbowen Registered User regular
    They're both widgets, can't you look for a widget instead of Scene?

  • urahonkyurahonky Registered User regular
    Same error somehow. It says "Cannot covert Component to Widget". Which is weird because when I output the class of the component it comes out as a SceneComponent.

    Games completed recently: Dragon's Crown, Knights of Pen and Paper, Castlevania: Symphony of the Night (20th time), Defender's Quest, The Witcher
  • urahonkyurahonky Registered User regular
    I feel like I need to extend JTabbedPane and basically allow the tabs to accept a scene and be able to return a scene.

    Games completed recently: Dragon's Crown, Knights of Pen and Paper, Castlevania: Symphony of the Night (20th time), Defender's Quest, The Witcher
  • bowenbowen Registered User regular
    What if you accept component instead of widget? :P

  • urahonkyurahonky Registered User regular
    bowen wrote: »
    What if you accept component instead of widget? :P

    I'm not sure what you mean. Are you talking about error checking? :) I am going to be the only one using this Tabbed Pane class.

    Games completed recently: Dragon's Crown, Knights of Pen and Paper, Castlevania: Symphony of the Night (20th time), Defender's Quest, The Witcher
  • bowenbowen Registered User regular
    edited April 2012
    Change the expected type? I don't know. You should be able to use them as their parent class, so if you can add a tab as a widget, express it as the most unique object of the hierarchy.

    In your case Scene and SceneComponent are both of "widget" type. Use that as the object you use to add a tab. Obviously you made your function accept a Scene type object right? Change that. This is the power of polymorphism.
    //function to add widgets as tabs
    private void addTab(Widget TheWidget)
    {
        //add it to the window here?
    }
    
    public void DragDropPassEventThing(//yadda)
    {
        //somewhere else
        Widget tabWidge1 = new Scene("Tab1");
        Widget tabWidge2 = new SceneComponent("Tab2");
    
        this.addTab(tabWidge1);
        this.addTab(tabWidge2);
    }
    

    This way your function can take either of those types of components and use them as tabs.

    bowen on
  • urahonkyurahonky Registered User regular
    bowen wrote: »
    Change the expected type? I don't know. You should be able to use them as their parent class, so if you can add a tab as a widget, express it as the most unique object of the hierarchy.

    In your case Scene and SceneComponent are both of "widget" type. Use that as the object you use to add a tab. Obviously you made your function accept a Scene type object right? Change that. This is the power of polymorphism.
    //function to add widgets as tabs
    private void addTab(Widget TheWidget)
    {
        //add it to the window here?
    }
    
    public void DragDropPassEventThing
    {
        //somewhere else
        Widget tabWidge1 = new Scene("Tab1");
        Widget tabWidge2 = new SceneComponent("Tab2");
    
        this.addTab(tabWidge1);
        this.addTab(tabWidge2);
    }
    

    This way your function can take either of those types of components and use them as tabs.

    This would work except I need scenes because I am going to be adding the Widgets TO that scene. Each tab will have it's own Scene with it's own Widgets on that scene. Scene is the parent of all the Widgets... Hopefully this makes sense. So far my SceneTabbedPane is working like a champ.

    Games completed recently: Dragon's Crown, Knights of Pen and Paper, Castlevania: Symphony of the Night (20th time), Defender's Quest, The Witcher
  • JasconiusJasconius sword criminal Flo-ridaRegistered User regular
    Anyone have a comprehensive link to how do deal with array values in querystrings in MVC3?

    such as:

    &filter[filters][0][value]=thing

  • bowenbowen Registered User regular
    Clearly something is converting your scene into scenecomponents then urahonkey, or it was designed to prevent someone doing what you're doing without doing it the way I'm showing.

  • urahonkyurahonky Registered User regular
    bowen wrote: »
    Clearly something is converting your scene into scenecomponents then urahonkey, or it was designed to prevent someone doing what you're doing without doing it the way I'm showing.

    Yeah I'm not sure what/why/how it's doing that, honestly.

    Games completed recently: Dragon's Crown, Knights of Pen and Paper, Castlevania: Symphony of the Night (20th time), Defender's Quest, The Witcher
  • centraldogmacentraldogma Registered User regular
    org.netbeans.api.visual.widget.SceneComponent isn't even listed in the Netbeans API. Like, it's not even listed as existing...

    signaturecreation.gif
  • baronfelbaronfel Registered User regular
    edited April 2012
    I should have asked you guys before blindly choosing a mocking framework for java :(

    I initially went with Jmock based on nothing more than google result listings, but a friend just introduced me to Mockito, which looks to be about 100x more streamlined, and more along the lines of Rhino.Mocks, which I use for my .Net work.

    Anywho, just thought I'd toss that out for general informative purposes.

    PS - Explaining why mocking and unit testing is in general a good thing for verification and validation to someone who has hobby coded, but nothing of any real size, since before I was out of diapers is surprisingly hard.

    baronfel on
  • bowenbowen Registered User regular
  • baronfelbaronfel Registered User regular
    Unrelated:

    I just watched this talk on creating a bridge between Java bytecode and the .Net CLR. The main thrust is IKVM lets you use libraries from Java in .Net nearly seamlessly.

    Keep an eye out towards the end for the presenter running Eclipse, on the CLR faster than the original Java-bytecode parent.

  • urahonkyurahonky Registered User regular
    org.netbeans.api.visual.widget.SceneComponent isn't even listed in the Netbeans API. Like, it's not even listed as existing...

    Yep. I looked at the API as well. :P

    Games completed recently: Dragon's Crown, Knights of Pen and Paper, Castlevania: Symphony of the Night (20th time), Defender's Quest, The Witcher
  • bowenbowen Registered User regular
    SceneComponent seems to be an underlying class involved in things like GraphScene that devs can't/shouldn't touch.

  • SaerisSaeris Chronogestaltist Trinity, New MexicoRegistered User regular
    Huh. The regex one granted me some new insight. I didn't know about non-capturing groups.

    Nlgya.png
  • urahonkyurahonky Registered User regular
    Ugh... It's "Serif" not "Sareef"

    Games completed recently: Dragon's Crown, Knights of Pen and Paper, Castlevania: Symphony of the Night (20th time), Defender's Quest, The Witcher
  • GnomeTankGnomeTank Registered User regular
    Well...yeah, because serif is a word and sereef is not :P

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh
  • admanbadmanb the bored genie Seattle, WARegistered User regular
    Sareef is almost, but not quite, a Middle-Eastern/Indian name.

    twitter, github, resume/portfolio, if you like to play or host boardgames online, check out handtracker
  • urahonkyurahonky Registered User regular
    Just a pet peeve of mine. That and "Libary" instead of "Library".

    Games completed recently: Dragon's Crown, Knights of Pen and Paper, Castlevania: Symphony of the Night (20th time), Defender's Quest, The Witcher
  • GnomeTankGnomeTank Registered User regular
    edited April 2012
    Who in the world says/types "libary"?

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh
  • SaerisSaeris Chronogestaltist Trinity, New MexicoRegistered User regular
  • admanbadmanb the bored genie Seattle, WARegistered User regular
    GnomeTank wrote: »
    Who in the world says/types "libary"?

    I said libary a lot... when I was around the age of 12.

    twitter, github, resume/portfolio, if you like to play or host boardgames online, check out handtracker
  • urahonkyurahonky Registered User regular
    Almost everyone in this room says "libary" and it literally kills me inside.

    Games completed recently: Dragon's Crown, Knights of Pen and Paper, Castlevania: Symphony of the Night (20th time), Defender's Quest, The Witcher
  • GnomeTankGnomeTank Registered User regular
    urahonky wrote: »
    Almost everyone in this room says "libary" and it literally kills me inside.

    I am sure it's not completely true, but you do an excellent job of making everyone you work with sound like a mouth breathing pants on head idiot.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh
  • seabassseabass Doctor MassachusettsRegistered User regular
    edited April 2012
    admanb wrote: »
    Sareef is almost, but not quite, a Middle-Eastern/Indian name.

    With my deepest apologies
    Spoiler:

    seabass on
    Run you pigeons, it's Robert Frost!
  • admanbadmanb the bored genie Seattle, WARegistered User regular
    Goddamn.

    twitter, github, resume/portfolio, if you like to play or host boardgames online, check out handtracker
  • urahonkyurahonky Registered User regular
    GnomeTank wrote: »
    urahonky wrote: »
    Almost everyone in this room says "libary" and it literally kills me inside.

    I am sure it's not completely true, but you do an excellent job of making everyone you work with sound like a mouth breathing pants on head idiot.

    Hah. No comment.

    Games completed recently: Dragon's Crown, Knights of Pen and Paper, Castlevania: Symphony of the Night (20th time), Defender's Quest, The Witcher
  • urahonkyurahonky Registered User regular
    Truth be told I'm not very intelligent. I just learn to adapt. :P

    Games completed recently: Dragon's Crown, Knights of Pen and Paper, Castlevania: Symphony of the Night (20th time), Defender's Quest, The Witcher
  • TrippyJingTrippyJing Moses supposes his toeses are roses. But Moses supposes erroneously.Registered User regular
    edited April 2012
    I've got a bit of a problem. I have a project which makes use of a Library class. The class has two vector member variables which are manipulated with the member functions, but this isn't happening. I'm fairly certain I fucked up the constructor somehow, since every time I debug it, the vectors are destroyed immediately upon calling a member function.
    Spoiler:

    TrippyJing on
    mosesupposes.gif
  • ecco the dolphinecco the dolphin Registered User regular
    TrippyJing wrote: »
    I'm fairly certain I fucked up the constructor somehow, since every time I debug it, the vectors are destroyed immediately upon calling a member function.

    Sort of. By doing:
    Library::Library()
    {
    	int numCards = 0;
    	int numBooks = 0;
    	std::vector<Book> booklist;
    	std::vector<Card> cardlist;
    }
    

    You're creating numCards, numBooks, booklist and cardlist as local variables in the constructor, not member variables of the class.

    Compare with:
    void testFunction( void )
    {
    	int localCopy; // This variable only exists in testFunction()
    }
    

    This is what you're doing. This is why you are seeing the vectors being destroyed after calling the constructor... and I suspect that you've made the same mistake in the member functions.

    To use member variables instead of creating local variables:
    Library::Library()
    {
    	numCards = 0; // They already exist
    	numBooks = 0;
    }
    

    assuming that you declared them in the Library class by doing something like:
    class Library
    {
    public:
    	// ...
    
    private:
    	int numCards, numBooks;
    	std::vector<Book> booklist;
    	std::vector<Card> cardlist;
    };
    

    Penny Arcade Developers at PADev.net.
  • TrippyJingTrippyJing Moses supposes his toeses are roses. But Moses supposes erroneously.Registered User regular
    That is exactly how I had them declared, and it seems I fundamentally misunderstood constructors.

    Thanks! That solves my main problem, and now I just have to write up the documentation and I'm done.

    mosesupposes.gif
  • [Michael][Michael] Registered User regular
    Corona SDK seems like it's pretty awesome for the projects it can do (though I do see its limitations). I spent maybe a month of on and off free-time learning Android and making an app, and I managed to recreate it in Corona in 3 days. Might be worth it to shell out the 400 dollars or whatever for it if it means being able to publish to iOS and Android.

    Plus, Lua is pretty fun compared to Java. It's at least a nice break.

  • Mike DangerMike Danger "Diane..." a place both wonderful and strangeRegistered User regular
    So my friend suggested I try Readability in lieu of Instapaper. However, as far as I can tell, there isn't an easy "import your articles from Instapaper to Readability" service. "I know," I said last night, "I'll use Ruby to handle this!"

    Sure enough, Readability has an associated gem for their library (Readit); however, Readit assumes that you have an access token/secret before you start. I decided to try doing this with XAuth and I'm not sure what I'm doing wrong:
    require 'highline/import'
    require 'yaml'
    require 'oauth'
    require 'readit'
    
    config = YAML.load_file("config/readability.yaml")
    uname = ask ("Username: ") 
    passwd = ask ("Password: ") {|q| q.echo = false}
    
    consumer = OAuth::Consumer.new(config["-consumer_key"], config["-consumer_secret"], :site => "https://www.readability.com/api/rest/v1/oauth/access_token/";)
    access_token = consumer.get_access_token(nil, {}, {:x_auth_mode => 'client_auth', :x_auth_username => uname, :x_auth_password => passwd})
    

    Running this and giving my username/password gets me:
    /Users/mike/.rvm/gems/ruby-1.9.3-p125/gems/oauth-0.4.5/lib/oauth/consumer.rb:219:in `token_request': 404 NOT FOUND (OAuth::Unauthorized)
    	from /Users/mike/.rvm/gems/ruby-1.9.3-p125/gems/oauth-0.4.5/lib/oauth/consumer.rb:109:in `get_access_token'
    	from instab.rb:15:in `<main>'
    

    I'm not sure what I'm doing wrong. That URL to readability's site seems to be right, and uname and passwd have the values I expect them to have before I make the get_access_token call.

  • Jimmy KingJimmy King Registered User regular
    I haven't messed with xAuth, but in the standard OAuth flow there's a callback URL on your own side which you pass to the server during the token request process and the server will redirect the user back to that URL and some more stuff is done there. Does xAuth also need that? With twitter and yahoo to not use it you pass "oob" as the callback URL. That would be my first guess as to what's going wrong, not being familiar with any differences xAuth has over OAuth other than that you pass in the username and password yourself.

    Other than that, look at the line in the code it's specifying is causing the error to see what URL it might be trying to access and where that comes from is my advice.

    import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.stringreturners.StringStringReturner;
  • Lux782Lux782 Registered User regular
    For those who are interested in cool stuff.

    http://0x10c.com/doc/dcpu-16.txt

    Its a 16bit assembler spec for a new game Notch is apparently working on.

This discussion has been closed.