Tag Info

Hot answers tagged

5

This is not an answer, and somewhat unrelated to the point, but it's too long to be a comment. To be fair, your first example is not ideal. 1) you are creating a new category before checking if one already exists. var category = new PlacedCategory(); 2) your check for an exsiting category iterates twice over the collection, using Any and First. This is ...


5

First of all, a simplification: all real numbers are a subset of complex numbers, so just do everything with complex numbers. Secondly, why isn't Root supported by ComplexNumber? If you're supporting complex numbers, then you can take the root of any number, including negative or complex ones. It all just becomes vector multiplication. So if it's all ...


4

Almost all of them! Now, this does depend on the type of game of course, but surprising as it may seem, most mechanics do need to be run on the client. Note that they only need to be run on the client. The server must always have the final say. I'm talking about a simulation. Physics are the most obvious case of all. If you jump, the server may receive ...


4

There isn't a catchy name for it, but Clean Code devotes a lot of space to it: Functions should do one thing. They should do it well. They should do it only. It's an example of a function that does more than one thing, at more than one level of abstraction. It's doing both the more abstract operation of a GetOrAdd as well as the more concrete ...


4

You're doing this backwards. Forget about the design patterns for awhile. Just build your calculator program. Build it from scratch, and just design it however it is intuitive to you. Think about it for a few minutes, come up with a few ideas, then roll with it, start to finish. While you are trying to implement your calculator, you might not design it ...


3

In my opinion Actions should be relatively small and delegate work to other objects. Actions should (again, in my opinion) simply be responsible for the following: Receiving the request Delegate work to other objects Return the result in the correct format If you do this then unit testing becomes much easier through the use of mock objects and Dependency ...


3

In my applications I have always separated things out, with different models for the database (Entity Framework) and MVC. I have separated these out into different projects too: Example.Entities - contains my entities for EF and the DB context for accessing them. Example.Models - contains MVC models. Example.Web - web application. Depends on both ...


2

You can use SQL Server to directly import CSV files without needing to go through Excel to perform "data clean up". You have several methods to import data: T-SQL's Bulk Insert command to load a CSV file. A good example is shown in Import CSV file into SQL Server on StackOverflow. SQL Server Management Studio which can be automated using SSIS. Importing ...


1

You can't do it using exactly this syntax, because generic parameters can't change what interfaces does your class implement (i.e. you can't write something like class Hub<T> : T). I can see two alternative ways to do this (there are probably others): A simple approach using lambdas Your Hub class would have a method like void ...


1

If a method is too large to effectively unit test- meaning it is most likely doing too many things for one method- then there are two approaches you can take: Split the method into several methods to be called sequentially Abstract parts of its functionality behind other methods In your question you seem to focus on 1, but most of the time, 2 will be the ...


1

I'll take a different approach actually. I'll suggest you use a strategy pattern (pseudo code - been a while since I used C#). class CalculatorContext { private List<Number> numberHistory; private Number currentDisplay; private List<Operation> commandHistory; private Operation currentCommand; public void evaluateAnswer(Operation ...



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