Trying out Domain Event

As the system implementation getting bigger, It may be hard to spot/fix important function. Therefore, we came up with an idea of using Domain Events to organize each function explicitly. As you may know, domain event is a simple class that constitute event in domain.

For the understanding, I go through some example and article regarding domain events. After that, I try out the implementation on my actual project. As my project is using Unity container, It is a bit differ from most examples on the internet (mostly structure maps). With few trials here and there for unity, my wrapper service class does directed to the event class, however it skip the event handler. Thus, nothing is trigger upon the button that I clicked and error prompted.

I then proceed the implementation based on various example that uses structure maps. After setting up the implementation, same thing occurs. Despite altering multiple declaration, system still unable to run as what we wanted. Even though it is said to be a great organized implementation, but it is still hard for me on how to implement domain event. In conclusion, domain events is yet suitable for me to apply in my actual project, thus, I have to look into other options available.

Remove File from Git Repository History

As I my implementation goes on, I push few commit upon my progress to bitbucket origin/develop branch. However, there is files/class that I want to remove from previous commits. After search up the internet, I get to know that git rm "filesname" command in new commit will not completely remove it from previous commits. Thus, after referring to my supervisor, I get to known there is a way to remove those files, which is by rebase and rewrite history of commit.

Beside, fix IsReady happens to have bug when I close and reopen the form. Given that I faced this situation quite often, I know that the bug is due to event aggregator is not unsubscribed during OnCloseDialog(). Thus, I just add a unsubscribe function and dispose the event for IsReady‘s view model class.

Lastly, I also add try catch statement and dialog when updating/creating data. This, is to notify user if there is error when updating changes onto database. I also add in new logic for IsCancelled in my repository class.

Row Version Update Upon Saving & The Importance of Clean Code

As my supervisor plan to print details in the system, I am required to and in new attribute in my current context. This attribute would actually be printed and customizable according to liking.

Next, rowVersion of current context won’t update whenever the changes is made in sub attribute. Therefore, I am required to add attribute “ModifiedDateTime” with attribute type of datetime. This attribute is used upon save button been clicked. Whenever a new/existing set of data is updated, ModifiedDateTime would update the latest date and time to the database, thus update the rowVersion.

Alongside of these implementation, I by accident altered my code. Which the alteration cause failure of updating ReadyToPick in my context. Thankfully I did commit my code frequently, hence, I am able to track my changes and revert it to working implementation.

I read through a few pages of Clean Code by Robert C. Martin. I found one interesting topic that more or less related to me which is about Bad Code. Many implemented application/system went down due to bad code. Bugs appears all over the system, crashed the system or even load time kept on increases as the system is not repaired. Major factor is mainly due to Rush, thus making big mess in code. As these mess builds, it may drag the productivity of one team. Eventually, it may cause the need of having more staff to help increase the productivity to its original phase. Which also may result more and more mess towards the project, as everyone trying to increase their productivity under pressured environment.

As the conclusion, I shall make sure my code is clean and easy to understand by others. It will bring benefit towards future me or other team member that is working on the same project. Therefore, Repairing, maintaining or adding implementation can be a lot more efficient.

Code Review on Modules

For the last week of my internship, I’ve performed code review on each module that I responsible for. I’ve clean up some redundant codes and functions, renamed variables to be more understandable. Not only that, I’ve also wrote comments to clarify the implementation logic for some functions.

Secondly, during the code review, I’ve also learned on the usage of Enum, which can be used to replace or represent a group of constants. In my case, instead of assigning magic strings as the line item’s pick status, I’ve replaced it with Enum which contains the variety of pick status.

Lastly, I’ve moved all the magic strings to Parameter class. By using parameter class, it become more maintainable to all the strings inside the whole solution. For example, changing of dialog message will only require to change the string in parameter class.

Implement WrapperService class & Retrieving Other Modules

Adding new attribute “isCancelled” to my ongoing project code. It is a simple checkbox with type of tinyint(1) and logic is validate in boolean. After adding the checkbox, I proceed with fixing initialization on various test class to ensure all tests pass the assertion.

Next, Implement WrapperService to manage multiple transaction for my current module. To support my implementation, I need to reference some context from multiple modules. Therefore I need to retrieve latest implemented modules that is needed in my WrapperService class.

As I am currently working on the project in a group of three. Each of us will works on our own modules. However, there is time we need to use element/attribute from other modules. Hence, we use git to retrieve and merged commits to keep my code at latest version. Sometimes it can be hard, combining latest code from origin git repository and ongoing code might cause few issues. Issue such as refactored variable name, overloading and missing function situation might occurs. Thus, I will need to refactor those code and discuss on which function to be maintain/removed.



Dispatcher Interface for Mocking

As I’ve wrote the integration tests for the pick module which also included the multi-threaded class, I’ve faced problem that the dispatcher in the multi-threaded class fails to mock. Since the multi-threaded class is used to refresh the data grid view within time interval, therefore fails to mock had caused all the integration tests fail to receive the data grid binding source to perform testing.

In order to solve the issue, I’ve decided to use the solution which is implement an interface for the dispatcher for mocking.

I’ve created the interface which called IDispatcher which include the BeginInvoke method. Then, instead of calling dispatcher, I’ve changed it to fire IDispatcher and its method as well. Lastly, in the integration tests, I call the mock for IDispatcher and setup its callback as (Action a) => a() to invoke the method in the multi-threaded class.