Tag Info

Hot answers tagged

10

What is Code analysis? Code analysis (previously FxCop) is a static analysis tool which searches for common patterns which may indicate that something is wrong in the source code. For example, if an instance of a class which implements IDisposable is not disposed properly, Code analysis will emit a warning: private void DoSomething() { var connection = ...


6

Look at the source code of Guid.NewGuid method: public static Guid NewGuid() { Contract.Ensures(Contract.Result<Guid>() != Guid.Empty); ... } See the code contract? The Guid.NewGuid method never gives an empty GUID.


4

Addition of many elements to the end is O(m + logn), where m is the number of elements to be added. These operations would be O(n + m), and if m = n then they are almost as fast as addition to the end. In practice, they would be many orders of magnitude faster than if the user implemented them naively. However, for small numbers of elements, they would ...


4

If SomeParameterClassName regroups logically connected objects, then name it accordingly. For instance, if it regroups coordinate X, Y and Z, name it 3DPoint. If it regroups the product name, product price and product description, name it Product. void Demo(int x, int y, int z) { } ――― ↧ ――― void Demo(3DPoint coordinates) { } and: void ...


3

To me, the middle tier is not actually the middle tier because regardless of how isolated the design is and how stateless the DLLs are, they execute in the context of a web server only and essentially a part of the web application. No, the middle tier could be in another server(s) altogether when it comes to large applications. For example you ...


2

We know that nowadays the systems are designed as web applications. Every imaginable system is either converted or planned to be converted to a web app. Huh? While web apps are certainly quite popular and useful, they are by no means the be-all-end-all. Here are some cases where web apps are a poor choice and a "desktop" app would be a much better ...


2

Whether you place the "Middle Tier" code in DLLs loaded by the Front End site or place it into a separate web service application is just a detail. This placement decision does not change the code architecture in a meaningful way. It's more of a deployment decision. No, the tiers are not defined by physical deployment decisions but by code architecture and ...


2

I would follow the YAGNI principle and carefully think through what the client needs on his/her side. Including things that you think the client is going to need is a symptom of a core problem - that being lack of research and/or knowledge what the client actually needs.


1

You can use Memory Cache. I use memory cache to cache data rarely changes or at the specific time. Here is example: public static T GetCache<T>(string key, Func<T> initializer) where T : new() { if (!MemoryCache.Default.Contains(key)) { try { T data = initializer(); AddData(key, data); return ...


1

A relatively simple and generic method to pass .NET objects over process boundaries is to use serialization. Make sure your DomainObject is serializable, then you can implement your Clone method by serializing your object to a memory stream, and deserialize it from there within you main component out-of-process. We used that in conjunction with memory ...


1

Is your library a weather api that uses existing web services to get data? In that case you should probably hide the details of the actual ws, and define your own set of attributes for weather data. That way you encapsulate the external dependency from the users of the api. You may also want to watch how you get data from the xml. Try to only bind your ...


1

If the purpose of your API is just to provide data (which is true in my opinion), then do not return redundant or formatted values. In your example, returning single date/time is enough. This makes your response more concise and less ambitious. Making assumptions about consumer GUI and interpretation of provided data is usually wrong approach, avoid.


1

Exceptions denote exceptional cases, which I think is in your case. Assuming I am understanding your question correctly, returning an empty/null result could also imply that the input was [4][4][4][0], so there was nothing to return, rather than an empty or malformed input array. I would suggest that wrap that exception with an exception of your own, ...


1

It's all about discovery: the ability of your API to be understandable and usable by the next developer encountering it. If the WebSocket methods are easily discoverable, and it is clear that they should be used in conjunction with the ordinary REST methods, then your design is probably sound. In practice, for this discovery to occur, I think your ...



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