1 / 21

A proactive approach to programming

A proactive approach to programming . An Architect’s Perspective. Roadmap. Recommendations for Smart Programming. Java Programming Working alongside Spring QA. What ?. Intelligence. Smart. Smart Skills - Programming. Effective Programming Jargons. Accurate Brick Better Design

janet
Télécharger la présentation

A proactive approach to programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A proactive approach to programming An Architect’s Perspective

  2. Roadmap Recommendations for Smart Programming • Java Programming • Working alongside Spring • QA

  3. What ? Intelligence Smart

  4. Smart Skills - Programming Effective Programming Jargons • Accurate Brick • Better Design • Performance • Multi-threading • Security • Design Patterns

  5. Smart Skills - Accurate Bricks • Identify - Start Line • Automatic Build (Ant, Maven), Log Monitoring • Identify- End Line • Unit Testing, JUnit, Functionality Validation Tests

  6. Smart Skills - Better Design • Type safety (Generics) • Enforcing encapsulation • Simplifying adaptation to interfaces • Design patterns • Flexibility, OOD, Strategy, Singleton, Composite, Factory, Inversion of control • Exception Handling • Framework or guidelines

  7. Smart Skills - Performance • Measuring performance • Applying performance profiling tools for response time, load and stress, and identification of performance bottlenecks • Strategies for improving performance • GC, JVM settings, NIO, Reordering loops • Effective use of the Collections API • Identify weak references, best collection classes

  8. Smart Skills - Multi-threading • Improving response time by parallelization • Thread-safe, avoiding deadlocks • Improvising a threaded application • Synchronization & Data Sharing • Managing the performance implications of synchronization

  9. Smart Skills - Security • Handle with care • Secure coding in Java • Programming defensively • Authentication and authorization • Applying role-based security • Restricting access to protected resources • Establishing security policies

  10. Smart Skills – Design Patterns • Limiting the impact of changes • Centralizing properties using Singleton • Inserting transparent behavior with Proxy • Wrapping external libraries using Adapter • Modern design patterns • Inverting control (IoC) through bean factories • Injecting behavior with aspects • Adding scripting abilities to an application • Scripting end-user behavior

  11. Smart Skills – Alongside Spring Spring Programming Jargons • Spring Core • Data Layer • XML Configuration

  12. Smart Skills – Spring Core • Using Spring’s “Bean Container” nature and Dependency Injection. • Spring will act as a real container of Beans and creates bean instances at the time of requirement • Prefer ApplicationContext over BeanFactory • Once at start time or at time of instantiation • Prefer setter-based dependency injection over constructor-based dependency • Strong Vs Weak dependency • Singleton beans and Prototype beans

  13. Smart Skills – Spring Core (Contd.) • Aspect Oriented Programming in the necessary situations • Spring AOP and AspectJ AOP • Comparison • Declarative caching services for Spring • Example • Text Search • Lucene only· Compass/Lucene· Hibernate Search/Lucene

  14. Smart Skills – Spring Core (Contd.) • Configuring Spring Application context for different locations • Prefer static pointcut over dynamic • Dynamic are slower to evaluate • Use regular expression advisors to fine tune interceptor scope • Aware of thread safe issues with AOP advice • Example

  15. Spring AOP Vs AspectJ AOP Pro Con • Spring AOP doesn’t require any special java compiler or special build process. AspectJ requires special compiler. • Different advice could be applied to different instance of the same class. This is not possible with AspectJ. • Target object is not modified. AspectJmodiefies target object behavior. • Spring AOP can not be applied to final methods. Spring generates subclass of the target class and weave advuce around overriden method. • Spring only supports method joinpoints. AspectJ and JBoss AOP supports field joinpoints as well. • Targets are not proxied which means that the method calls on this object is not advised. • Lazy initialization of Spring Beans

  16. Smart Skills – Declarative Caching <bean id="customerDaoTarget“ class=“dao.CustomerDao” /> <coherence:proxy id="customerDao" refId="customerDaoTarget“> <coherence:cachingmethodName="load" cacheName="customerCache" /> <coherence:flushingmethodName="update" cacheNames="customerCache" /> </coherence:proxy> <bean id="customerManager“ class=“business.CustomerManager" /> <property name="customerDao" ref="customerDao" /> </bean>

  17. Smart Skills – AOP Advice public class CountingMethodAdvice implements MethodInterceptor { // The next serial number to be assigned private static long nextSerialNum = 0; private static ThreadLocalserialNum = new ThreadLocal() { protected synchronized Object initialValue() { return new Long(nextSerialNum++); } }; private static long getCount() { if(serialNum!=null){ return ((Long) (serialNum.get())).longValue(); } } public Object invoke(MethodInvocationmethodInvocation) throws Throwable { System.out.println(”This method is called ” + getCount + ” times”); } }

  18. Smart Skills – Data Layer • Prefer to use apache Connection pooling bean (commons.apache.org/dbcp) • Handling Exceptions • Prefer to use Springs Declarative Transaction Capability • Transaction Attribute Settings • Better to perform unit testing in the DAO layer

  19. Smart Skills – XML Configuration • Avoid using spring’s ‘autowiring’ • Use shortcut forms • Prefer type over index for constructor argument matching • Reuse bean definitions, if possible • Prefer assembling bean definitions through ApplicationContext over imports

  20. Smart Skills – Advantages • Spring Provides Better Leverage • Spring Enables POJO Programming • Dependency Injection Helps Testability • Inversion of Control Simplifies JDBC • Spring‘s Community Thrives

  21. Q & a

More Related