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... |
|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 c... |
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;
@l... |
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 ... |
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 y... |
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 mig... |
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 ... |
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 netwo... |
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]* (w... |
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/librar... |
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 ... |
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:... |
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 ... |
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 p... |
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 avera... |
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 h... |
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 h... |
|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 h... |
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 ... |
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 ... |
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: [Cockpi... |
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 in... |
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 cod... |
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 cod... |
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... |
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 th... |
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.au... |
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.doubl... |
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 avera... |
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 gene... |
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... |
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.galli... |
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 i... |
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... |
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 l... |
**.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 wil... |
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... |
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) u... |
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... |
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... |
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.)
... |
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://twistedmat... |
|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 ... |
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 Windo... |
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... |
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]: ... |
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
... |
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 Sea... |
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 produ... |
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 ... |
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 smal... |
|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. |