Backup 2, 3rd Feb

PHP

Key words: php, learning

I have learnt PHP in my university life, have little memory for this language. After that, I have steped into my java/javascript career. As the first language to communicate with server end, I must pick up it now. So let's start.

How to learn a new language, in my knowledge, php is like java to be a back end lang, but difference is, PHP can be put together with html so more agile option.

Editor

Someone said UEditor is a good choosen but so lightweight I think, to succeed JetBrains tradition, PHPStorm I choose for now.

Let's Start

W3C school is good place I think.

load, update, delete server end data, files, forms.
operations on cookies.
authorization
mysql is good friend with php, I'm proud I feel familiar with mysql database
Choose an application server

Apache and IIS can support PHP both, I choose apache here because I'd like apache community it has many good artifacts like maven, lucune, etc. I like this community.This is apache http server link. Version 2.4.10 for now.

Knowledge points

foreach as
define()
string functions
global variables

"; echo $_SERVER['SERVER_NAME']; echo "
"; echo $_SERVER['HTTP_HOST']; echo "
"; echo $_SERVER['HTTP_REFERER']; echo "
"; echo $_SERVER['HTTP_USER_AGENT']; echo "
"; echo $_SERVER['SCRIPT_NAME']; ?>

Node

Key words: nodejs, meanio, meteor

https://www.meteor.com/

http://sailsjs.org/#/

http://www.totaljs.com/

Key words: reflection, java, apache

Offical Link CommonsUtils

Let's learn from javadoc.

Javabean should be public classes, like code below, reflection should inject a java class and new an instance with non-arg constructor.

String className = ...;
Class beanClass = Class.forName(className);
Object beanInstance = beanClass.newInstance();
Some methods from property utils and dynaclass and dynabean are listed below.

DynaProperty[] props = new DynaProperty[]{
new DynaProperty("address", java.util.Map.class),
new DynaProperty("subordinate", String.class),
new DynaProperty("firstName", String.class),
new DynaProperty("lastName", String.class)
};
BasicDynaClass dynaClass = new BasicDynaClass("employee", null, props);
DynaBean bean = dynaClass.newInstance();
PropertyUtils.setSimpleProperty(bean,"firstName","settle");
System.out.println(bean.get("firstName"));
System.out.println(dynaClass.toString());
ResultSetDynaBean and ResultRowBean are used jdbc returned object, it's often looked as java bean object. Stress convert will be true.

Sails official website

What's Sails?
Based on express and nodejs, sails can easily build restful website without any code level knowledge.
Restful
Soap is based on XML document but restful is based on http, restful uses URI to achieve its goal and four classic method POST/GET/PUT/DELETE
POSTMAN
Chrome tool to send request to restful server.

Exciting JS Began, Express?

Key words: javascript, nodejs, express, http

I'd like to go from express, it's the most popular nodejs module in npm community.

Step by Step

At first, What's express module? Help to create web application server, from I know, embeded http module can do this, express encapsulates http module.

Guide from offical website

Template engines
This is a great topic to think.
Haml haml implementation(Most used in PHP,Ruby)
Jade haml.js successor(nodejs template engine)
EJS Embedded JavaScript(I like html style, so choose this one as main)
CoffeeKup CoffeeScript based templating
jQuery Templates for node
ejs
How to combine ejs with angular. Angularjs loads data through restful ajax calls, however, ejs render code is server side code so it can get data when html initially loaded.
npm install -g express-generator
Further thinking

npm command
npm ls
npm info
node command
package.json
./node_modules

Properties Artist

Key words: javadoc, Properties, How to

From easy to extreme, properties is a tiny util in java.util package. However, since properties file is standard tool for java configuration, I'd like to start from this.

Javadoc tells

The Properties class represents a persistent set of properties. The Properties can be saved to a stream or loaded from a stream. Each key and its corresponding value in the property list is a string.(Emphasize String)

A property list can contain another property list as its "defaults"; this second property list is searched if the property key is not found in the original property list.(See getProperty(String key, String defaultValue) Load default value)

Because Properties inherits from Hashtable, the put and putAll methods can be applied to a Properties object. Their use is strongly discouraged as they allow the caller to insert entries whose keys or values are not Strings. The setProperty method should be used instead. If the store or save method is called on a "compromised" Properties object that contains a non-String key or value, the call will fail. Similarly, the call to the propertyNames or list method will fail if it is called on a "compromised" Properties object that contains a non-String key.(HashTable)

Some own Tests

1.Print all the properties keys.

public static void main(String args[]) throws IOException {
Properties properties = PropertiesUtil.loadProperties();
System.out.printf(String.valueOf(properties.stringPropertyNames()));
}
2.Load and store to XML type file

public static void main(String args[]) throws IOException {
Properties properties = PropertiesUtil.loadProperties();
OutputStream os = new FileOutputStream("C:\out.xml");
properties.storeToXML(os,"some comment", "GBK");
}
Further Thinking

Properties extends from Hashtable, you should know hashtable features and differences between hashtable and hashmap.

posted @ 2015-02-03 14:55  一途  阅读(204)  评论(0编辑  收藏  举报