Monday, April 17, 2017

... about simple vs easy

The following is a list of 10 easy things:

  1. Caching results of a method using JSR-107's @CacheResult annotation.
  2. Automatic transaction handling with Spring's @Transactional annotation.
  3. Using JSR-303's annotations for validating POJO's.
  4. Using hibernate for inserting or loading data to/from the database
  5. Injecting fields in services using JSR-330's @Inject or Spring's @Autowired annotations.
  6. Automatically creating Spring beans using component scanning.
  7. Automatic permission checking using Spring Security's @PreAuthorize.
  8. Implementing service locators using Spring's ServiceLocatorFactoryBean.
  9. Implementing repositories using Spring data.
  10. Automatic project configuration using Spring boot.

The following is a list of 10 simple things:
  1. Keeping a cache using Guava's cache
  2. Starting and committing transactions using Spring's TransactionTemplate.
  3. Validating POJO's by adding a validate method and implementing all the validation logic you need.
  4. Using Spring's JdbcTemplate to insert and select data to/from the database.
  5. Creating services using the new keyword and putting the dependencies in private final fields.
  6. Explicitly registering every Spring bean in @Configuration config files. 
  7. Permission checking by explicitly looking up the permission in Spring Security's SecurityContext, passed as an extra argument or by looking it up in the SecurityContextHolder.
  8. Manually creating a service locator that keeps a registry of services.
  9. Implementing repositories by ... implementing them.
  10. Configuring your application by carefully choosing the dependencies your application needs and configuring them manually.

I like simple things. I dislike easy things. 

Easy things look simple but that's only in the beginning. It doesn't take long until they become complicated. 

Simple things require more effort - that's why they're not in the easy list - but they remain simple to read and understand. 

Aim for simple. Shy away from easy.

Greetings
Jan

No comments:

Post a Comment