- Caching results of a method using JSR-107's @CacheResult annotation.
- Automatic transaction handling with Spring's @Transactional annotation.
- Using JSR-303's annotations for validating POJO's.
- Using hibernate for inserting or loading data to/from the database
- Injecting fields in services using JSR-330's @Inject or Spring's @Autowired annotations.
- Automatically creating Spring beans using component scanning.
- Automatic permission checking using Spring Security's @PreAuthorize.
- Implementing service locators using Spring's ServiceLocatorFactoryBean.
- Implementing repositories using Spring data.
- Automatic project configuration using Spring boot.
The following is a list of 10 simple things:
- Keeping a cache using Guava's cache.
- Starting and committing transactions using Spring's TransactionTemplate.
- Validating POJO's by adding a validate method and implementing all the validation logic you need.
- Using Spring's JdbcTemplate to insert and select data to/from the database.
- Creating services using the new keyword and putting the dependencies in private final fields.
- Explicitly registering every Spring bean in @Configuration config files.
- 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.
- Manually creating a service locator that keeps a registry of services.
- Implementing repositories by ... implementing them.
- 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