New answers tagged

5

Besides the fact that in your current state the code would not work, because dum would be null, you cannot mock a private attribute of a class unless you have an access to it using some public method. How to do it? 1. You need to change the Class1 class signature so that the IDummyInterface1 is passed as a parameter, be it in a constructor or a method ...


2

A SQLServer Connection can be shared by multiple tasks executing in parallel, e.g. threads in a C# program or requests in an app server. But most use scenarios would require you to synchronize access to the Connection. A task will have to wait for the connection if another task is using it. By the time you build a shared connection mechanism that does not ...


1

Usually an enterprise application server would have a datasource configurable through which an API could make requests. For example, WebSphere servers have a datasource which can be called via a defined JNDI name from a persistence framework (JPA, Hibernate, ...) within EJBs which handle threading on their own. So yes. However, I would highly recommend ...


1

I do not know the pattern name (but it's probably using the Reflection pattern, see below), but many Web frameworks natively implement what your are trying to do here. For example if you look at Ruby on Rails, ActiveRecord and Mongoid are the components used to represent a Database entity, and programmers usually implement their model like this : class ...


1

This sounds like combination of strategy and composite patterns. Individual validators are strategy pattern. Then, composite is used to invoke multiple strategies as single one.


2

Primary Constructors would have helped, but they were pulled from C# 6. You could use certain IOC container black magic to make it look neater. But neither remove the underlying problem: your class is awkward because it has a bunch of dependencies. If it has a bunch of dependencies, it's probably trying to do too much, since few problems require 4 ...


0

From the code it looks like it should work. Spinning off queued threads to the thread pool from an event listener should not cause issues (and I use a similar pattern is some of my code). You will want to stress test the code to make sure that through put is enough to keep up and I would read up on error handling in multi threaded code ...


1

Interfaces are required in good quality implementations of MVP for the same reason they are required in all good "OO" designs: They help reduce coupling They discourage inheritance (which further reduces coupling) Arguably most importantly, they simplify unit test writing


0

Ignoring the issues you have in your team, it seem that the first one to address is to debug the code matching what is in production. Otherwise you might be chasing a bug that was already fixed in the code you have in your "Source control". As this is .NET you could easily "decompile" the production binaries to compare the code with what you have. It's not ...


0

There is a problem: IEEE754 defines relational operations and equality in a way that is well-suited to numerical applications. It is not well-suited to sorting and hashing. So if you want to sort an array based on numerical values, or if you want to add numerical values to a set or use them as keys in a dictionary, you either declare that NaN values are not ...


5

I would argue that the IEEE behavior is correct. NaNs are not equivalent to one another in any way; they correspond to ill-defined conditions where a numeric answer isn't appropriate. Beyond the performance benefits that come from using IEEE arithmetic that most processors support natively, I think there's a semantic problem with saying that if isnan(x) ...


2

You could do that. But as mentioned by Robert in the comments you could avoid a lot of trouble by using a library, such as Lucene. In your case (.NET) you should pick the Lucene.net port.


3

In my opinion, the main reason this feature is not available due to the language designers not being required to implement it or not seeing point in doing that since this can be already achieved with lambdas in a sane manner. The feature is most probably technically possible, since all expressions can be written as lambdas The adoption would mean that each ...


1

We already know that the expression tree generation mechanism is able to generate an expression tree for any arbitrary expression, because it's able to generate an expression tree for any arbitrary expression within a lambda. So it's clear that technical limitations are not the problem. The most likely answer is that it was used only set up for automatic ...


0

I would say (5) is the one you need to fix first. If you don't know which code is running in production, you have no safe way of reproducing and fixing problems. This makes any other change you introduce dangerous, since it might cause problems you cannot foresee and cannot reproduce. You may need to do some detective work and perhaps reverse engineering to ...


1

What you want to do is called a three-way merge. Basically, you take the original before the branch, and the end result of the two branches. You take the differences between both branches and the original, and merge those diffs together. How do you merge the diffs? That's the tricky part, but here are several projects which implement the algorithm for ...


4

First, all the above... ditto. Some heuristics: Use source control on your development computer. It's the best thing I've done. It is not a substitute for the project's version control, which we have. It's a tool that gives amazing freedom to fearlessly experiment, hack, work problems simultaneously yet independently, etc. I am better at using version ...


5

Start with logging. This will have the greatest impact. Implement a logging framework into the code base, like Log4Net or similar. Start logging what the code does. Debugging should be possible locally. If not, work on getting the symbol files (PDBs) so you can debug into 3rd party dlls to gain a complete picture of the issues that are occurring. Tools ...


8

1) Debugger cannot be used on client site ... That's perfectly normal. ... or locally Now that's a problem. 2) There is virtually no logging done in our apps. Logging is the Production Debugging. There are no unit tests. Oh dear. All to common, though. 3) Version control only has 1 version of the full solution Then you're ...


21

Robert Harvey's advice is likely best, but since career advice is off topic, I'll give what answer can be given: You are at the bottom of a very steep mountain covered in brambles and mud and irritable mountain goats. There's no easy way up. If you want to get to the top, you've got to force your way up one tremendously painful step at a time. It seems ...


1

You're right, if you've written a Windows-only console you need to port the code in it to Linux or Mac. How hard that is depends a lot on what you wrote it in, and how you wrote it. Note that it is possible to run the console on Windows and connect to it via a network connection (if you wrote it to have this capability). As for ASP.NET, this is a ...


1

As far as I know, ASP.NET MVC applications can run only on IIS, which is only available on Windows. This will change with the latest ASP.NET 5, which will run in the DNX (.NET Execution Environment). DNX supports running cross-platform console applications, so consider looking here: http://docs.asp.net/en/latest/dnx/console.html


0

My thoughts: You should implemented objects writeTo/readFrom in some human readable text format like csv, xml, json. Advantages Can be maintained via texteditor Support for textual find&replace If you have (embedded) lists of (sub-) objects make shure that they are always in the same order (i.e. sorted by name). Advantages Windiff will only show ...


0

I know this is way late to the party, but... The interfaces IObservable<T> and IObserver<T> are not part of Rx...they're core types...but Rx makes extensive use of them. You are free to have as many (or as few) observers as you like. If you anticipate multiple observers, it's the observable's responsibility to route OnNext() calls to the ...



Top 50 recent answers are included