Wednesday, April 22, 2009

Design Patterns

Definitions on this blog came from the book Head First Design Patterns.

  • Strategy pattern - defines a family of algorithms, ancapsulate each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

  • From http://www.ida.liu.se

  • Observer pattern - defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
    - think Swing/GUI

  • From http://kur2003.if.itb.ac.id

    Using Java's built-in Observer pattern (allows observer to pull data from observable)...
    From http://kur2003.if.itb.ac.id


  • Decorator pattern - attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.
    - think Java I/O

  • From http://oreilly.com



Ref:
Head First Design Patterns by By Eric Freeman, Elisabeth Robson, Kathy Sierra, and Bert Bates

Monday, April 13, 2009

Web Application Basics

HTTP - Hypertext Transfer (or Transport) Protocol), is a connectionless protocol for communicating clients/browsers and web servers

TCP/IP - Transmission Control Protocol, allows communication between your application software. It is responsible for breaking data down into IP packets before they are sent, and for assembling the packets when they arrive.
-connection oriented
-used to make connections and exchange information to one another
IP - Internet Protocol, is responsible for sending the packets to the correct destination
- connectionless

URL -Uniform Resource Locator, is a full specification of a resource. It includes the protocol, host machine name (domain name or IP address), optional protocol number and resource location.
Three ranges of port numbers:
  1. well-known ports - from 0 through 1023
    20 & 21: File Transfer Protocol (FTP)
    22: Secure Shell (SSH)
    23: Telnet remote login service
    25: Simple Mail Transfer Protocol (SMTP)
    53: Domain Name System (DNS) service
    80: Hypertext Transfer Protocol (HTTP) used in the World Wide Web
    110: Post Office Protocol (POP3)
    119: Network News Transfer Protocol (NNTP)
    143: Internet Message Access Protocol (IMAP)
    161: Simple Network Management Protocol (SNMP)
    194: Internet Relay Chat (IRC)
    443: HTTP Secure (HTTPS)
    465: SMTP Secure (SMTPS)
  2. the registered ports - from 1024 through 49151
    - they can be registered to specific protocols by software corporations/companies or users
    - assigned by or registered to Internet Assigned Numbers Authority (IANA) (or by Internet Corporation for Assigned Names and Numbers (ICANN) before March 21, 2001[1])
  3. dynamic or private ports - from 49152 through 65535
    - available for use by any application or just about anybody
HTML - is the principal language b/w the client and server that expresses content of webpages.



  • DOM - is an interface to the browser and HTML/XML documents.

  • DHTML
    Dynamic HTML is a term used to describe the combination of HTML, style sheets, and scripts that allow dynamic pages.

  • Javascript - is the most common scripting language for browsers.

  • Inversion of Control and Dependency Injection

  • Martin Fowler, who first coined Dependency Injection, considers it the same to Inversion of Control. He used Dependency Injection since he finds Inversion of Control too generic. However, other sources claim that Dependency Injection is just a form of Inversion of Control. With all the articles and blogs written about them, it is very easy to get confused. So I'll try to summarize their description here according to my own understanding and hopefully, it will be simple and easy to understand.

    Inversion of Control is a general principle in which the flow of control is inverted, unlike the traditional sequential flow. It follows the "Hollywood principle" - "don't call us, we'll call you". Your objects don't call services directly. Instead, your objects expect to be called. It is the framework that manages the objects and services, and is aware of what to instantiate and invoke.

    The main idea of Inversion of Control is to have none of your classes know or care how they get the objects they depend on.

    Dependency Injection is a way of implementing Inversion of Control in which an external mechanism is supplied in order for your objects not to call services (other objects) directly and therefore not depend on them. The external mechanism is the one responsible in injecting the concrete implementation that your objects needed.

  • Loose coupling - describes a relationship of two entities/objects where they can interact, but have very little knowledge of each other.


To r: inline css vs external css
What is robustness?
Disadvan of frames

Website-static
Webapp-dynamic

Get vs post- when to use get?

Session - uses cookies

Enabling technoligies:
Compiled modules-java servlets
Interpreted scripts-jsp