Cleaning Before The Nearly Done Update

At the beginning of this week, the main goals was to fix the bug that caused Views to render multiple times. And changing the style of the whole application by putting all of the styles into a single style file and using it on every page.

I followed the previous work to use the correct UseEffects and the render problem got addressed. I next went on to the pagination issue, where the list of items was inconsistent. And page pagination did not function at all. The bug was at the pagination function, so after I altered the function by using UseInterval solution, the problem is fixed. In addition, I started performing Async tests on the UseInterval function to have a better understanding.

After that I started to work on the styling because the application. The point of the style wasn’t the style itself, but rather to make it easier for me to make changes or style a component. The previous style was somewhat random, and each component was styled independently, which made the code more complicated. Therefore, the main purpose here was to clean the code and make the style easy to edit.

Next, I styled the main page and the primary background, in addition to all other components in the main pages. The result for me is great, now I can change any component style in only one place for all pages.

While Mr. Peter was testing the application before to this version’s upgrade, we discovered a bug again in the keyboard toggle. It took us some time to solve this problem, but after we did, Mr. Peter showed me how to make it a reusable component for our app, which was wonderful and helpful.

To conclude, the keyboard toggle were functioning properly with no bugs. However, it was not as we expected it to be, so we postponed the upgrade until the following week, when I will fix the issue.

Introduction to WPF

On the forth week of my internship, I was introduce to WPF. WPF is the main UI component of the sandbox application that I was working on. After going through an introduction of it together with prism. The main design pattern used when developing the WPF page was the MVVM model where the code that implement the business logic is separated from the UI code where it usually consist of the view and view model.

Afterward, I have to convert the existing feature of the stock threshold so that it uses the API end point that I have created previously. Firstly, I registered the container which will connect to the API. The first page I was working on was the page which display the list of the stock threshold. In this page, the entire list of the existing stock threshold from the database will be display to the user. Not only that, I also added a feature to allow the user search for the desired stock threshold through the item name search bar.

Next, when I tried running the application and navigated to the stock threshold page, the code return a 404 not found response. I realized that the container was mapped to the wrong API end point which resulted in 404 not found response. After registering the proper API end point, the page was able to display the stock threshold list.

Lastly, the next page I was working was the page which is responsible for the create, update and delete of the stock threshold. At first, I was having some difficultly in understanding the code. After some guidance, I was able to figure out what needed to do. The mapping of the data was mainly done with the Auto Mapper.

Application of What I have Learnt

On the third week of my internship, I learnt on how to apply what I have learn so far. After setting up the sandbox application to practice the concepts like API, TDD and loose coupling. My task was to convert the stock threshold function of the existing app into an API. At the beginning, I was struggling to create the API for the stock threshold. After some guides from Mr Peter, I begin to understand on how to create the API.

Firstly, using the CQRS pattern, I separated the commands and the queries into separate files. In the queries folder contains the different Query which will return the entire list of the existing stock threshold to the user when it is called. Not only that, there’s also GetById Query which will return a stock threshold to the user based on the requested Id of the stock threshold.

Next, in the commands folder contains the create, update and delete functions for the stock threshold. The create command will take the item Id with the quantity for the stock threshold. Using the given item Id, the code will look for the item in the item database and map it to the stock threshold that was created.

Similar to the create command, the update command will take the stock threshold Id, item Id together with the quantity as well. In the update command, the code will take the item Id and check if the existing item Id is different with the inputted item Id. If the item Id is different, the code will look for the new item in the item database and update the existing item to the new one. As for the delete command, the user just has to input the stock threshold Id and the code will delete it. The Http method was implemented in the controller folder.

Lastly, the unit test was created for each of the function to make sure they are working properly. At the first, I was struggling to create the unit test as I was inexperience in creating unit test but after reference the other unit testing I was able to get the hang of it. The unit test was also accompany with some dummy data. All the unit test was able to pass without much problem.

Positive Test Cases and Positive Testing

Although the Flatlist obstacle was hard to define and took a long time to get solved. I’ve gained a greater understanding of testing and its flaws as a result. Therefore, I can follow the test progress and attempt to create the optimal assertion more quickly than previously.

This week, I started with testing the more page components. I tested the primary UI elements and the manual scanning functionality. I can state that my unit tests are imperfect and disorganized, but I am working to improve them each time, which affects my upcoming tests.

After that, I moved to test other views. They share comparable components, thus I did not encounter as many difficulties as before. Mr. Peter often urges me to write a good description, and I have since understood that the structure of my tests has to be improved and more understandable. Consequently, I separated my tests into several ‘describe’ sections. For instance, the ‘Header’ section only contains unit tests for the header components.

While you interact with some page, you can easily tell that something is going wrong with the manual scanning input field. Accordingly, I managed also to fix that and create a keyboard toggle that works as a controller to prevent the virtual keyboard from automatically appearing.

