- Represent our ideas
- Manage Complexity
- Abstraction - Figuring out what abstractions express our requirements
- Polymorphism - Using multiple abstractions in the same way
- Inheritance - Sharing Implementation
simple rule: | |
we have object A and object Z. | |
if we have a pointer from object A to object Z then its aggregation.(no pointing from Z to A ,since it maks a simple relation). | |
if object Z cannot exists in the system without object A, then its composition. | |
its not that hard, even more ITS NOT THAT USEFUL. why? beacuse no body uses this stuff to the fine lines, its a loose model that lets you grasp what you want from the system. |
A Java object is considered immutable when its state cannot change after it is created. Use of immutable objects is widely accepted as a sound strategy for creating simple, reliable code. Immutable objects are particularly useful in concurrent applications. Since they cannot change state, they cannot be corrupted by thread interference or observed in an inconsistent state. java.lang.String and java.lang.Integer classes are the Examples of immutable objects from the Java Development Kit. Immutable objects simplify your program due to following characteristics :
Immutable objects are simple to use test and construct. Immutable objects are automatically thread-safe. Immutable objects do not require a copy constructor. Immutable objects do not require an implementation of clone. Immutable objects allow hashCode to use lazy initialization, and to cache its return value. Immutable objects do not need to be copied defensively when
import java.io.File; | |
import java.io.UnsupportedEncodingException; | |
import java.net.URLDecoder; | |
public class WindowsExeFile { | |
private final File file; | |
public WindowsExeFile(String rawPath) { | |
this.file = convertToFile(rawPath); |
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> | |
<property name="entityManagerFactory" ref="entityManagerFactory" /> | |
<property name="dataSource" ref="myDS" /> | |
</bean> | |
<tx:annotation-driven transaction-manager="transactionManager" /> | |
<aop:config> | |
<aop:pointcut id="defaultServiceMethodTxPointcut" | |
expression="execution(!@org.springframework.transaction.annotation.Transactional * *(..)) |
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> | |
<property name="entityManagerFactory" ref="entityManagerFactory" /> | |
<property name="dataSource" ref="myDS" /> | |
</bean> | |
<tx:annotation-driven transaction-manager="transactionManager" /> | |
<aop:config> | |
<aop:pointcut id="defaultServiceMethodTxPointcut" | |
expression="execution(!@org.springframework.transaction.annotation.Transactional * *(..)) |
package com.example; | |
import com.vaadin.shared.ui.grid.DropMode; | |
import com.vaadin.ui.Grid; | |
import com.vaadin.ui.GridDragSource; | |
import com.vaadin.ui.GridDropTarget; | |
import com.vaadin.ui.VerticalLayout; | |
import java.util.List; |
#!/bin/sh | |
# | |
# a simple way to parse shell script arguments | |
# | |
# please edit and use to your hearts content | |
# | |
ENVIRONMENT="dev" |
#!/bin/bash | |
## Script start time | |
START=$(date +%s) | |
## Total run time | |
DURRATION=$((60 * 60 * 24)) | |
## Total running time | |
UPTIME=$(($(date +%s) - $START)) |
import com.yammer.dropwizard.util.Duration; | |
import com.google.common.cache.*; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import java.util.concurrent.*; | |
import static com.google.common.base.Throwables.propagateIfInstanceOf; | |
public class LocalAppConfigStorage implements AppConfigStorage { |