Interestingly, this same condition may appear to tones that are greater than semitones in the lower frequency range. In other words, chords in lower frequency range did not sound as smooth as the same chord in a higher frequency range. That's why musician does not play chord with bass instruments.
Sunday, October 22, 2017
Sensory Disonance
A note entering an ear causes the ear drum to vibrate. The in turn stimulate a patch of hairs in the cochlea in the inner year. Different frequency will stimulate a different cochlea patch. When several notes is heard, multiple cochlea patches are stimulated. Patches for 2 semitone may have overlapped area. The brain would need to work herder to identify them. This biologically caused us to sense the sound combination of 2 semitone as dissonant.
Object Serialization
Serialization is to make an object persistent across session. An object exists in memory of a program instance (e.g. Javascript). Once the program terminated, memory is released and the object ceases to exist. To preserve am object across different program instances, the object must be stored in an persistent media (disk). The object memory layout is converted to string and kept on disk.
JSON2 library contains routine to serialize a JavaScript object (stringify) and to recreate the object in memory from a serialize object (parse).
JSON
In addition to using "new" keyword, JavaScript Object can also be created directly from literal values. For example,
Obj1 = {“member1” : “this is member 1”, “member2” : “2”, member 3 : 3, member4 : Obj2};
Or using array notation:
Obj1 = [“this is member 1”, “member2”, 3, Obj2];
JSON is derived from the literal form of the Object in Javascript. The possible JSON value can be a string, number, object, array, true, false and null.
HttpServlet
As most servlet is written to handle request delivered by http protocol, the HttpServlet extends the GenericServlet and provide methods specially created to handle http requests.
HttpServlet defines doGet and doPut methods which can be overridden by the real servlet to process the request. doGet and doPut eventually returns to the Servlet service method. There are more "do" methods for the other http request types such as "head" etc.
HttpServlet also defines 2 new objects, httpRequest and httpResponse to be used in place of the ServletRequest and ServletResponse objects.
HttpServlet defines doGet and doPut methods which can be overridden by the real servlet to process the request. doGet and doPut eventually returns to the Servlet service method. There are more "do" methods for the other http request types such as "head" etc.
HttpServlet also defines 2 new objects, httpRequest and httpResponse to be used in place of the ServletRequest and ServletResponse objects.
JavaScirpt Objects
A JS object is basically an associative array containing a series of key-value pair. To create a JS object, use the new keyword. For example,
Var obj1 = new Object();
Obj1.member1 = “this is member 1”;
Obj1.member2 = 3
Another way to create members of an object is to use square bracket (array?) notation:
Obj1[“member1”] = “this is member 1”
The square bracket notation has an advantage that it can use character not allowed for variable name because the member name is specified as string. For example, Obj1[“1”] works as single digit 1 is not allowed in variable name. Obj1.1 will flag as error by JS.
Array can be generalized (viewed alternatively) as an object with numeric keys (0, 1, 2, ..).
Sunday, June 18, 2017
GenericServlet
To implement the Servlet interface, one needs to provide classes for all methods specified in the interface, even if the method is not used by the servlet. To simplify coding, GenericServlet is an abstract class that implemented the Servlet inteface. GenericServlet supplies implementation for the method in the interface so that the real servlet class only needs to override those method it uses.
GenericServlet also saves the ServletConfig object passed by the servlet container to the init method in a persistent variable so the real servlet can access it later on. GenericServlet adds another init method with no argument for the real servlet to override with its specific code.
GeneicServlet is implemented as abstract class as it expects the real servlet implementation override one of more methods before it is used.
GenericServlet also saves the ServletConfig object passed by the servlet container to the init method in a persistent variable so the real servlet can access it later on. GenericServlet adds another init method with no argument for the real servlet to override with its specific code.
GeneicServlet is implemented as abstract class as it expects the real servlet implementation override one of more methods before it is used.
Servlet Interface
The Servlet interface specified s contract between the servlet container and the servlet. Servlet container calls the init method of the servlet one time during start up. When a request comes in, servlet engine calls the service method of the servlet to process it.
Servlet engine will also pass in a ServletConfig object to the servlet application's init method. ServletConfig contains initialization parameters. ServletConfig also provide a SrvletContext object. The ServleCcontext contains global data accessible by all classes in the servlet. In a distributed environment, each servlet instance can access the same ServletContext data.
Servlet also defines two objects - ServletRequest and ServletResponse that used by service method. ServletRequest defines methods to retrieve parameters submitted in a request. For example, "id" is the parameter which the method returns as string value.
http:::.../servlet?id=1
ServletResponse simplifies the returning of response to the client. It defines methods to let the application to write the response to a certain stream and let servlet container to handle the rest.
To implement a serlvet, one create a class implement the Servlet interface or extend a class that implemented the Servlet interface.
Servlet engine will also pass in a ServletConfig object to the servlet application's init method. ServletConfig contains initialization parameters. ServletConfig also provide a SrvletContext object. The ServleCcontext contains global data accessible by all classes in the servlet. In a distributed environment, each servlet instance can access the same ServletContext data.
Servlet also defines two objects - ServletRequest and ServletResponse that used by service method. ServletRequest defines methods to retrieve parameters submitted in a request. For example, "id" is the parameter which the method returns as string value.
http:::.../servlet?id=1
ServletResponse simplifies the returning of response to the client. It defines methods to let the application to write the response to a certain stream and let servlet container to handle the rest.
To implement a serlvet, one create a class implement the Servlet interface or extend a class that implemented the Servlet interface.
Subscribe to:
Posts (Atom)