Hello. I have Class1, which has methods:
setSomething()
createObjectOfClass2()
Now, when I create object of Class2, is it possible to call setSomething method from it?
Following http://stackoverflow.com/questions/659647/how-to-get-folder-path-from-file-path-with-cmd
I want to strip the path (without the filename) from a variable. following the logic of the methods discussed above I would like to use batch bellow, which doesn't work. any takers? possible?
set cpp="C:\temp\lib.dll"
echo %cpp%
"C:\temp\lib.dll"
echo %~dpcpp
"C:\temp\" > doesn't work
I only see static methods by which we don't need to instantiate a class to call the method.
What's the purpose of a static function?
static GtkWidget *
create_bbox (gint horizontal,
char *title,
gint spacing,
gint layout)
{
...
}
What's the best way to get the current PowerShell Cmdlet from another object? If I create a helper object that is not a Cmdlet but will be called by Cmdlets, the helper methods may want to call WriteVerbose, WriteDebug etc. What's the best way to get access to that? Is there a static PowerShell method that will return the current Cmdlet or do I need to have the Cmdlet pass itself to the helper?
How to add comments/description/information about the web service methods so that the person who will invoke it will know what the method is for , what are the useful params etc. so the invoker will be able to read these.
The List interface is the following:
public interface List<E>{
public boolean add(Object e);
public boolean remove(Object e);
public boolean contains(Object e);
...etc
Why aren't the add, remove and contains methods written like the following?
public boolean add(E e)
public boolean remove(E e)
public boolean contains(E e)
Hi,
I first time tried to subClassed an NSDate to give it 2 methods that I need. Compiles fine, but in runtime I try to access it I get an error.
Lets say I just want the current date which is unmodified in the subClass:
[myNSDate date];
I get the error
-[NSDate initWithTimeIntervalSinceReferenceDate:]: method only defined for
abstract class. Define -[myNSDate initWithTimeIntervalSinceReferenceDate:]!
what is different?
I want to create two UIViews in quartz 2D application.
First UIView for static text, it will redraw automatically after each one second.
Second UIView for animated text, it will be redrawn automatically after each .1 second.
How can i create multiple Views/Layers? Is there drawRect methods will be different?
My question is similar to this one over here about include and extend.
What's the difference between require and include in Ruby? If I just want to use the methods from a module in my class, should I require it or include it?
Given the following object graph:
{
"children": [
{
"child": {
"pets": [
{
"pet": {
"name": "fido"
}
},
{
"pet": {
"name": "fluffy"
}
}
]
}
},
{
"child": {
"pets": [
{
"pet": {
"name": "spike"
}
}
]
}
}
]
}
What would be a nice one-liner (or two) to collect the names of my grandchildren's pets? The result should be ["fido", "fluffy", "spike"]
I don't want to write custom methods for this... I'm looking for something like the way jQuery works in selecting dom nodes, where you can just give it a CSS-like path and it collects them up for you.
I would expect the expression path to look something like "children child pets pet name"
Apologies for the indescriptive title, however it's the best I could think of for the moment.
Basically, I've written a singleton class that loads files into a database. These files are typically large, and take hours to process. What I am looking for is to make a method where I can have this class running, and be able to call methods from within it, even if it's calling class is shut down.
The singleton class is simple. It starts a thread that loads the file into the database, while having methods to report on the current status. In a nutshell it's al little like this:
public sealed class BulkFileLoader {
static BulkFileLoader instance = null;
int currentCount = 0;
BulkFileLoader()
public static BulkFileLoader Instance
{
// Instanciate the instance class if necessary, and return it
}
public void Go() {
// kick of 'ProcessFile' thread
}
public void GetCurrentCount() {
return currentCount;
}
private void ProcessFile() {
while (more rows in the import file) {
// insert the row into the database
currentCount++;
}
}
}
The idea is that you can get an instance of BulkFileLoader to execute, which will process a file to load, while at any time you can get realtime updates on the number of rows its done so far using the GetCurrentCount() method.
This works fine, except the calling class needs to stay open the whole time for the processing to continue. As soon as I stop the calling class, the BulkFileLoader instance is removed, and it stops processing the file. What I am after is a solution where it will continue to run independently, regardless of what happens to the calling class.
I then tried another approach. I created a simple console application that kicks off the BulkFileLoader, and then wrapped it around as a process. This fixes one problem, since now when I kick off the process, the file will continue to load even if I close the class that called the process. However, now the problem I have is that cannot get updates on the current count, since if I try and get the instance of BulkFileLoader (which, as mentioned before is a singleton), it creates a new instance, rather than returning the instance that is currently in the executing process. It would appear that singletons don't extend into the scope of other processes running on the machine.
In the end, I want to be able to kick off the BulkFileLoader, and at any time be able to find out how many rows it's processed. However, that is even if I close the application I used to start it.
Can anyone see a solution to my problem?
Today I had an epiphany, and it was that I was doing everything wrong. Some history: I inherited a C# application, which was really just a collection of static methods, a completely procedural mess of C# code. I refactored this the best I knew at the time, bringing in lots of post-college OOP knowledge. To make a long story short, many of the entities in code have turned out to be Singletons.
Today I realized I needed 3 new classes, which would each follow the same Singleton pattern to match the rest of the software. If I keep tumbling down this slippery slope, eventually every class in my application will be Singleton, which will really be no logically different from the original group of static methods.
I need help on rethinking this. I know about Dependency Injection, and that would generally be the strategy to use in breaking the Singleton curse. However, I have a few specific questions related to this refactoring, and all about best practices for doing so.
How acceptable is the use of static variables to encapsulate configuration information? I have a brain block on using static, and I think it is due to an early OO class in college where the professor said static was bad. But, should I have to reconfigure the class every time I access it? When accessing hardware, is it ok to leave a static pointer to the addresses and variables needed, or should I continually perform Open() and Close() operations?
Right now I have a single method acting as the controller. Specifically, I continually poll several external instruments (via hardware drivers) for data. Should this type of controller be the way to go, or should I spawn separate threads for each instrument at the program's startup? If the latter, how do I make this object oriented? Should I create classes called InstrumentAListener and InstrumentBListener? Or is there some standard way to approach this?
Is there a better way to do global configuration? Right now I simply have Configuration.Instance.Foo sprinkled liberally throughout the code. Almost every class uses it, so perhaps keeping it as a Singleton makes sense. Any thoughts?
A lot of my classes are things like SerialPortWriter or DataFileWriter, which must sit around waiting for this data to stream in. Since they are active the entire time, how should I arrange these in order to listen for the events generated when data comes in?
Any other resources, books, or comments about how to get away from Singletons and other pattern overuse would be helpful.
Hi!
I have a static library static_library.a
How to list functions and methods realized there.
or at least how to look is there concrete function 'FUNCTION_NAME' realized?
There are so many methods out there and it's a bit confusing but what's the best way to change the default grid columns in the Magento 1.4 product catalog?
Thanks
I'm developing a web site, and i'm using infragistics for web, but I want to use in some pages silverlight controls (Infragistics too). Is there a way to access a silverlight control's properties and methods from an aspx page?
Thanks in advance for the help.
When debugging in Visual Studio and you want to step into a procedure for example, but you dont want to step into the parameter methods.
Is there a way to do this?
var a = StepIntoSomething(getSomeValueDontStepIn(1),getSomeValueDontStepIn(2));
How to declare an array in method declaration in gen-class?
(ns foo.bar
(:gen-class
:methods [[parseString [String Object] Object]]))
That works fine. But the return type is really an array. How I can declare that so Java can understand it?
Hello
I have a loop created with each, check this example:
$('.foo').each(function(i){
//do stuff
});
Is there any possibility to run a functions when this loop has ended? Couldn't find it on docs or Google.
I can make it work without this kind of solution, but it's always good to search for and use the simpliest methods.
Martti Laine
I want to record audio using the iphone (< 2 minutes) and save it to a file.
I looked at SpeakHere, but it confuses me. Which classes do I use? What delegate methods do I create?
Thanks!
I am reluctant to say I can't figure this out, but I can't figure this out. I've googled and searched Stack Overflow, and come up empty.
The abstract, and possibly overly vague form of the question is, how can I use the traits-pattern to instantiate non-virtual member functions? The question came up while modernizing a set of multivariate function optimizers that I wrote more than 10 years ago.
The optimizers all operate by selecting a straight-line path through the parameter space away from the current best point (the "update"), then finding a better point on that line (the "line search"), then testing for the "done" condition, and if not done, iterating.
There are different methods for doing the update, the line-search, and conceivably for the done test, and other things. Mix and match. Different update formulae require different state-variable data. For example, the LMQN update requires a vector, and the BFGS update requires a matrix. If evaluating gradients is cheap, the line-search should do so. If not, it should use function evaluations only. Some methods require more accurate line-searches than others. Those are just some examples.
The original version instantiates several of the combinations by means of virtual functions. Some traits are selected by setting mode bits that are tested at runtime. Yuck. It would be trivial to define the traits with #define's and the member functions with #ifdef's and macros. But that's so twenty years ago. It bugs me that I cannot figure out a whiz-bang modern way.
If there were only one trait that varied, I could use the curiously recurring template pattern. But I see no way to extend that to arbitrary combinations of traits.
I tried doing it using boost::enable_if, etc.. The specialized state information was easy. I managed to get the functions done, but only by resorting to non-friend external functions that have the this-pointer as a parameter. I never even figured out how to make the functions friends, much less member functions. The compiler (VC++ 2008) always complained that things didn't match. I would yell, "SFINAE, you moron!" but the moron is probably me.
Perhaps tag-dispatch is the key. I haven't gotten very deeply into that.
Surely it's possible, right? If so, what is best practice?
I am having a a method which listens continuously to a stream from a server and writes that data to datastore in google app which is later on retrieved by other methods.
How can i do that in google app engine i.e calling that method one time during the starting of app and having it running for unlimited time without affecting other things.
I am new to java world,So please help from that point of view also.How's that done in Java?
In webmethods, it is very simple to implement caching by annotating [WebMethod(CacheDuration...] attribute. Can we create something similar for non-webmethods, such as Static methods?
Any help/tip is appreciated. Thanks in advance.
Duplicate of Calling .NET methods from VB6 via COM visible DLL
Which ways exist to use/call .NET classes/functions/libraries (.net 3.x) in VB6 or classical ASP ?
Has anybody experiences with that ? How much effort is necessary to wrap .NET to COM ?
Are there tools which help ?
Hi,
I am working on an iphone application in which I am consuming a webservice.
So i am parsing the XML file data. any idea about how to parse self closing tag
like: State/ and how to read data of self tag like: Contact Email="[email protected]" Name="PhD" Phone="123-521-3388" Source="location"/
I am parsing xml file using NSXMLPARSER class methods and library
Thanks,