instruction
stringlengths
0
30k
I am designing a new System and I have a lot of Interfaces that will grow over time with the system. What is the best practice to name this interfaces ISomethingV01 ISomethingV02 etc or same other way?
I am designing a new System and I have a lot of Interfaces that will grow over time with the system. What is the best practice to name this interfaces ISomethingV01 ISomethingV02 etc and I do this public interface ISomething{ void method(); } then I have to add method 2 so now what I do? public interface ISomethingV2:ISomething{ void method2(); } or same other way?
|versioning|interface|naming-guidelines|
Ideally, you shouldn't be changing your interfaces very often (if at all). If you do need to change an interface, you should reconsider its purpose and see if the original name still applies to it. If you still feel that the interfaces will change, and the interfaces changes are small (adding items) and you have control of the whole code base, then you should just modify the interface and fix all the compilation errors. If your change is a change in how the interface is to be used, then you need to create a separate interface (most likely with a different name) to support that alternative usage pattern. Even if you end up creating ISomething, ISomething2 and ISomething3, the consumers of your interfaces will have a hard time figuring out what the differences are between the interfaces. When should they use ISomething2 and when should they use ISomething3? Then you have to go about the process of obsoleting ISomething and ISomething2.
You can do this in one line, using the conditional operator and the fact that you can cast `null` to a nullable type (two lines, if you don't have a pre-existing int you can reuse for the output of `TryParse`): int unused; int? val = Int32.TryParse(stringVal, out unused) ? Int32.Parse(s) : (int?)null; @lomaxx's answer was posted while I was preparing mine, but his won't work - there is no one-argument overload of `Int32.TryParse()`
You can do this in one line, using the conditional operator and the fact that you can cast `null` to a nullable type (two lines, if you don't have a pre-existing int you can reuse for the output of `TryParse`): int tempVal; int? val = Int32.TryParse(stringVal, out tempVal) ? tempVal : (int?)null;
In my current application, I'm doing both. When the user identifies an image to attach to a record, I use ImageMagick to resize it to an appropriate size for display on screen (about 300x300 for my application) and store that in the database for ease of access, but then also copy the user's original file to a network share so that it's available for applications that require higher resolution (like printing). (There are a couple other factors involved as well: Navision will only display BMPs, so when I resize it I also convert to BMP for storage, and the database is replicated to remote sites where it's useful to be able to display the image. Printing is only done at the head office, so I don't need to replicate the original file.)
I would also add a check to see if the function exists: function doIt($callback) { if(function_exists($callback)) { $callback(); } else { // some error handling } }
Are you aware of the 'prove' utility (from App::Prove)? You can tell it to run all the tests recursively in a given directory, with or without verbosity, etc.
You should be able to do both if you implement the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.iscriptcontrol.aspx">IScriptControl</a> interface while also deriving from BaseValidator: public class YourControl : IScriptControl, BaseValidator To implement the IScriptControl interface means your control will also have to have the GetScriptReferences and GetScriptDescriptors methods.
Designing a new UI for a legacy WinForms MDI application
|c#|wpf|user-interface|silverlight|
I'm working on moving a client/server application created with C# and WinForms into the SOA/WPF/Silverlight world. One of the big hurdles is the design of the UI. My current UI is MDI driven and users rely heavily on child windows, having many open at the same time and toggling back and forth between them. What might be the best way to recreate the UI functionality in an MDI-less environment? (I've no desire to create MDI functionality on my own in WPF). Tabs? A list panel that toggles different controls?
Well what if I had an array that looked like this { {1, 2, 3}, {4, 5, 6, 7, 8, 9, 9, 9}, {5, 4, 3, 2} } How would GetLength(1) still know the length of each row?
Well what if I had an array that looked like this { {1, 2, 3}, {4, 5, 6, 7, 8, 9, 9, 9}, {5, 4, 3, 2} } How would GetLength(1) still know the length of each row? --- Basically what I want is.... **a way to find the number of elements in any given row**.
I am currently exploring the extent to which SharePoint can provide non-techie friendly yet reliable version control in a similar context. The preliminary result is "meh". Even in the case we come to a conclusion, it is already becoming clear that revision control requires quite an important shift in users' attitudes to document management. Now if this was for teams using Apple Macs, which I presume it isn't, I'd strongly recommend [Versions](http://www.versionsapp.com/), which is an extremely intuitive SVN client. This is the first and only software where I've seen revision control and its paradigm shifts being adopted easily by non-programmers.
The way I understand the question, you are asking for developer centric podcast. My personal number one is "Late Night Cocoa" from the Mac Developer Network followed by "Mac Developer Roundtable". Although I agree that every developer should probably listen to Steve Gibson's "Security Now!" (on Leo Laporte's TWiT network). For general tech stuff, check out other TWiT podcasts: "This week in Tech", "MacBreak Weekly", "MacBreack Tech", "Windows Weekly", "FLOSS Weekly" Coming soon: "MacBreak Dev" On a side note: relevant to some developers who think about becoming a Micro-ISV in the Apple Universe: "MacSB - Mac Software Business"
The way I understand the question, you are asking for developer centric podcast. My personal number one is *[Late Night Cocoa][1]* from the ***[Mac Developer Network][2]*** followed by *[Mac Developer Roundtable][3]*. Although I agree that every developer should probably listen to Steve Gibson's *[Security Now!][4]* (with Leo Laporte's ***[TWiT network][5]***). For general tech stuff, check out other TWiT podcasts: *[This week in Tech][6]*, *[MacBreak Weekly][7]*, *[MacBreack Tech][8]* (with ***[PixelCorps][11]***), *[Windows Weekly][9]* and *[FLOSS Weekly][10]* On a side note: relevant to some developers who think about becoming a Micro-ISV in the Apple Universe: *[MacSB - Mac Software Business][12]* [1]: http://mac-developer-network.com/podcasts/latenightcocoa/index.html [2]: http://mac-developer-network.com/ [3]: http://mac-developer-network.com/podcasts/macdeveloperroundtable/index.html [4]: http://www.grc.com/securitynow.htm [5]: http://thisweekintech.com/ [6]: http://thisweekintech.com/twit [7]: http://thisweekintech.com/mbw [8]: http://macbreaktech.com/ [9]: http://thisweekintech.com/ww [10]: http://thisweekintech.com/FLOSS [11]: http://www.pixelcorps.tv/ [12]: http://mac-developer-network.com/podcasts/macsb/index.html
I recently did this on my project using an idea similar to [Tyler's point 1](http://stackoverflow.com/questions/48087/select-a-random-n-elements-from-listt-in-c#48114). I was loading a bunch of questions and selecting five at random. Sorting was achieved using an [IComparer<T>](http://msdn.microsoft.com/en-us/library/8ehhxeaf.aspx). aAll questions were loaded in the a QuestionSorter list, which was then sorted using the [List<T>'s Sort function](http://msdn.microsoft.com/en-us/library/234b841s.aspx) and the first k elements where selected. private class QuestionSorter : IComparable<QuestionSorter> { public double SortingKey { get; set; } public Question QuestionObject { get; set; } public QuestionSorter(Question q) { this.SortingKey = RandomNumberGenerator.RandomDouble; this.QuestionObject = q; } public int CompareTo(QuestionSorter other) { if (this.SortingKey < other.SortingKey) { return -1; } else if (this.SortingKey > other.SortingKey) { return 1; } else { return 0; } } } Usage: List<QuestionSorter> unsortedQuestions = new List<QuestionSorter>(); // add the questions here unsortedQuestions.Sort(unsortedQuestions as IComparer<QuestionSorter>); // select the first k elements
This is very easy to do in java, and as stated above you can reach into the java.util.zip libraries from C#. For references see: [java.util.zip javadocs][1] <br> [sample code][2] I used this a while ago to do a deep (recursive) zip of a folder structure, but I don't think I ever used the unzipping. If I'm so motivated I may pull that code out and edit it into here later. [1]: http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/package-summary.html [2]: http://www.devx.com/getHelpOn/10MinuteSolution/20447
This is my take on it. I would say unit testing is the practice of writing software tests to verify that your real software does what it is meant to. This started with [jUnit](http://junit.org/) in the Java world and has become a best practice in PHP as well with [SimpleTest](http://simpletest.org/) and [phpUnit](http://www.phpunit.de/). It's a core practice of Extreme Programming and helps you to be sure that your software still works as intended after editing. If you have sufficient test coverage, you can do major refactoring, bug fixing or add features rapidly with much less fear of introducing other problems. It's most effective when all unit tests can be run automatically. Unit testing is generally associated with OO development. The basic idea is to create a script which sets up the environment for your code and then exercises it; you write assertions, specify the intended output that you should receive and then execute your test script using a framework such as those mentioned above. The framework will run all the tests against your code and then report back success or failure of each test. phpUnit is run from the Linux command line by default, though there are HTTP interfaces available for it. SimpleTest is web-based by nature and is much easier to get up and running, IMO. In combination with xDebug, phpUnit can give you automated statistics for code coverage which some people find very useful. Some teams write hooks from their subversion repository so that unit tests are run automatically whenever you commit changes. It's good practice to keep your unit tests in the same repository as your application.
I'd suggest against passing an integer between them, simply for purposes of readability and debugging. Say you're going through your logs and you see a bunch of 500 errors for DocumentType=4. Now you've got to go look up which DocumentType is 4. Or if one of the applications refers to a number that doesn't exist in the other, perhaps due to mismatched versions. It's a bit more code, and it rubs the static typing part of the brain a bit raw, but in protocols on top of HTTP the received wisdom is to side with legible strings over opaque enumerations.
I can only speak about .net, but if you have an ASP.net Webservice, you should be able to add an enumeration directly to it. When you then use the "Add Web Reference" in your Client Application, the resulting Class should include that enum But this is from the top of my head, i'm pretty sure i've done it in the past, but I can't say for sure.
What I did when working against a database of unknown performance was to measure turnaround time on my queries. I kept upping the thread count until turn-around time dropped, and dropping the thread count until turn-around time improved (well, it was processes in my environment, but whatever). There were moving averages and all sorts of metrics involved, but the take-away lesson was: just adapt to how things are working at the moment. You never know when the DBAs will improve performance or hardware will be upgraded, or perhaps another process will come along to load down the system while you're running. So adapt. Oh, and another thing: avoid process switches if you can - batch things up.
I have developed some classes with similar behavior, they all implement the same interface. I implemented a factory that creates the appropriate object and returns the interface. I am writing a unit test for the factory. All you get back is an interface to the object. What is the best way to test that the factory has worked correctly? I would like to know the answer in Java, but if there is a solution that crosses languages I would like to know it. What if the factory doesn't take input and returns an interface, like a plug in architecture? It seems your only option might be Class.isInstance(). Or is there a better way to test that kind of factory?
I have developed some classes with similar behavior, they all implement the same interface. I implemented a factory that creates the appropriate object and returns the interface. I am writing a unit test for the factory. All you get back is an interface to the object. What is the best way to test that the factory has worked correctly? I would like to know the answer in Java, but if there is a solution that crosses languages I would like to know it.
|java|unit-testing|tdd|
I have developed some classes with similar behavior, they all implement the same interface. I implemented a factory that creates the appropriate object and returns the interface. I am writing a unit test for the factory. All you get back is an interface to the object. What is the best way to test that the factory has worked correctly? I would like to know the answer in Java, but if there is a solution that crosses languages I would like to know it. Number 2. in the answer, would be done like the other answer? If so I will mark the other answer accepted as well and reword my question to adress both a factory where an interface is returned and you have no clue what type of concrete class implemented the interface, and the case where you do know what concrete class was used.
There are a lot of votes for Steve McConnell's Code Complete, but what about his [Software Project Survival Guide][1] book? I think they're both required reading but for different reasons. [1]: http://www.stevemcconnell.com/sg.htm
Regular expressions are not scary, but writing your own regexes to strip HTML is a sure path to madness (and it won't work, either). Follow the path of wisdom, and use one of the many good HTML-parsing libraries. Lucas' example is also broken because "sub" is not a method of a Python string. You'd have to "import re", then call re.sub(pattern, repl, string). But that's neither here nor there, as the correct answer to your question does not involve writing any regexes.
Displaying ad content from Respose.WriteFile()/ Response.ContentType
|c#|webdevelopment|system.web.httpresponse|
How would one display any add content from a "dynamic" aspx page? Currently I am working on using the System.Web.HttpResponse "Page.Response" to write a file that is stored on a web server to a web request. This would allow people to hit a url to the type http://www.foo.com?Image=test.jpg and have the image display in their browser. So as you may know this revolves around the use of Response.ContentType. By using Response.ContentType = "application/octet-stream"; I am able to display images of type gif/jpeg/png (all i have tested so far), bit tryung to display .swf or .ico files gives me a nice little error. using Response.ContentType = "application/x-shockwave-flash"; I can get flash files to play, but then the images are messed. So how do i **easily** choose the contenttype?
This may be a bug in S3Fox, because it is generally able to delete items recursively. However, I'm not sure if I've ever tried to delete a whole bucket and its contents at once. The [JetS3t][1] project, as mentioned by Stu, includes a Java GUI applet you can easily run in a browser to manage your S3 buckets: [Cockpit][2]. It has both strengths and weaknesses compared to S3Fox, but there's a good chance it will help you deal with your troublesome bucket. Though it will require you to delete the objects first, then the bucket. Disclaimer: I'm the author of JetS3t and Cockpit [1]: http://jets3t.s3.amazonaws.com/index.html [2]: http://jets3t.s3.amazonaws.com/applications/cockpit.html
you can compile a directx apps in linux, but not launching it straight away. if you use a crosscompilator that makes windows exe and point to the windows sdk and directx sdk.
"Debugging the Development Process: Practical Strategies for Staying Focused, Hitting Ship Dates, and Building Solid Teams" by Steve Maguire. No-non-sense, down-to-earth, entertaining, profound. [ http://stackoverflow.com/questions/559/what-books-would-you-recommend-for-a-beginning-software-developer#1150 ]
I had this exact problem. When I looked back over some old code for a vertical splitter thinking I had an easy answer, it turned out that I had build and loaded my own resource: <pre> SetCursor( LoadCursor( ghInstance, "IDC_SPLITVERT" )); </pre> I vaguely remember investing some considerable time and effort into find the system way of doing it, so (my guess) is that there is not a system ICON readily available to do the job, so you are better off rolling your own. This is one of those times when I would like to be wrong, as I would have liked there to be a system icon for this job.
i am thinking to run multiple application similar to [ypops][1]. [1]: http://ypopsemail.com/
In programming, a "magic number" is a value that should be given a symbolic name, but was instead slipped into the code as a literal, usually in more than one place. It's bad for the same reason SPOT (Single Point of Truth) is good: If you wanted to change this constant later, you would have to hunt through your code to find every instance. It is also bad because it might not be clear to other programmers what this number represents, hence the "magic". Eliminating magic numbers isn't always good, however. That's where Cobol came from.
In programming, a "magic number" is a value that should be given a symbolic name, but was instead slipped into the code as a literal, usually in more than one place. It's bad for the same reason SPOT (Single Point of Truth) is good: If you wanted to change this constant later, you would have to hunt through your code to find every instance. It is also bad because it might not be clear to other programmers what this number represents, hence the "magic". People sometimes take magic number elimination further, by moving these constants into separate files to act as configuration. This is sometimes helpful, but can also create more complexity than it's worth.
netstat -aon | find /i "listening"
This is quite common. Unless you address this issue up front when you enter into a license you are at the mercy of the licensor when a transaction like you describe happens. The licensor may or may not have a policy to come along and charge a fee, but unless the matter is addressed in your license, they will have the legal ability to do so. The reason is this: a license is a legal contract with a specific legal entity (your employer in this case) and grants no rights in the software to anyone else (they buyer company in your example). Now your employer could have insisted on a clause in the original agreement saying that the license could be freely transferred to a possible future buyer without fee, but without such a clause, the licensor can do what they wish. Including charging the 25% fee. This is one reason that many companies have their licenses routinely reviewed by legal counsel who are knowledgeable about software licensing.
The "__file__" attribute works for both the file containing the main execution code as well as imported modules <http://pyref.infogami.com/__file__>
+1 for Monaco ![alt text][1] Just beautiful and I find I can read it for hours on end. [1]: http://img.skitch.com/20080908-nmjji28uerreqpprs1h86gxna9.png
I think the answer is really going to be up to your users -- I'd set up some prototypes with multiple paradigms and let them provide some input. The last thing you want to do is introduce a new UI paradigm without having any end-user input. Tabs are really popular now, but don't allow side-by-side viewing, so if that is a requirement you may want to go with more of an outlook-style setup, with multiple panels that can be activated, hidden and resized. One thing that you might want to do is to code your app as a composite UI, where each view is built independently from its container (be it a child window, tab or accordion, etc.), and is just "dropped in" in the designer. That will protect you from when the users change their minds about the navigation paradigm in the future.
C will do no such thing. It will silently overflow and lead to a possibly incorrect comparison. You can up-cast yourself, but it will not be done automatically.
I believe this might be platform specific. Check the C documentation on how overflows are handled... Ah, yes, and the upcast will not happen automatically...
How do I format a number in java?
|java|
How do I format a number in java? What are the "Best Practices"? Will I need to round a number before I format it? "32.302342342342343" formatted to "32.30" ".7323" formatted to "0.73" etc.
>If I were to stick with Windows Forms, what are all the tricks to achieving a font-size-independent layout that can survive the user setting his fonts large, or setting the display to 120 DPI? For one, [AutoScaleMode][1] may be your friend. [1]: http://msdn.microsoft.com/en-us/library/system.windows.forms.autoscalemode.aspx
From [this thread][1], there are different ways to do this: double r = 5.1234; System.out.println(r); // r is 5.1234 int decimalPlaces = 2; BigDecimal bd = new BigDecimal(r); // setScale is immutable bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); r = bd.doubleValue(); System.out.println(r); // r is 5.12 ---------- f = (float) (Math.round(n*100.0f)/100.0f); ---------- DecimalFormat df2 = new DecimalFormat( "#,###,###,##0.00" ); double dd = 100.2397; double dd2dec = new Double(df2.format(dd)).doubleValue(); // The value of dd2dec will be 100.24 The DecimalFormat() seems to be the most dynamic way to do it, and it is also very easy to understand when reading others code. [1]: http://bytes.com/forum/thread16212.html
What I did when working against a database of unknown performance was to measure turnaround time on my queries. I kept upping the thread count until turn-around time dropped, and dropping the thread count until turn-around time improved (well, it was processes in my environment, but whatever). There were moving averages and all sorts of metrics involved, but the take-away lesson was: just adapt to how things are working at the moment. You never know when the DBAs will improve performance or hardware will be upgraded, or perhaps another process will come along to load down the system while you're running. So adapt. Oh, and another thing: avoid process switches if you can - batch things up. ---------- Oh, I should make this clear: this all happened at run time, not during development.
Any experiences with Protocol Buffers?
|database|xml|
I was just looking through some information about Google's [protocol buffers][1] data interchange format. Has anyone played around with the code or even created a project around it? I'm currently using XML in a Python project for structured content created by hand in a text editor, and I was wondering what the general opinion was on Protocol Buffers as a user-facing input format. The speed and brevity benefits definitely seem to be there, but there are so many factors when it comes to actually generating and processing the data. [1]: http://code.google.com/apis/protocolbuffers/
I would still use enumeration internally but would expect consumers to pass me only the name (use **Enum.Parse** to parse it), not the numeric value itself.
I would still use enumeration internally but would expect consumers to pass me only the name, not the numeric value itself. just some silly example to illustrate: public enum DocumentType { Invoice, Contract, WorkOrder, SignedWorkOrder } [WebMethod] public void UploadDocument(string type, byte[] data) { DocumentType docType = (DocumentType)Enum.Parse(typeof(DocumentType), type); }
How can I get at the matches when using preg_replace in PHP?
|php|regex|
I am trying to grab the capital letters of a couple of words and wrap them in spans. I am using preg_replace, but it's not outputting anything. preg_replace("/[A-Z]/", "<span class=\"initial\">$1</span>", $str)
You need to put the match in parentheses, like this: preg_replace("/([A-Z])/", "<span class=\"initial\">$1</span>", $str)
+1 for print_r(). Use it to dump out the contents of an object or variable. To make it more readable, do it with a pre tag so you don't need to view source. echo '<pre>'; print_r($arrayOrObject); Also var_dump($thing) - this is very useful to see the type of subthings
The value of 'false' is true. You need to remove the quotes: $canMerge = ($condition1 && $condition2) ? true : false;
I like [MbUnit][1], er, [Gallio][2]. Most importantly to me is having good tools support inside Visual Studio. For that I use [Resharper][3], which has an [MbUnit test runner][4]. A lot of folks seem to like [TestDriven.NET][5] as their test runner as well. [1]: http://www.mbunit.com/ [2]: http://www.gallio.org/ [3]: http://www.jetbrains.com/resharper/index.html [4]: http://code.google.com/p/mbunit-resharper/ [5]: http://www.testdriven.net/overview.aspx
I think it really depends on your job. If you are a developer in a large company with dedicated DBAs then maybe you don't need to know much, but if you are in a small company then it may be really helpful knowing more about databases. In small companies you may wear more than one hat. It cannot hurt to know more in any situation.
If you are uncertain about how to best access the database you should be using tried and tested solutions like the application blocks from Microsoft - [http://msdn.microsoft.com/en-us/library/cc309504.aspx][1]. They can also prove helpful to you by examining how that code is implemented. [1]: http://msdn.microsoft.com/en-us/library/cc309504.aspx "Data Access Application Block"
I think these are the most important things (from most important to least, IMO): - **SQL (obviously)** - It helps to know how to at least do basic queries, aggregates (sum(), etc), and inner joins - **Normalization** - DB design skills are an major requirement - **Locking Model/MVCC** - Its nice to have at least a basic grasp of how your databases manage row locking (or use MVCC to accomplish similar goals with optimistic locking) - **ACID compliance, Txns** - Please know how these work and interact - **Indexing** - While I don't think that you need to be an expert in tablespaces, placing data on separate drives for optimal performance, and other minutiae, it does help to have a high level knowledge of how index scans work vs. tablescans. It also helps to be able to read a query plan and understand why it might be choosing one over the other. - **Basic Tools** - You'll probably find yourself wanting to copy production data to a test environment at some point, so knowing the basics of how to restore/backup your database will be important. Fortunately, there are some great FOSS and free commercial databases out there today that can be used to learn quite a bit about db fundamentals.
**.NET Strings are Immutable** Therefore having an instance method makes absolutely no sense. String foo = new String(); foo.Format("test {0}",1); // Makes it look like foo should be modified by the Format method. string newFoo = String.Format(foo, 1); // Indicates that a new string will be returned, and foo will be unaltered.
I personally use both stacks and the reason really depends on the client. If a client can support LAMP, it is certainly cheaper but it is important what the client or company can support. As an independent developer I would not recommend LAMP when all of the client's assets exist on Windows. It is really a comfort level as either platform works equally well to solve any problem.
I used the MVC framework to build a small site, and I found myself frequently frustrated by the tag soup views, and lack of the server controls I had come to love. I went back to using webforms. WebForms, once mastered, are great...They just take a very long time to learn all the tricks.
It certainly can't hurt to be familiar with relational database theory, and have a good working knowledge of the standard SQL syntax, as well as knowing what stored procedures, triggers, views, and indexes are. Obviously it's not terribly important to learn the database-specific extensions to SQL (T-SQL, PL/SQL, etc) until you start working with that database. I think it's important to have a basic understand of databses when developing database applications just like it's important to have an understanding of the hardware your your software runs on. You don't have to be an expert, but you shouldn't be totally ignorant of anything your software interacts with. That said, you probably shouldn't need to do much SQL as an application developer. Most of the interaction with the database should be done through stored procedures developed by the DBA, I'm not a big fan of including SQL code in your application code. If your queries are in stored procedures, then the DBA can change the implementation of the stored procedure, or even the database schema, and so long as the result is the same it doesn't require any changes to your application code.
I looked at Hadoop and Hbase and as **Sean** said, I soon realised it didn't give me what I actually wanted, which was a clustered JDBC compliant database. I think you could be better off using something like [C-JDBC][1] or [HA-JDBC][2] which seem more like what I was was after. (Personally, I haven't got farther with either of these other than reading the documentation so I can't tell which of them is any good, if any.) [1]: http://c-jdbc.objectweb.org/ [2]: http://ha-jdbc.sourceforge.net/
Use [TCPView][1] if you want a GUI for this. It's the old Sysinternals app that Microsoft bought out. [1]: http://technet.microsoft.com/en-us/sysinternals/bb897437.aspx
If you'd like to use a GUI tool to do this there's [SysInternals TCPView][1]. [1]: http://technet.microsoft.com/en-us/sysinternals/bb897437.aspx
C:\> netstat -a -b (add -n to stop it trying to resolve hostnames, which will make it a lot faster)
C:\> netstat -a -b (add -n to stop it trying to resolve hostnames, which will make it a lot faster) ***Edit:*** +1 for Dane's recommendation for [TCPView][1]. Looks very useful! [1]: http://technet.microsoft.com/en-us/sysinternals/bb897437.aspx
Are you sure that JMF is right for you? Unfortunately, it is not in particularly good shape. Unless you are already committed to JMF, you very well may want to investigate alternatives. Wikipedia has a decent overview at **[en.wikipedia.org/wiki/Java_Media_Framework][1]** > Many JMF developers have complained that it **supports few codecs and formats in modern use**. Its all-Java version, for example, cannot play MPEG-2, MPEG-4, Windows Media, RealMedia, most QuickTime movies, Flash content newer than Flash 2, and **needs a plug-in to play the ubiquitous MP3 format**. While the performance packs offer the ability to use the native platform's media library, they're only offered for Linux, Solaris and Windows. Furthermore, **Windows-based JMF developers can unwittingly think JMF provides support for more formats than it does**, and be surprised when their application is unable to play those formats on other platforms. > Another knock against JMF is Sun's seeming abandonment of it. The **API has not been touched since 1999**, and the last news item on JMF's home page was posted in November 2004. > While JMF is built for extensibility, **there are few such third-party extensions**. > Furthermore, **editing functionality in JMF is effectively non-existent**, which makes a wide range of potential applications impractical. [1]: http://en.wikipedia.org/wiki/Java_Media_Framework
The distro which is most developer friendly, in my opinion, is [Gentoo][1]. Since you compile everything from scratch, you choose exactly what makes up your system. Java can be installed very easily, so you could potentially just have a [window environment][2] and Java installed (aside from the standard tool chain.) [1]: http://gentoo.org [2]: http://xfce.org
Python includes a [telnet client][1], but not a telnet server. You can implement a telnet server using [Twisted][2]. [Here's an example][3]. As for hooking these things together, that's up to you. [1]: http://www.python.org/doc/lib/module-telnetlib.html [2]: http://twistedmatrix.com [3]: http://twistedmatrix.com/pipermail/twisted-python/2004-August/008335.html
|c#|system.web.httpresponse|
|c#|
How would one display any add content from a "dynamic" aspx page? Currently I am working on using the System.Web.HttpResponse "Page.Response" to write a file that is stored on a web server to a web request. This would allow people to hit a url to the type http://www.foo.com?Image=test.jpg and have the image display in their browser. So as you may know this revolves around the use of Response.ContentType. By using Response.ContentType = "application/octet-stream"; I am able to display images of type gif/jpeg/png (all i have tested so far), bit trying to display .swf or .ico files gives me a nice little error. using Response.ContentType = "application/x-shockwave-flash"; I can get flash files to play, but then the images are messed. So how do i **easily** choose the contenttype?
Yes, Windows Forms dates back to before generics in .Net
You could try using the DataGridView control. To see an example, load an XML file in DevStudio and then right-click on the XML and select "View Data Grid". You'll need to read the API documentation on the control to use it. Skizz
May not be "best practice" advice here... but based on real life needs and expirience: we have distributed system, 60 boxes running each 10 clients all do task X, and they need to take the next task from a "Q". The Q is being feed from one other "client"... We had used inter process communication, we used the Windows Q (not SQL Server), we tried service broker... It just doesn't work in the long term because you are giving way the control of your application to Microsoft. It works great as long as your needs are satisfied. it becomes hell when you need something not supported. The best solution for us was: Use a SQL Database as the "Q". Don't invent the wheel there, sicne you will make mistakes (locks). There is info out there on how to do it, it is very easy and we handled over 200K messages per 24H (with 60x10 = 600 concurrent reads and writes to the Q). Some reasons why MSMQ doesn't work: 1. When you need to change the logic of the Q to not FIFO, but something like "the oldest RED message" or "the oldest BLUE message" you can;t do it. (I know what people will say, you can do it by having a RED Q and a BLUE Q.. .But what if the number/types of Ques is dynamic based on the way the application is administrated and changes daily?) 2. It adds a point of failue and deployment nighmare (the Q is a point of failure and you need to deal with setting the right permissions on all boxes to read/write messages etc' in Enterprise software you pay in blood for these type of things). SQL server... all clients are writing/reading already from the DB, it is just one more table..
May not be "best practice" advice here... but based on real life needs and expirience: we have distributed system, 60 boxes running each 10 clients all do task X, and they need to take the next task from a "Q". The Q is being feed from one other "client"... We had used inter process communication, we MSMQ, we tried service broker... It just doesn't work in the long term because you are giving away the control of your application to Microsoft. It works great as long as your needs are satisfied. it becomes hell when you need something not supported. The best solution for us was: Use a SQL Database table as the "Q". Don't invent the wheel there, snce you will make mistakes (locks). There is info out there on how to do it, it is very easy and we handled over 200K messages per 24H (with 60x10 = 600 concurrent reads and writes to the Q). That is in addition to the same SQL server handling the rest of the application stuff... Some reasons why MSMQ doesn't work: 1. When you need to change the logic of the Q to not FIFO, but something like "the oldest RED message" or "the oldest BLUE message" you can;t do it. (I know what people will say, you can do it by having a RED Q and a BLUE Q.. .But what if the number/types of Ques is dynamic based on the way the application is administrated and changes daily?) 2. It adds a point of failure and deployment nightmare (the Q is a point of failure and you need to deal with setting the right permissions on all boxes to read/write messages etc' in Enterprise software you pay in blood for these type of things). SQL server... all clients are writing/reading already from the DB, it is just one more table..
I agree with [Garo Yeriazarian][1], changing interface is a serious decision. Also, if you want to promote usage of new version of interface you should mark old version as obsolete. In .NET you can add [ObsoleteAttribute][2]. [1]: http://stackoverflow.com/questions/45123/interfaces-and-versioning#45138 [2]: http://msdn.microsoft.com/en-us/library/system.obsoleteattribute.asp
Take a look at NotesSQL:<br/> http://www.ibm.com/developerworks/lotus/products/notesdomino/notessql/
I think you're overrusing interfaces. Meyer and Martin told us: "Open for extension but closed for modification!" and then Cwalina (et al) reiterated: From Framework Design Guidelines... > In general, classes are the preferred > construct for exposing abstractions. > The main drawback of interfaces is > that they are much less flexible than > classes when it comes to allowing for > evolution of APIs. Once you ship an > interface, the set of its members is > fixed forever. Any additions to the > interface would break existing types > implementing the interface. > > A class offers much more flexibility. > You can add members to classes that > have already shipped. As long as the > method is not abstract (i.e., as long > as you provide a default > implementation of the method), any > existing derived classes continue to > function unchanged. ![alt text][1] [1]: http://blogs.msdn.com/blogfiles/fxcop/WindowsLiveWriter/WhatdoyouwanttoseeinthesecondeditionofFr_C50F/FrameworkDesignGuidelines_3.jpg
How to develop catagories of controllers in MVC Routing?
|asp.net-mvc|routes|controller|
I'm looking for some examples or samples of routing for the following sort of scenario: The general example of doing things is: {controller}/{action}/{id} So in the scenario of doing a product search for a store you'd have: public class ProductsController: Controller { public ActionResult Search(string id) // id being the search string { ... } } Say you had a few stores to do this and you wanted that consistently, is there any way to then have: {category}/{controller}/{action}/{id} So that you could have a particular search for a particular store, but use a different search method for a different store? (If you required the store name to be a higher priority than the function itself in the url) Or would it come down to: public class ProductsController: Controller { public ActionResult Search(int category, string id) // id being the search string { if(category == 1) return Category1Search(); if(category == 2) return Category2Search(); ... } } It may not be a great example, but basically the idea is to use the same controller name and therefore have a simple URL across a few different scenarios, or are you kind of stuck with requiring unique controller names, and no way to put them in slightly different namespaces/directories? Edit to add: The other reason I want this is because I might want a url that has the categories, and that certain controllers will only work under certain categories. IE: /this/search/items/search+term <-- works /that/search/items/search+term <-- won't work - because the search controller isn't allowed.
class Producer implements Runnable { private final BlockingQueue queue; Producer(BlockingQueue q) { queue = q; } public void run() { try { while (true) { queue.put(produce()); } } catch (InterruptedException ex) { ... handle ...} } Object produce() { ... } } class Consumer implements Runnable { private final BlockingQueue queue; Consumer(BlockingQueue q) { queue = q; } public void run() { try { while (true) { consume(queue.take()); } } catch (InterruptedException ex) { ... handle ...} } void consume(Object x) { ... } } class Setup { void main() { BlockingQueue q = new SomeQueueImplementation(); Producer p = new Producer(q); Consumer c1 = new Consumer(q); Consumer c2 = new Consumer(q); new Thread(p).start(); new Thread(c1).start(); new Thread(c2).start(); } } This example was taken from the [JDK 1.6 docs of `BlockingQueue`][1]. So You can see that you are doing it the right way. Here's the quote which tells you that it have to work: > Memory consistency effects: As with > other concurrent collections, actions > in a thread prior to placing an object > into a BlockingQueue happen-before > actions subsequent to the access or > removal of that element from the > BlockingQueue in another thread. [1]: http://java.sun.com/javase/6/docs/api/java/util/concurrent/BlockingQueue.html
Non-overloaded, non-inherited static methods (like Class.b(a,c)) that take an instance as the first variable are semantically equivalent to a method call (like a.b(c)) so the platform team made an arbitrary, aesthetic choice. (Assuming it compiles to the same CIL, which it should.) The only way to know would be to ask them why. Possibly they did it to keep the two strings close to each other lexigraphically, i.e. String.Format("Foo {0}", "Bar"); instead of "Foo {0}".Format("bar"); You want to know what the indexes are mapped to; perhaps they thought that the ".Format" part just adds noise in the middle. Interestingly, the ToString method (at least for numbers) is the opposite: number.ToString("000") with the format string on the right hand side.
Why is Peer-to-Peer programming a hard topic to obtain good research for?
|p2p|language-agnostic|networking|
After reading a bit more about how Gnutella and other P2P networks function, I wanted to start my own peer-to-peer system. I went in thinking that I would find plenty of tutorials and language-agnostic guidelines which could be applied, however I was met with a vague simplistic overview. I could only find very small, precise P2P code which didn't do much more than use client/server architecture on all users, which wasn't really what I was looking for. I wanted something like Gnutella, but there doesn't seem to be any articles out in the open for joining the network.
|language-agnostic|networking|vague|p2p|
> Why the choice of NHibernate over > anything else? It's a very powerful tool, and is (relatively) easy to learn. It takes away all the monotony and repetitiveness of manually implementing object-relational mapping.