instruction
stringlengths
0
30k
Alternatives to System.exit(1)
|java|process|
For various reasons calling System.exit is frowned upon when writing Java Applications, so how can I notify the calling process that not everything is going according to plan?
For various reasons calling System.exit is frowned upon when writing Java Applications, so how can I notify the calling process that not everything is going according to plan? **Edit:** The 1 is a standin for any non-zero exit code.
|java|processes|
Can you force either a scalar or array ref to be an array in Perl?
|perl|scalar|array|
I have a perl variable `$results` that gets returned from a service. The value is supposed to be an array, and `$results` should be an array reference. However, when the array has only one item in it, `$results` will be set to that value, and not a referenced array that contains that one item. I want to do a `foreach` loop on the expected array. Without checking `ref($results) eq 'ARRAY'`, is there any way to have something equivalent to the following: foreach my $result (@$results) { # Process $result } That particular code sample will work for the reference, but will complain for the simple scalar.
|perl|arrays|scalar|
I have a perl variable `$results` that gets returned from a service. The value is supposed to be an array, and `$results` should be an array reference. However, when the array has only one item in it, `$results` will be set to that value, and not a referenced array that contains that one item. I want to do a `foreach` loop on the expected array. Without checking `ref($results) eq 'ARRAY'`, is there any way to have something equivalent to the following: foreach my $result (@$results) { # Process $result } That particular code sample will work for the reference, but will complain for the simple scalar. EDIT: I should clarify that there is no way for me to change what is returned from the service. The problem is that the value will be a scalar when there is only one value and it will be an array reference when there is more than one value.
|perl|arrays|reference|scalar|
Windows built-in ZIP compression script-able?
|windows|batch-file|script|vbscript|zip|
Is the zip compression that is built into Windows XP/Vista/2003/2008 able to be scripted at all? What executable would I have to call from a BAT/CMD file? or is it possible to do it with VBScript? I realize that this is possible using WinZip, 7-zip and other external apps, but I'm looking for something that requires no external apps to be installed.
|windows|batch-file|vbscript|scripting|zip|
I don't think you'll find it in the C spec, more likely the spec for your OS. My experience in Linux has been that it's always the lowest.
If you are actually looking for Charting libraries and not for Node/Edge Graph libraries I would suggest splurging on Big Faceless Graph library ([BFG][1]). It's way easier to use than JFreeChart, looks nicer, runs faster, has more output options, really no comparison. [1]: http://big.faceless.org/products/graph/
The best way would be to add a common base class, otherwise you can fall back to reflection.
You could just write a 'brute force' command line tool that comments out the #includes one by one and tests whether the compile still works. Let me know when you've got it to work. ;0)
I'll counter this with another question - why does this matter? You shouldn't be comparing the file descriptor with anything (unless checking for stdin/stdout/stderr) or doing math with it. As long as it fits in an int (and its guaranteed to) that's all you really need to know.
I've tried various techniques and had most success with [SWFUpload](http://swfupload.org). You create and interact with an SWFUpload object using Javascript, but uses a (hidden) Flash file for file selection, uploading and upload progress monitoring. You can specify a wide range of Javascript event handlers (<code>uploadStarted</code>, <code>uploadProgress</code>, <code>uploadError</code> etc.) that the Flash will call during the upload progress making it very flexible. It also implements a file queue, so it works well for single or multiple files. *Links:* * [API documentation](http://demo.swfupload.org/Documentation/#methods) * [Demos](http://demo.swfupload.org/) * [Downloads](http://code.google.com/p/swfupload/downloads/list)
This may be a bit off topic (I'm replying specifically to your question about source control and graphics), but you *can* put binary data (images etc.) into source control (and in my opinion in a lot of cases should) -- they just take up more disk space and you can't use a diff view to analyze what has changed in any meaningful way, but what you do gain is a history of commit messages documenting each revision, rollback ability and the ability to easily archive (*tagging a revision* in SVN terms) all files (be they visual assets, documentation, source code, whatever) belonging to a specific release/version together. It's also easier for your build system to just fetch everything required for building a specific version of your software from the source control.
Steve M is right; C has no notion of sockets, and its file I/O functions use a [pointer to a] FILE object, not a descriptor.
How to discover USB storage devices and writable CD/DVD drives (C#)
|c#|.net-2.0|
How can I discover any USB storage devices and/or CD/DVD writers available at a given time (using C# .Net2.0). I would like to present users with a choice of devices onto which a file can be stored for physically removal - i.e. not the hard drive.
Solaris :) On a serious note, there is no Linux distro dedicated to Java, so it would be about the same. [OpenSolaris][1] on the other hand (in my *very* humble experience) would be a bit faster, and you would have bonus of Dtrace as a tool. (Not that you can't find similar tools in Linux, but Dtrace should be somewhat more advanced). [1]: http://opensolaris.org/os/
Referring to [the bible](http://plan9.bell-labs.com/cm/cs/cbook/): - Your addition operation causes the int to be converted to an unsigned int. - Assuming two's complement representation and equally sized types, the bit pattern does not change. - Conversion from unsigned int to signed int is implementation dependent. (But it probably works the way you expect on most platforms these days.) - The rules are a little more complicated in the case of combining signed and unsigned of differing sizes.
Top on my list are: 1. Software Engineering Radio 2. Java Posse Sometimes I also listen to: The ASP.NET podcast I keep an eye on iTunes U as some courses have the perfect price (free) from top-notch Universities around the world. E.g. Computer Language Engineering from MIT.
Be aware that classes that descend from NumberFormat (and most other Format descendants) are not synchronized. It is a common (but dangerous) practice to create format objects and store them in static variables in a util class. In practice, it will pretty much always work until it starts experiencing significant load.
You could try looking at the lower tier offerings from AT&T and Comcast. Probably 1.5 Mbps for the basic level (which I imagine most people get). The "test your bandwidth" sites may have some stats on this, too.
It would depend on the geography that you are targeting. For example, in India, you can safely assume it would be a number below 256kbps.
[Speedtest.net][1] has a lot of stats broken down by country, region, city and ISP. Not sure about accuracy, since it's only based on the people using their "bandwidth measurement" service. [1]: http://speedtest.net/global.php
There are a lot of factors involved (server bandwidth, local ISP, network in between, etc) which make it difficult to give a hard answer. With my current ISP, I typically get 200-300 kB/sec. Although when the planets align I've gotten as much as 2 MB/sec (the "quoted" peak downlink speed). That was with parallel streams, however. The peak bandwidth I've achieved on a single stream is 1.2 MB/sec
How to promote WCF to a non-techie?
|c#|.net|web-services|wcf|
How would you describe and promote WCF as a technology to a non-technical client/manager/CEO/etc? What are competing solutions or ideas that they might bring up(such as those they read about in their magazines touting new technology)? What is WCF *not* good for that you've seen people try to shoehorn it into? -Adam
|c#|.net|web-services|wcf|soa|
In vim is there a way to delete without putting text in the register?
|vim|vi|
Using vim I often want to replace a block of code with a block that I just yanked. But when I delete the block of code that is to be replaced, that block itself goes into the register which erases the block I just yanked. So I've got in the habit of yanking, then inserting, then deleting what I didn't want, but with large blocks of code this gets messy trying to keep the inserted block and the block to delete separate. So what is the slickest and quickest way to replace text in vim? - is there a way to delete text without putting it into the register? - is there a way to say e.g. "replace next word" or "replace up to next paragraph" - or is the best way to somehow use the multi-register feature?
I guess if you could store this information with Javascrit and cookies for the functionality of remembering the bookmarks and even add a splash of Ajax if you wanted to interact with a database. CSS would only be able todo the styling bit. You would have to give the bookmarked anchor a class found in ur css file. CSS also have the a:visited selector which is used for styling links found in the browsers history.
If A, B, C and D have nothing in common then adding a base class won't really get you anything. It will just be an empty class and in effect will be the same as object. I'd just create an ErrorItem class without the generics, make Item an object and do some casting when you want to use the objects referenced. If you want to use any of the properties or methods of the A, B, C or D class other than the Guid you would have had to cast them anyway.
It depends on when you want to determine this. You could print the "value" of, say, a label control (which has no "value" property) to the debugger like: debug.print("Value for cmdTest is ["+format(cmdTest)+"]" Which will give you something like: > Value for cmdTest is [False] As it turns out, the default value for a command button is it's state (pressed or not), so if you put the code example above in the click event for the control, you will see "True", if you execute it somewhere else, you'll see "False". For other results, this method will at least show you the sort of property you're looking for. You could use: debug.print "cmdTest's value is of type ["+TypeName(oObject) +"]" which tell you the actual type, namely: > cmdTest's value is of type [Boolean] You could use various methods to narrow things down, such as setting the value and seeing what happens.
It depends on when you want to determine this. You could print the "value" of, say, a label control (which has no "value" property) to the debugger like: debug.print "Value for cmdTest is ["+format(cmdTest)+"]" Which will give you something like: > Value for cmdTest is [False] As it turns out, the default value for a command button is it's state (pressed or not), so if you put the code example above in the click event for the control, you will see "True", if you execute it somewhere else, you'll see "False". For other results, this method will at least show you the sort of property you're looking for. You could use: debug.print "cmdTest's value is of type ["+TypeName(oObject) +"]" which tell you the actual type, namely: > cmdTest's value is of type [Boolean] You could use various methods to narrow things down, such as setting the value and seeing what happens.
|version-control|decentralized-version-co|distributed|
|version-control|distributed|dvcs|
Changing CURRENT save/default directory in Delphi 2007 without using Save-As
|delphi|delphiide|
I have a project group that contains a project I'm working on as well as some related component / packages. I prefer to have the database links active at design time, and though I know how to write the code to change database files location, I'm just using ".\data" for that in this case, for a few different reasons, mostly design-time related. Being a relative folder location, though, means Delphi needs to be "pointing" to the same folder as the project is in. I'd like to be able to force that folder location, w/o using "Save As." Does anyone know where the Delphi IDE stores that info?
|ide|delphi|
Mootools: Drag and Drop problem
|mootools|javascript|drag|dragdrop|drop|
|javascript|dragdrop|mootools|
|javascript|drag-and-drop|mootools|
I've asked this question to the forums on the Mootools website and one person said that my class selection was corrupted before an admin came along and changed my post status to invalid. Needless to say this did not help much. I then posted to a google group for mootools with no response. My question is why doesn't the 'enter', 'leave', 'drop' events fire for my '.drop' elements? The events for the .drag elements are working. <title>Untitled Page</title> <script type="text/javascript" src="/SDI/includes/mootools-1.2.js"></script> <script type="text/javascript" src="/SDI/includes/mootools-1.2-more.js"></script> <script type="text/javascript" charset="utf-8"> window.addEvent('domready', function() { var fx = []; $$('#draggables div').each(function(drag){ new Drag.Move(drag, { droppables: $$('#droppables div'), onDrop: function(element, droppable){ if(!droppable) { } else { element.setStyle('background-color', '#1d1d20'); } element.dispose(); }, onEnter: function(element, droppable){ element.setStyle('background-color', '#ffffff'); }, onLeave: function(element, droppable){ element.setStyle('background-color', '#000000'); } }); }); $$('#droppables div').each(function(drop, index){ drop.addEvents({ 'enter': function(el, obj){ drop.setStyle('background-color', '#78ba91'); }, 'leave': function(el, obj){ drop.setStyle('background-color', '#1d1d20'); }, 'drop': function(el, obj){ el.remove(); } }); }); }); </script> <form id="form1" runat="server"> <div> <div id="draggables"> <div class="drag"></div> <div class="drag"></div> <div class="drag"></div> <div class="drag"></div> <div class="drag"></div> <div class="drag"></div> <div class="drag"></div> <div class="drag"></div> <div class="drag"></div> <div class="drag"></div> </div> <div id="droppables"> <div class="drop"></div> <div class="drop"></div> <div class="drop"></div> <div class="drop"></div> <div class="drop"></div> <div class="drop"></div> </div> </div> </form>
I had a REALLY hard to track down bug years ago that was caused by this. The code was something like Object problemMethod() { Object rtn = null; try { rtn = somethingThatThrewAnException(); } finally { doSomeCleanup(); return rtn; } } What happened is that the exception was thrown down in some other code. It was being caught and logged and rethrown within the somethingThatThrewAnException method. But the exception wasn't being propagated up past problemMethod. After a LONG time of looking at this we finally tracked it down to the return method. The return method in the finally block was basically stopping the exception that happened in the try block from propagating up even though it wasn't caught. Like others have said, while it is legal to return from a finally block according to the Java spec, it is a BAD thing and shouldn't be done.
I use dynamic instantiation in my custom framework. My application controller needs to instantiate a sub-controller based on the request, and it would be simply ridiculous to use a gigantic, ever-changing switch statement to manage the loading of those controllers. As a result, I can add controller after controller to my application without having to modify the app controller to call them. As long as my URIs adhere to the conventions of my framework, the app controller can use them without having to know anything until runtime. I'm using this framework in a production shopping cart application right now, and the performance is quite favorable, too. That being said, I'm only using the dynamic class selection in one or two spots in the whole app. I wonder in what circumstances you would need to use it frequently, and whether or not those situations are ones that are suffering from a programmer's desire to over-abstract the application (I've been guilty of this before).
> with loss tolerant Do you mean "with loss tolerance" ? Basically, UDP is not "loss tolerant". You can send 100 packets to someone, and they might only get 95 of those packets, and some might be in the wrong order. For things like video streaming, and multiplayer gaming, where it is better to miss a packet than to delay all the other packets behind it, this is the obvious choice For most other things though, a missing or 'rearranged' packet is critical. You'd have to write some extra code to run on top of UDP to retry if things got missed, and enforce correct order. This would add a small bit of overhead in certain places. Thankfully, some very very smart people have done this, and they called it TCP. Think of it this way: If a packet goes missing, would you rather just get the next packet as quickly as possible and continue (use UDP), or do you actually need that missing data (use TCP). The overhead won't matter unless you're in a really edge-case scenario.
Having small, obtainable goals is one of the greatest ways to learn any skill. Programming is no different. Python is a great language to start with because it is easy to learn, clean and can still do advanced things. Python is only limited by your imagination. One way to really get someone interested is to give them small projects that they can do in an hour or so. When I originally started learning python I playing [Code Golf][1]. They have many small challenges that will help teach the basics of programming. I would recommend just trying to solve one of the challenges a day and then playing with the concepts learned. You've got to make learning to program fun or the interest will be lost very quickly. [1]: http://www.codegolf.com
I would recommend [GenX][1] as a streaming XML writer, I use this in [Programmer's Notepad][2] and it works a treat, you can see examples of use in the source code. Extremely fast, and it produces good UTF-8 XML. Memory usage while you use it should remain roughly constant. [1]: http://www.tbray.org/ongoing/When/200x/2004/02/20/GenxStatus [2]: http://pnotepad.org/
Twitter for work updates
|project-management|project-planning|knowledge|knowledge-management|
If you are sending work/progress reports to the project lead on a daily or weekly basis, I wondered if you would consider using [Twitter][1] or similar services for this updates. Say if you're working remotly or with a distributed team and the project lead has a hard time getting an overview about the topics people are working and where the issues/time consumers are, would you set up some private accounts (or even a private company-internal service) to broadcast progress updates to your colleagues? [1]: http://twitter.com
|project-management|project-planning|knowledge-management|knowledge|
If you are sending work/progress reports to the project lead on a daily or weekly basis, I wondered if you would consider using [Twitter][1] or similar services for this updates. Say if you're working remotly or with a distributed team and the project lead has a hard time getting an overview about the topics people are working and where the issues/time consumers are, would you set up some private accounts (or even a private company-internal service) to broadcast progress updates to your colleagues? **edit** Thanks for the link to those products, but do you already use one of it in your company too? For real-life professional use? [1]: http://twitter.com
Involve the graphic designer in early design and architecture sessions. You want to involve them to reveal misaligned assumptions and to establish a pattern of working together rather than throwing things back and forth over the wall.
I also would not recommend using office apps on a server except for data access to mdb files. I can definitely understand that there are times where it is necessary. In thoses cases I would recommend the following: - Create a separate server where that is the only function. (Let's you reboot with minimum impact). - Have the server implement a mechanism of queuing requests - Keep a single thread processing the queue. This gives you the ability to keep track of the office app, kill it if necessary, and continue on without impacting any queued up jobs or other applications. If you absolutely need to do it on the same server, then at least implement the above in it's own app pool. Limiting yourself keeping a queue of work and only one instance of Excel (or any other office app) let's you kill it with abandon with TaskKill or .Kill() and not lose work. I believe if you keep it to a single thread then you would rarely have a need to kill it.
What to do with queries who don´t have a representation in a domain model?
|orm|
I use the following bit of Python to launch p4merge and use it with git : #!/usr/bin/python import sys import os os.system('/Applications/p4merge.app/Contents/MacOS/p4merge "%s" "%s"' % (sys.argv[2], sys.argv[5])) I'm not sure how mercurial looks to launch an external diff tool though ? Hopefully it's as simple as adjusting 2 & 5 in the above line to being the index of the arguments for 'checked in' and 'current working copy'.
Well, first do this command: :h d Then you will realize that you can delete into a specific register. That way you won't alter what is in your default register.
In light of your update: var inputs = document.getElementsByTagName('input'); var lastTextBox = null; for(var i = 0; i < inputs.length; i++) { if(inputs[i].getAttribute('type') == 'text') { inputs[i].onfocus = function() { lastTextBox = this; } } } var button = document.getElementById("YOURBUTTONID"); button.onclick = function() { lastTextBox.value += 'PUTYOURTEXTHERE'; }
For the specific example that you gave, if I understand the question then this might work: *Highlight what you want to put somewhere else *delete (d) *Highlight the code that you want it to replace *paste (p)
I figured it out myself. The type you're looking for is "HTML" not RichHTML.
I vote for the "sneak in refactorings" approach, which is, I believe, the way refactoring is meant to be done in the first place. It's probably a bad idea to refactor just for the sake of "cleaning up the code." This means that you're making changes for no real reason. Refactoring is, by definition, modifying the without the intent of fixing bugs or adding features. If you're following the KISS principle, any new feature is going to need at least some refactoring because you're not really thinking about how to make the most extensible system possible the first time around.
Use your favorite JS toolkit to add a "highlight" (or whatever) class to the item containing (or contained in) the anchor. Something like: jQuery(location.hash).addClass('highlight'); Of course, you'd need to call that onready or click if you want it triggered by other links on the page, and you'll want to have the .highlight class defined. You could also make your jQuery selector traverse up or down depending on the container you want highlighted.
You can also pass the arguments inside the ant task <arg value="-J-Dhttp.proxyHost=your.proxy.here"/> <arg value="-J-Dhttp.proxyPort=##"/> If going the offline link route. Download the package list by going to the URL of the Java API (http://java.sun.com/j2se/1.5.0/docs/api/package-list) and saving it as a text file and then using this Ant task. <javadoc sourcepath="${source}" destdir="${doc}"> <link offline="true" href="http://java.sun.com/j2se/1.5.0/docs/api/" packagelistloc="path-containing-package-list"/> </javadoc>
Hide directories in wxGenericDirCtrl
|wxwidgets|wxpython|
.NET has a pretty straight forward way to read and watch STDOUT. <br /> I guess this would be the cleanest way, since it is not dependent on any external files, just the path to rsync. I would not be too surprised if there is a wrapper library out there either. If not, write and open source it :)
You can use an instance of the string formatter object passed in to the drawstring method to centre the text. see <http://msdn.microsoft.com/en-us/library/21kdfbzs.aspx> and <http://msdn.microsoft.com/en-us/library/system.drawing.stringformat.aspx>
Here's some code. This assumes you are doing this on a form, or a UserControl. Graphics g = this.CreateGraphics(); SizeF size = g.MeasureString("string to measure"); int nLeft = Convert.ToInt32((this.ClientRectangle.Width / 2) - (size.Width / 2)); int nTop = Convert.ToInt32((this.ClientRectangle.Height / 2) - (size.Height / 2)); From your post, it sounds like the ClientRectangle part (as in, you're not using it) is what's giving you difficulty.
Check out I think it is called Delta Sync. It is a windows gui for rsync (i believe)
Check out I think it is called DeltaCopy. It is a windows gui for rsync (i believe) Looked it up. DeltaCopy http://www.download.com/DeltaCopy/3000-2242_4-10471616.html
Printing from a .NET Service
|.net|c#|windows|service|printing|
I am working on a project right now that involves receiving a message from another application, formatting the contents of that message, and sending it to a printer. Technology of choice is C# windows service. The output could be called a report, I suppose, but a reporting engine is not necessary. A simple templating engine, like StringTemplate, or even XSLT outputting HTML would be fine. The problem I'm having is finding a free way to print this kind of output from a service. Since it *seems* that it will work, I'm working on a prototype using Microsoft's RDLC, populating a local report and then rendering it as an image to a memory stream, which I will then print. Issues with that are: - Multi-page printing will be a big headache. - Still have to use PrintDocument to print the memory stream, which is unsupported in a Windows Service (though it may work - haven't gotten that far with the prototype yet) - If the data coming across changes, I have to change the dataset, and the class that the data is being deserialized into. bad bad bad. Has anyone had to do anything remotely like this? Any advice? I already posed a question about printing HTML without user input, and after wasting about 3 days on that, I have come to the conclusion that it cannot be done, at least not with any freely available tool. All help is appreciated.
|c#|.net|windows|service|printing|
I am working on a project right now that involves receiving a message from another application, formatting the contents of that message, and sending it to a printer. Technology of choice is C# windows service. The output could be called a report, I suppose, but a reporting engine is not necessary. A simple templating engine, like StringTemplate, or even XSLT outputting HTML would be fine. The problem I'm having is finding a free way to print this kind of output from a service. Since it *seems* that it will work, I'm working on a prototype using Microsoft's RDLC, populating a local report and then rendering it as an image to a memory stream, which I will then print. Issues with that are: - Multi-page printing will be a big headache. - Still have to use PrintDocument to print the memory stream, which is unsupported in a Windows Service (though it may work - haven't gotten that far with the prototype yet) - If the data coming across changes, I have to change the dataset, and the class that the data is being deserialized into. bad bad bad. Has anyone had to do anything remotely like this? Any advice? I already posed a question about printing HTML without user input, and after wasting about 3 days on that, I have come to the conclusion that it cannot be done, at least not with any freely available tool. All help is appreciated. EDIT: We are on version 2.0 of the .NET framework.
I've asked this question to the forums on the Mootools website and one person said that my class selection was corrupted before an admin came along and changed my post status to invalid. Needless to say this did not help much. I then posted to a google group for mootools with no response. My question is why doesn't the 'enter', 'leave', 'drop' events fire for my '.drop' elements? The events for the .drag elements are working. <title>Untitled Page</title> <script type="text/javascript" src="/SDI/includes/mootools-1.2.js"></script> <script type="text/javascript" src="/SDI/includes/mootools-1.2-more.js"></script> <script type="text/javascript" charset="utf-8"> window.addEvent('domready', function() { var fx = []; $$('#draggables div').each(function(drag){ new Drag.Move(drag, { droppables: $$('#droppables div'), onDrop: function(element, droppable){ if(!droppable) { } else { element.setStyle('background-color', '#1d1d20'); } element.dispose(); }, onEnter: function(element, droppable){ element.setStyle('background-color', '#ffffff'); }, onLeave: function(element, droppable){ element.setStyle('background-color', '#000000'); } }); }); $$('#droppables div').each(function(drop, index){ drop.addEvents({ 'enter': function(el, obj){ drop.setStyle('background-color', '#78ba91'); }, 'leave': function(el, obj){ drop.setStyle('background-color', '#1d1d20'); }, 'drop': function(el, obj){ el.remove(); } }); }); }); </script> <form id="form1" runat="server"> <div> <div id="draggables"> <div class="drag"></div> <div class="drag"></div> <div class="drag"></div> <div class="drag"></div> <div class="drag"></div> <div class="drag"></div> <div class="drag"></div> <div class="drag"></div> <div class="drag"></div> <div class="drag"></div> </div> <div id="droppables"> <div class="drop"></div> <div class="drop"></div> <div class="drop"></div> <div class="drop"></div> <div class="drop"></div> <div class="drop"></div> </div> </div> </form>
How can I "unaccept" a drag in Flex?
|apache-flex|dragdrop|
Once I've called <code>DragManager.acceptDrag</code> is there any way to "unaccept" the drag? Say that I have a view which can accept drag and drop, but only in certain areas. Once the user drags over one of these areas I call <code>DragManager.acceptDrag(this)</code> (from a <code>DragEvent.DRAG_OVER</code> handler), but if the user then moves out of this area I'd like to change the status of the drag to not accepted and show the <code>DragManager.NONE</code> feedback. However, neither calling <code>DragManager.acceptDrag(null)</code> nor <code>DragManager.showFeedback(DragManager.NONE)</code> seems to have any effect. Once I've accepted the drag an set the feedback type I can't seem to change it. Just to make it clear: the areas where the user should be able to drop are not components or even display objects, in fact they are just ranges in the text of a text field (like the selection). Had they been components of their own I could have solved it by making each of them accept drag events individually. I guess I could create proxy components that float over the text to emulate it, but I'd rather not if it isn't necessary.
Here is a related discussion as to [**why String.Format is static**][1] that will highlight some reasons. [1]: http://stackoverflow.com/questions/23228/why-is-stringformat-static
When should a method be static?
|static|language-agnostic|
In addition, are there any performance advantages to static methods over instance methods? I came across the following recently: http://www.cafeaulait.org/course/week4/22.html I would be very interested in the feedback of the Stack Overflow community on this.
|language-agnostic|static|
In addition, are there any performance advantages to static methods over instance methods? I came across the following recently: http://www.cafeaulait.org/course/week4/22.html : > When should a method be static? > > 1. Neither reads from nor writes to instance fields > 2. Independent of the state of the object > 3. Mathematical methods that accept arguments, apply an algorithm to those > arguments, and return a value > 4. Factory methods that serve in lieu of constructors I would be very interested in the feedback of the Stack Overflow community on this.