Skip to main content

Posts

Showing posts with the label best practice

How to design a method

Introduction We have been reading articles about how to architect / design a system, microservices etc. However, I still find that there are developers that require some details on how to write / create a method. These are valid for statically typed languages like C# , Java which I have worked. though some of them apply to Javascript as a good practice. Below are some of the points that I consider worth noting The method should have a descriptive verb of the action that it is performing. ReadFromConfigurationFile SaveUserData CheckInOrderPriorToPayment 2. The arguments if any to the method should be validated prior to consumption. There are some built-in types in Java that helps in checking for nulls like  requireNonNull  from  java.util Note:  The below given method is one that i had built which checks for null and empty value and if so, throws suitable exceptions. We have been using similar built-in functionality in  Microsoft Enterprise Library  for .Net as  Guard.Null  or  Guard.Nu