Category Archives: Java

Store session data in cookie

In Web applications, users session can store a lot of data:

  • Information about the users profile
  • User roles
  • Temporary data (for example, wizard step data)

However, such storage can be a real headache if we have few backend servers that serve this application. To provide load-balancing and fault-tolerance in the service, session data should be stored in external storage (redis, memcached, sql). Appearance of new storage adds stress to supporting and performance.

Continue reading Store session data in cookie

Create your own dsl

In software development I encounter problems with creating user interfaces for manage logical chains.
More complex chain of logic cause more difficult to develop, test, and debug resulting interface.
That interfaces are hard to understand without help of man, who participated in the design.

Instead of complex interface is to try to use DSL.
This require a little more skill from the end user but in return it will eliminate the overloaded ui.
It provide a more flexible control over logic at lower labor costs.
A much easier debugging, testing, and auto-testing.

Consider the example of pethouse. We have the following classes:

class Food {
    Integer size
class Pet {
    String name
    Long age
    Closure hello
class PetHouse {
    String name
    Pet master
    @DSLTypeHint(Pet) List<Pet> pet
    @DSLTypeHint(Food) Map<String, Food> food

Continue reading Create your own dsl