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.
// calling code
using(MyClassProcessor process = new MyClassProcessor(new MyClass(stuff))
process.Run();
class MyClassProcess : IDisposable
{
private MyClass myClass;
public MyClassProcess(MyClass obj)
{
myClass = obj;
}
public void Dispose()
{
myClass.Dispose();
}
public void Run() {
DoAction();
ProcessResults();
}
private void DoAction();
private void ProcessResults(); // If this is really complex it might be worth while breaking out into its own class
}
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());
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
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:
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?
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.
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
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
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.
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.
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
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.
org.netbeans.api.visual.widget.SceneComponent isn't even listed in the Netbeans API. Like, it's not even listed as existing...
When people unite together, they become stronger than the sum of their parts.
Don't assume bad intentions over neglect and misunderstanding.
0
Options
baronfelWould you say I havea _plethora_?Registered Userregular
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.
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
0
Options
baronfelWould you say I havea _plethora_?Registered Userregular
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.
Truth be told I'm not very intelligent. I just learn to adapt. :P
0
Options
TrippyJingMoses supposes his toeses are roses.But Moses supposes erroneously.Registered Userregular
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.
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:
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.
0
Options
Mike Danger"Diane..."a place both wonderful and strangeRegistered Userregular
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:
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.
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.
Posts
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 :
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:
This outputs:
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?
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.
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.
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.
such as:
&filter[filters][0][value]=thing
Yeah I'm not sure what/why/how it's doing that, honestly.
Don't assume bad intentions over neglect and misunderstanding.
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.
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.
Yep. I looked at the API as well. :P
saw this and thought maybe a few of you could use it.
I said libary a lot... when I was around the age of 12.
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.
With my deepest apologies
Hah. No comment.
Sort of. By doing:
You're creating numCards, numBooks, booklist and cardlist as local variables in the constructor, not member variables of the class.
Compare with:
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:
assuming that you declared them in the Library class by doing something like:
Thanks! That solves my main problem, and now I just have to write up the documentation and I'm done.
Plus, Lua is pretty fun compared to Java. It's at least a nice break.
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:
Running this and giving my username/password gets me:
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.
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.
http://0x10c.com/doc/dcpu-16.txt
Its a 16bit assembler spec for a new game Notch is apparently working on.