Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

9

C#'s Task is somewhere halfway between Java's Future and CompletableFuture. The Result property is equivalent to calling get(), ContinueWith() does the things the massive array of continuation functions on CompletableFuture does (add some Task.WhenAny and Task.WhenAll in there). But complete(T) has no equivalent (use a TaskCompletionSource), nor does cancel()...


3

Is there a unique android ID question gives a good overview of the options to get a unique id for android. Best practices for Unique Identifiers recommends using instanceID for most use cases. See IdentifierForVendor for iOS products. Once you have an ID, hash it and send the hash to the webapi over a secure connection. This does not protect against rooted ...


3

Bringing namespaces in for this is not right, namespaces are for big scope borders, typically on the module/assembly level. This is about keeping your scope tight, if you introduce a new namespace, that namespace will be visible outside the scope of the class which you do not want. The partial class would be OK. I personally would just use a region named ...


2

You're applying the Open Closed Principle to files. This is reasonable when your motivation for following the Open Closed Principle is to isolate proven tested files from change. By keeping your files small the amount of code that must be reviewed after a change is kept small. Just keep in mind that just as extra indentation comes as a cost to readability ...


2

So why create a nested class? I can think of couple of important reasons: 1. Enable encapsulation Many times nested classes are implementation details of the class. Users of the main class should not have to care about their existence. You should be able to change them at will without requiring the users of the main class to change their code. 2. Avoid ...


1

The ProductService is tightly coupled to http. You cant switch hosting without changing the ProductService. I instead let a exception handler deal we this so the domain can be completely separated from the hosting public class ExceptionHandlingMiddleware { private static readonly Dictionary<Type, IExceptionMapping> ExceptionMappings = new ...


1

One approach is Application requests a license key at startup, attach either a random or hardware based id and the username to the request. The server finds the appropriate key and marks it as used, with the id and other relevant data. This can be done by using a separate 'used licenses' table or by updating the licese key row. Application sends a keep ...


1

Short answer This is a problem I've encountered and solved. In short, the issue was indeed that a context was being injected (via an injected repository) which was kept alive in a Windows service consumer, which was not the intention. The short and simple answer on how I fixed this is to inject a context factory instead of a context. For my use case, I ...


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