Form Template Method

You have two methods in subclasses that perform similar steps in the same order, yet the steps are different.
Get the steps into methods with the same signature, so that the original methods become the same.Then you can pull them up.

Ex:

interface MacroRender {
...void render();
}

class MobileMacroRender implements Render {
...public void render() {
......get data
......analyze data
......parse data
......render macro
...}
}

class DestopMacroRender {
......get data
......analyze data
......parse data
......render macro
}

Apply Form Template Method


abstract class MacroRender {
...void render() {
......gatData();
......analyzeData();
......parseData();
...}

...public void abstract getData();
...public void abstract analyzeData();
...public void abstract parseData();
}

class MobileMacroRender implements Render {
...public void getData() { //implements code }
...public void analyzeData() { //implements code }
...public void parseData() { //implements code }
}

class DestopMacroRender {
...public void getData() { //implements code }
...public void analyzeData() { //implements code }
...public void parseData() { //implements code }
}


Function

1. Function is a object.

2. Syntax to define a function:

Type1: regular function declaration

function nameOfFunction() {}

Type2: regular variable declaration and assign an anonymous function to it.

var nameOfFunction = function() {}

– Different between type 1 and type 2 is refer to js hoisted feature.

Type3: using new keyword

var nameOfFunction = new Function(arguments, function_body);

3. No Overloading:

function show()  { alert(‘show1’) }

function show(name) {alert(‘show2’) }

call: show() –> it will call show(name) function –> alert ‘show2’

Explanation:

– When you define function show() –> global will have show property:  window.show = function() {…}

– So when you define another with the same name. It will override old property if it exists. window.show = function(name) {..}

 


Coding Review

1. Code convention and format

2. Coding smell

3. Performance

4. Security:

4.1 Javascript:

– SQL Injection

– XSS (Cross-Site Scripting)

5. Business Logic:


Spring MVC Config

XML Annotation Description
 <annotation-driven/> @EnableWebMvc Support of annotation configuration for Spring MVC controllers

BeanFactory vs ApplicationContext

1. BeanFactory:
– Default instantiates beans lazily.

2. ApplicationContext: is a subinterface of BeanFactory
– Default instantiates beans eager.
– Support Message Internationalization (i18n)
– Support Event propagation
– Easy to access file resources


Reference Link

1. Javascript:

http://jquery-howto.blogspot.com
http://javascriptweblog.wordpress.com
http://jqapi.ru
http://addyosmani.com/jqprovenperformance
http://bonsaiden.github.io/JavaScript-Garden/
http://www.martinrinehart.com/

-Javascript Template Engine:http://engineering.linkedin.com/frontend/client-side-templating-throwdown-mustache-handlebars-dustjs-and-more


Escape Analysis

1. Escape analysis will make a object store in stack instead of in heap to improve performance base on:


Follow

Get every new post delivered to your Inbox.