Common Git Problems

The past week , I have been working on refactoring fields/methods namings for consistency in the Tong Hin application .

As I refactor the codebase , git is able to handle the new changes automatically , but it will not fit for every ideal scenario . The changes I have made caused breaking changes , some may include deleting or modifying a required field or method . Large refactors and major feature additions are good , but remember that basic communication is needed in a team before changing any fields/methods as some of them are used in separated projects and may cause merge conflicts.

Another mistake that i made was using git push –force way too often than should , and not realizing it will generate problems to everyone else . To prevent this , try not to reset or rewrite history in a branch that someone that might have already pulled without understanding the consequences .

Lastly , always remember to merge a pull request from another working branch . Even git offers powerful tools to resolve changes , but conflicts will most likely happen in a team environment when two separated branches have made edits in the same file .

That is all for this week .

Test-Driven Development (TDD)

The past week, i have been working on creating tests on modules .

What is TDD ?
TDD is a practice that focuses on creating test cases before developing the actual code . While it’s a slow process to understand from the beginning , not knowing why TDD applies the reversed traditional way of testing , I am starting to grasp the principals and benefits of TDD .

Why do I think TDD is advantageous ? While it also takes a lot of effort to create a test . It also makes a project easier to maintain , especially in large projects . Instead of setting countless breakpoints and debugging in the program over and over to find a bug . Running the test may save a lot of time .

TDD also documents the code better , when using the TDD approach , instead of documenting detailed and time-consuming comments in the program , most of the documentations are already illustrated in the tests on how the code is supposed to work .

However , the TDD approach is very challenging and difficult to learn and adjust to its behaviours appropriately. It is a slow process that takes time , skills and persistence .

WPF Layout

The past week , I have been working on Tong Hin’s inventory module layout .

Why is layout important ?
Setting a layout is so important to an application usability . Arranging controls based on explicit coordination may work for one environment , but as soon as we change its screen resolution or with different font sizes it will fail .

Therefore , I realized the best practices when creating any layout is to :-

  1. Avoid fixated sizes of height/width . Use the HorizontalAlignment/VerticalAlignment properties together with Margin to position elements in the layout
  2. Practice using a StackPanel to layout buttons of a dialog
  3. Practice using Grid to layout static data entry form . Create Auto sized columns and Star(Asterisk) sized columns for the elements

Additionally , if the layout is too big to fit the resolution size , we can add a scroll bar by using the ScrollViewer property. The visibility of the ScrollViewer can be set using the ScrollbarVisibility properties .

Any beginners should practice these useful tips before starting a UI layout development in WPF . That is all for this week .

EF Core Performance 2

Regarding last week’s blog in optimizing EF core performance , the cartesian explosion was optimized to a slight extent successfully using explicit loading and removing several repetitive code . The data of this performance is tracked with the help of performance profiling .

I optimized the problem by starting a timeline profiling session provided by visual studio , here are the following steps :-

Step 1 : In visual studio , go to Debug and click performance profiler

Step 2 : Select Application Timeline and Database (examine the SQL query to measure time)

Step 3 : Click start , navigate to the cause of the UI freeze and click “Stop Collection”

Following these steps we are able to analyze where is the memory traffic coming from , then improving the code and fixing the issue .

In summary , profiling helps a lot in detecting what causes performance issues , for less experienced developers we have to be careful in retrieving so called “list” or static data using database connection every time in a loop or repetitive process . After many trial and error , I manage to optimize the performance loading in the SandBoxApp .