Tag Info

Hot answers tagged

7

There is a fundamental difference here. In one case you say, "I'm going to just assume this is an int", and in the former, you ask the reader to give you an int. If the value is already an int, I would not expect any difficulty. However, what happens when the value is a Int64? You're casting it to an int which is only 4 bytes long. You may get ...


6

You original question seemed to reflect a misconception - one of top 10 false assumptions about OO: the belief that object orientation will imply more code reuse and less duplicated code. That is a fallacy! If you have devs who care for DRY code, care for reuse and who have learnt and understood OO principles, they can use the latter to build better, more ...


5

You are both right. You don't want to lose the stack trace, but you may want to catch the lower level exception. Don't wrap the exception if it isn't adding information. I would call your ExceptionManager and TreatException a bit of a code smell - they are trying too hard to centralize exception handling. To re throw without losing the stack trace: ...


5

IndexOutOfRangeException and NullReferenceException should be thrown by the runtime. If method, which includes an indexer, validates its parameters, it should throw ArgumentOutOfRangeException and ArgumentNullException instead. The built in collections, such as List<T> do this: Exceptions: ArgumentOutOfRangeException -- index is less than 0. ...


5

For a property that with string values like that, I would have: List<string> KnownHidScanners = new List<string>(); However, if you're going to expose this property externally as an API, there is: ICollection<string> KnownHidScanners = new List<string>(); or more appropriately is to create your own type that inherits from ...


5

If you have a lot of options, figure out if you can: reduce the number. How about making an assumption instead of making something configurable? group the options together. See this answer to Is a single config object a bad idea?: If you need to change the config class you may have to visit every instance in which it is used and check that you haven't ...


4

You might be best served by letting the apps pull the information rather than pushing it out -- that is a much simpler model as all you need to do is expose an API. The default choice in 2014 is probably an RESTful ASP.NET web api but there are tons of options depending on what you are doing. As for the push model, MSMQ is a pretty raw tool but it is ...


3

The quality of speech recognition depends on many parameters: Microphone: as you noted, a headset microphone is better than the one in your laptop. Studio microphones will give the best results, I imagine. Environment: you'll have hard time making speech recognition work in a noisy environment compared to a quiet one (ideally a studio). Pronunciation: for ...


3

What about approaching the problem from the other side. You have a class, that represents that nice flow diagram of yours and this flow diagram creates "events" based on transitions. Those events then can be represented as either an interface or events: public interface IFileProcessor { void HandleFile(string fileName, Stream data); void ...


3

With modern .NET / C# we try to use generics. Check out System.Collections.Generic namespace I recommend List<T> until you find something it doesn't do for you. If you need random access of more than 3 values, go with a Dictionary<K,T> For a small number of values where you always know where they are, you can use Tuples (such as a 3D ...


3

One solution would be to publish the information via UDP. Open a specific port for broadcasting, send your data. There is nothing else to do on the provider/server side. On the client side, open the same port for receiving. The only downside that I am aware of with this method is that if you miss the broadcast message, you will never see it again. There is ...


3

SignalR might be a good candidate if you don't need guaranteed delivery, and you're simply looking to periodically send relatively small amounts of data to/from N* clients and servers (e.g. real-time dashboard, instant messaging, multiplayer game, etc...). It can also scale quite well using backplanes (currently supports Redis, Azure Service Bus, SQL Server, ...


3

I'd avoid having separate code bases. All that branching and merging creates lots of unnecessary maintenance work. Even worse when they get out of sync it becomes hard to determine which differences were intentional and which by mistake. I prefer replacing #if preprocessor directives by ordinary if statements, that way all variants of the code need to ...


1

It depends if your versioning problem is a compile-time or run-time problem. For instance, you might want to be able to support a legacy message format in your API. That's a run-time problem because both code paths are still available within your application and can be called arbitrarily. It requires a run-time solution: DI, ifs, delegates, etc. They are ...


1

You don't need to specify the interface again since the base class already implements it, it is redundant to add it again but it shouldn't harm anything either. I also don't know why they are explicitly implementing the interface instead of overriding the existing virtual methods which already implement the interface.


1

Actually, I would go with a third option. Retrieve the column ordinal up-front and use the ordinal overloads. In any case where you have multiple rows, it saves work: var ord_field1 = dr.GetOrdinal("field1"); while(dr.Read()) { ... var field1 = dr.GetInt32(ord_field1); ... }


1

Okay, in the meantime I've invested additional time and made my own study on the topic. Findings: checking through Object inspector how properties containing word "Items" are declared in existing libraries reveals somewhat a surprise – I found every form: array, collection, list and custom types dominant types are these two: collections (generic or ...


1

I've been using Rebus which makes it pretty simple to push messages between applications. It is a .NET library that sits as a layer on top of an underlying transport layer, which could be MSMQ, RabbitMq, or something else. It does support publish/subscribe. In the case of MSMQ, this is simply implemented that Rebus handles publishing the message to multiple ...


1

Whether it's applicable to your specific scenario is a different question entirely, but writing to a text file and reading it from the other applications is probably the 'simplest' way to transfer data.



Only top voted, non community-wiki answers of a minimum length are eligible