Issue #4: DotNet (.NET) & JavaScript (JS)
Ahmed Tarek Hasan
Senior Software Design Engineer @ASML (Advanced Semiconductor Material Lithography) | Technical Blogger | Development Simply Put (DevelopmentSimplyPut.com)
This issue would be about some?topics for DotNet (.NET)?and?JavaScript (JS)?developers.
Notes:
DotNet (.NET)
How To Fully Cover I/O File Based Applications in .NET C# With Unit Tests
While working for different software houses, in more than one occasion I had the chance to work on an application which is mainly based on?I/O File?operations.
The biggest challenge the team was facing while working on such kind of applications is that the I/O File operations are so hard to be covered by unit tests, automate Bamboo builds, and many other things.
Therefore, once and for all, I decided to come up with the best design I can come up with to overcome these challenges. However, just as a reminder, nothing in software is an absolute truth. For every application you have to reconsider your design, see where it fits, where it doesn’t fit, and finally you need to adapt.
Now, as usual, I am going to provide a simple example and walk you through the trip to come up with the best -possible- solution.
When String.GetHashCode() in .NET C# Drives You Crazy
I was working on a side project of a tool to help me with my daily work. In one module, I needed to keep track of some transactions which could be executed between the tool runs. In other words, when I close and open the tool, these transactions should be there.
For storage, I used a SQLite database where I save a hash-code of an entity representing my Transaction class. I was depending on this hash-code as at some point the tool would generate a new hash-code and compare it to the one already saved in the database.
So, after setting everything in place, I started the tool, give it a try, yes… it is working. I close the tool, do some stuff, then try testing another thing, now it is not working as it should!!
领英推荐
I kept trying to understand what is going on and finally I got it. The hash-code comparison is not working fine. During the same run session of the tool, the comparison is working fine. However, when I close and open the tool, the newly generated hash-code -to the same exact transaction-is not the same as the one saved in the database.
JavaScript (JS)
How to Recursively Call APIs to Get All Results in JavaScript
Most of the time while working on a JavaScript project, I write some code to call?REST APIs. This is normal.
However, sometimes a REST API could have restrictions on the number of items it returns per request. In other words, while calling the API to get some items, these items would be divided into indexed pages/groups and you have to provide the page/group index. This would return only the items in this page/group. To get the rest, you would need to repeat the same API call but now with a different index, and so on…
Paging/Partitioning — Learn the Main Equations to Make it Easy
The?Paging?or?Partitioning?concept is used in many fields. When you have a set of items and you want to divide them equally between some sort of containers or groups, you are thinking of paging or partitioning but may be you don’t recognize it, yet…
The main goals of this story are to:
That’s it, hope you find reading this newsletter as interesting as I found writing it ??