Thursday, January 4, 2018

Do the extra work in order to have names that don't stink.

It was deemed today that IsActive is really a better name than IsToDeactive to drive a flag on a DTO for whether or not to soft delete that record alongside all of the other PUT verb-style updates that might be made. The reason I had IsToDeactive is because if this was just left unset, and indeed the delete flag was going to be set in one update scenario and not all update scenarios that end up hitting the repository for as much, that it would just end up as false in bridging the leap from Angular 4 to a .NET Core REST API. With the IsActive approach I had to have a nullable bool in lieu of a bool and then have some logic in the repository like so:

if (prospectData.IsActive == null) prospectData.IsActive = true;

 
 

...and yet this is the way it has to be. Don't forfeit good names for elegant code.

No comments:

Post a Comment