Search This Blog

Saturday, August 20, 2011

PLoP Links And Other Pattern Links

PLoP = Pattern Languages of Programs, a group that collects good patterns like some people collect baseball cards.
Some interesting links:
Books On Patterns
Patterns Catalog
Some Random Interesting Patterns:
Avionics Patterns
Scrum Patterns

Other Links:
Pattern-Oriented Software Architectures
Patterns & Frameworks for 
Concurrent & Distributed Systems - Patterns For Real Time Avionics Messaging in UAV
Great Article on Inversion of Control Layer
Variability Patterns (Software Product Line)

Friday, July 22, 2011

The Joel Test


  1. Do you use source control?
  2. Can you make a build in one step?
  3. Do you make daily builds?
  4. Do you have a bug database?
  5. Do you fix bugs before writing new code?
  6. Do you have an up-to-date schedule?
  7. Do you have a spec?
  8. Do programmers have quiet working conditions?
  9. Do you use the best tools money can buy?
  10. Do you have testers?
  11. Do new candidates write code during their interview?
  12. Do you do hallway usability testing?
Joel Spolsky's Joel Test (How Good is your software team)

Tuesday, July 19, 2011

Software Architecture Patterns and Best Practices

  • The fundamental rule is that all code can depend on layers more central, but code cannot depend on layers further out from the core.  In other words, all coupling is toward the center.   This architecture is unashamedly biased toward object-oriented programming, and it puts objects before all others. Onion Architecture

Sunday, June 26, 2011

My Favorite Java Tricks and Tips


  •  Classpath wild cards since Java 6: java -classpath ./lib/* so.Main Instead of java -classpath ./lib/log4j.jar:./lib/commons-codec.jar:./lib/commons-httpclient.jar:./lib/commons-collections.jar:./lib/myApp.
  • JDK 1.6_07+ contains an app called VisualVM (bin/jvisualvm.exe)
  • variable arity. So, instead of just passing an array, now you can do the following
    public void foo(String... bars) {
       for (String bar: bars)
          System.out.println(bar);
    }
    bars is automatically converted to array of the specified type
    
    
  •  javap disassembler which comes with Sun's JDK is not widely known or used.
  • // For each Object, instantiated as foo, in myCollection
for(Object foo: myCollection) {
 
System.out.println(foo.toString());
}
  • checking for null is not necessary.
Instead of:

if( null != aObject && aObject instanceof String )
{
    ...
}

just use:

if( aObject instanceof String )
{
    ...
}

  • anonymous subclass or anonymous impl of an interface:
public void initAnonymousSubclass() {
//anonymous subclass and directly call a method on it even if it implements no interfaces.
new Thread() {
public void run() {
while (true) {
try {
Thread.sleep(2000);
System.out.println("sleeping");
} catch (InterruptedException e) {
e.printStackTrace();
}
}

}
}.start();
}

public void initImplementationOfInterface(){
new TestInterface(){

@Override
public String printId() {
// TODO Auto-generated method stub
String someString = "time "+System.currentTimeMillis();
System.out.println(someString);
return someString;
}

}.printId();
}

Source attributation: http://stackoverflow.com/questions/15496/hidden-features-of-java

                                                            Monday, March 28, 2011

                                                            Common JEE Application Design Patterns

                                                            • Typesafe enum pattern/enum in JDK 1.5+
                                                            • code to an interface not an implementation
                                                            • abstract parent class to promote reuse for subclasses
                                                            • factory method pattern (loose couples calling code from instances created)
                                                            • abstract factory pattern  (specific method for each concrete type)
                                                            • builder pattern (similar to factory except user had more flexibility (builder.add(x), builder.add(y), etc.)
                                                            • strategy pattern (strategy encapsulates algorithms not data)
                                                            • decorator design pattern: (implements same interface as object it decorates)
                                                            • visitor pattern: (avoids lots of typecasts and instanceof to do common method on different types)
                                                            • iterator pattern
                                                            • template method pattern (e.g. Spring JDBC and Spring JMS)
                                                            • composite design pattern: (act on Manager or Staff object in same way. both subs of employee)
                                                            • facade pattern: (interface to large set of classes)
                                                            • observer pattern: (observer registers with publisher, publisher notifies observer of event)
                                                            • command pattern: OO equivalent of callbacks (sender object invokes operation, receiver object  receives request to execute certain operation)
                                                            • proxy pattern: (remote: EJB, RMI, CORBA, virtual: create memory intensive object on demand (lazy load hibernate objects when needed), access: different clients get different access rights)
                                                            • dynamic proxy: (reflection based; come at a performance cost; common in AOP)
                                                            • adapter pattern (wrap API)
                                                            • service activator pattern (ala MessageBean)  services need a way to be activated asynchronously
                                                            • For completion: (bridge, chain of responsibility)
                                                            • For completion JEE (MVC, front controller, composite view, view helper, dispatcher view, service to worker, business delegate, session facade, value object, fast lane reader, service locator)