Overall, I learned more and gained new experience with unit testing. By running tests, I consistently encounter new errors that require new solutions and provide me with fresh knowledge. Next week, I will do negative tests on previously tested components. Fixing the extra rendering times problem for other views is another task as well.

The Headstrong Flatlist

Following what I did last week, I spent this week learning how to debug the code, using breakpoints more in the debugging. I tried to solve the fake-timers issue I had last week, by reading the react native docs. I dived more into testing asynchronous code, and learnt several ways to make the test effective. So I used async/await correctly to pass that.


The flatList component of react native was a major time-consuming task that I needed to test. Unfortunately, I spent a lot of time trying to solve the problem and I failed to resolve it. The error message given was always related to the testing configuration, which already set up and working successfully last week. Therefore, I considered changing the code and replacing the FlatList components with SectionList to avoid all of this, but it was not the perfect option.


Finally, in order to solve the aforementioned problem, I had to mock the FlatList at the end. it seemed quite impossible to test or to get an element form a FlatList unless it is mocked.

Second Week in Tong Hin

On the second week of my internship, I begin to dwell deeper into the concept like ASP.NET Core, RESTful API and TDD. In ASP.NET Core, I learned the best practices to use whenever I work with the framework. Not only that, in ASP.NET Core, I learned on how to create an API where API allow for communication between 2 different application that uses different programming language. Lastly is the mediator pattern and CQRS. The mediator pattern is how two object communicate between each other and this promote loose coupling between the 2 objects. CQRS is the separation between the command model and query model where the command model is usually the create, update and delete operation which can change the data but doesn’t return data to the user. Meanwhile, the query model is the read operation in which it doesn’t change the data and return a result to the user.

The RESTful API is the communication between to application when it’s based on the CRUD (Create, Read, Update and Delete) operation. In an API, the client will send a request to the server through the API using the HTTP method like GET, POST, PUT and DELETE request. Afterward, the API will then fetch the appropriate data and send it back to the client. The REST is the constraint applied when creating the API. The constraints are usually, client-server architecture, stateless, cache-able, uniform interface and layered system.

Lastly is the concept of Test Driven Development (TDD). In TDD, the development of a software usually start with the testing first. The cycle of TDD involve creating a failing test first then applying the logic of the code to make the test green. Finally the last part of the TDD cycle is to refactor the code to make sure the code is clean. The process is then repeated again for the other part of the code. TDD allow for easier to test to code and provide a fast feedback to know whether or not the logic is working properly.

First week of Internship at Tong Hin

The first week I spent at the company was mainly focusing on learning the technology that will be used in the subsequent week. First thing I learnt was how to use git. In git, I learned the command in git, how to create repository, committing to changes, merging repositories and push any changes made in the repositories.

Next, I also touch up on my C# fundamentals again in order to fully prepare myself to learn the new concepts as listed below. From the C# fundamental course, I revised on the syntax used in C#, how to work on the classes and objects, testing my code through unit testing, differentiating between reference types and value types and the object oriented programming in C# as well.

Lastly, I was introduced to the concept of asynchronous programming. Asynchronous programming allow for 2 operations, operation A and operation B, which doesn’t depend on each other to run asynchronously when compare to synchronous programming which has to wait for operation A to finish first then it will execute the operation B. Asynchronous programming mainly uses the keyword async, await and task. The other concepts that I have briefly gone through are ASP.NET Core, RESTful API and Test Driven Development(TDD).

Babel Conflicts

This week, I began resolving dependency issues in order to rerun all test files and create new tests. There were several conflicts, so I reinstalled all jest and babel dependencies to address them. And this resulted in another failure to render the application due to Babel’s configuration and plugins.

The Error message was unclear, the code was difficult to follow.  This caused me to have greater difficulty troubleshooting the problem and discovering the bug, and it took me a significant amount of time to find a solution. I eventually had to separate the babel configurations for the application and the test files.

After that, I began to examine the test files and ensure that they ran properly. Numerous issues relating to Fake-timers and Mocks have appeared; I must solve them, ensure that existing tests are functional, and create new tests with no dependency conflicts or incorrect configurations.

Stuck in the Dependency Hell

This week, I was tasked with doing some test tasks, however, in order to complete them, I had to update a number of dependencies, which resulted in a large number of dependency conflicts.

My supervisor gave me the go-ahead to upgrade all dependencies and the react native version to the most recent version. It is not uncommon to discover several problems in the code and some dependency conflicts after getting done from the updates, which eventually I was able to resolve. Moreover, to modify the code and fix the errors, I had to spend some time reading the documentation for the new versions that I had upgraded.

Finally, with Mr. Peter’s assistance, the application ran properly on the emulator. Unfortunately, the testing dependencies still contain some errors, and Jest is unable to test the application. I have attempted a variety of solutions to resolve this issue, which will be resolved by next week.

In conclusion, this week was filled with dependencies updates and bug debugging. I’ve gained a lot of knowledge about how to handle the dependency conflict through much searching and reading, and from Mr. Peter of course. Now I must resolve the rest of the issues in the testing section so everything can be updated and work well.