Blog

Item 22: Use interfaces only to define types

Interfaces should be used only to define types. They should not be used merely to export constants. The constant interface pattern is a poor use of interfaces If the constants are best viewed as members of an enumerated type, you should export them with an enum type (Item 34) If the constants are NOT strongly […]

Item 20: Prefer interfaces to abstract classes

Advantages Existing classes can easily be reconstructed to implement a new interface. You just need to use implements clause to the class declaration and add the required methods Interfaces are ideal for defining mixins (Example: http://hannesdorfmann.com/android/java-mixins) Interfaces allow for the construction of non-hierarchical type frameworks. They are great for organizing things that don’t fall into a hierarchy […]

Item 18: Favor composition over inheritance

Inheritance violates encapsulation unless the superclass’s authors have designed it specifically for the purpose of being extended The superclass’s implementation may change from release to release, and if it does, the subclass may break, even though its code has not been touched. As a consequence, a subclass must evolve in tandem with its superclass, unless […]

Item 17: Minimize Mutability

An immutable class is simply a class whose instances cannot be modified. All of the information contained in each instance is fixed for the lifetime of the object, so no changes can ever be observed. An immutable object can be in exactly one state, the state in which it was created Immutable objects are inherently […]

Item 15: Minimize the accessibility of classes and members

Encapsulation A well-designed component hides all its implementation details, cleanly separating its API from its implementation. Components then communicate only through their APIs and are oblivious to each others’ inner workings. This concept, known as information hiding or encapsulation, is a fundamental tenet of software design. The advantages of encapsulation are as follows: Speeds up […]

Spring: Big Picture

What is Spring? Spring makes it easy to create Java enterprise applications.It is a complimentary to Java EE. Spring is open source. It has a large and active community. Spring 5.0 requires JDK 8+ and provides out-of-the-box support for JDK 9. Fundation: Spring Framework The Spring Framework is an application framework and inversion of control container for the Java […]

Terraform: Import AWS resources

Problem: Resource already exists If there are some AWS resources that are not exist in terraform scripts and you run terraform apply, you might get “XXXX already exists” errors. I listed some of them: BucketAlreadyExists: The requested bucket name is not available EntityAlreadyExists: A policy called dummy-policy-name already exists. Duplicate names are not allowed ResourceInUseException: Table already exists: dummy-table-name […]

Terraform: Create S3 bucket and DynamoDB table

Let’s say you have a Template file (.yaml) that provisions resources to support Terraform Remote state backed by S3 and DynamoDB for consistency locking as below You can create AWS S3 bucket and DynamoDB table using Designer Template in AWS CloudFormation. Go to AWS Cloud Formation page and click Design template. Copy and paste the […]

Docker: Recovering from deleting /var/lib/docker

I deleted “/var/lib/docker/” when I was dealing with Docker Thin Pool error below. devmapper: Thin Pool has 114247 free data blocks which is less than minimum required 116729 free data blocks. Create more free space in thin pool or use dm.min_free_space option to change behavior However, I couldn’t restart docker and got ea new error: […]

Jenkinsfile: AWS Lambda deployment from S3 bucket

AWS Lambda limits the amount of compute and storage resources that you can use to run and store functions. The deployment package size is 50 MB (zipped). Here is the solution how to beat it. Take a look at this blog for S3 solution as well.   Problem Assuming that you created a zip file called […]