Java Basics

  1. Inversion Of Control
    Object coupling is bound at run time by an "assembler" object

    • based on how they are used
    • based on their interaction with each other

    objects give their own dependencys
  2. Inheritance
    Concrete class extends another

    • is - a relationship
    • extends
    • implements

    'concrete' = commonalitys
  3. Containers
    the interface between a component and the low-level platform specific functionality that supports that component.

    before a component can be executed; it must be deployed into its container
  4. what is a web container
    servlet or jsp = web container

    manages the execution of jsp page and servlet components
  5. Dependancy Injection
    needs at least 3 elements

    • 1) a dependent consumer
    • 2) a declaration of components dependencies, defined as interface contracts
    • 3) an injector (provider or container) creates instances of classes that implement a given depenency interface or request

    ex.. the dependant object (1) describes what software component it depends on to do its work (2) the injector decides what concrete classes satisfy the requirements (3) and send those classes to the dependant object
  6. Servlet

    programs that run on the web server and build web pages
  7. Association
    a relationship between 2 classes where one class uses another (general)

    • a - relationship
    • ex.. rooms are in a house
  8. Aggregation
    a special type of association

    • the - relationship
    • ex.. house is the aggregator of the room
    • no room without a house
  9. Composition
    a special type of aggregation

    • has - a - relationship
    • ex.. house has rooms

    house is a composite object
  10. whats the difference between association, aggregation, composition
    • aggregation is a special type of association..
    • composition is a special type of aggregation

    • association = general
    • aggregation = middle
    • composition = core
  11. Decoupling
    careful controls that seperate code modules from particular use cases

    increases code re-useability

    ex.. polymorphically decouple the encapsulation (using a method interface which an encapsulated object must satisfy)

    • Bridge pattern
    • Adapter pattern
  12. Abstraction
    • reduce complexity by a supression of detail
    • what an object 'is' or 'does' not how

    • hide irrelevant details
    • an emphasis on the idea
  13. Generalization
    reduces complexity by elimination similurities

    replacing multiple entities which perform simular functions with a single construct

    • = Polymorphism
    • an emphisis on the similarities between objects
  14. Parameterization
    Abstracts are generalized through 'parameterization' to provide greater unity

    • 1) one or more parts of an entity are replaced with a name which is new to the entity
    • 2) the name is used as a parameter
    • 3) when the parameterized abstract is invoked, it is invoked with a binding of the parameter to an arguement

    ex.. Hibernate
  15. JSP
    java server pages

    • action = 'resource'
    • method = 'GET / POST'
  16. Container Services
    • lifecycle management
    • security
    • deployment
    • threading

    runtime support of a system-level entity
  17. XML - RPC
    xml remote procedure calls

    loose coupled web service
  18. SOAP
    simple object access protocol

    • basic messaging framework (3) parts
    • 1) envelop = what is in the message and how to process it
    • 2) encoding rules = how to express instances of application - defined datatypes
    • 3) convention for representing procedure calls and responces

    Extensibility, Neutrality, Independence
  19. Collections

    • List = FIFO
    • Set = FI?O
    • Map = (key, value)
  20. Transaction Management in EJB

    • Atomic = all or nothing
    • Consistancy = all updated together
    • Isolation = only user can see info until complete
    • Durability = once complete all users can see
  21. Life Cycle of Session Beans
    • STATELESS ........./........... STATEFULL
    • .........................................(remembers info)

    • ejbCreate(); ........................... ejbCreate();
    • init(); .......................................init();
    • ejbActivate();
    • ServiceMethods(); ...................ejbService();
    • ejbDestroy(); ...........................ejbPassivate();
  22. EJB
    • Enterprise Java Bean = a server side component that encapsulates the business logic of an application
    • ex...
    • login()
    • chechOut()
    • uploadPic()

    • Session Beans = Stateless / Statefull
    • Entity Beans = (ORM) Object Relational Mapping ex.. Hibernate
    • Message Beans = Java Messaging Service
  23. EJB Container
    provides system level services to the BEAN

    • ex..
    • transactionManagement()
    • securityAuthorization()
  24. Session Bean
    represents a single client inside the server

    • not shared
    • data is not saved
  25. Entity Bean

    represents a business object in a DB

    • persistant - still exists after the server process
    • sharred - transactions (EJB container)
    • have primary keys
    • can be a join
  26. Message Driven Bean
    • allows applications to process messages asynchronously
    • acts as the JMS Listener (recieves messages)
    • clients do not access
    • retain no data
  27. Transactions
    a block of statements

    • commit();
    • rollback();
  28. JDBC

    • Connection to DB
    • Statement SQL
    • ResultSet = answer
  29. Type Safe
    you can only use one kind of 'type'

    ex.. Box<Integer> boxInt = new Box<Integer>();
  30. How to understand a System
    Identify the module of the system

    then dig deep into each module seperately to seek out classes
  31. How to identify a Class
    • 1) fully list the leaf level functions / operations of the system (granular level use case)
    • 2) group each function to form classes (classes will group same types of functions / operations)

    a well defined class must ba a meaningfull grouping of a set of functions and should support the re-useability while increasing expandability
  32. How to design a Class
    • 1) SRP = Single Respository Principle
    • a class should have 1 and only 1 reason to change.
    • 2) OCP = Open Closed Principle
    • you should be able to extend a class, without modifying it.
    • 3) LSP = L Substitution Principle
    • derived classes must be sustainable for their base classes.
    • 4) DIP = Dependency Inversion Principle
    • depend on abstractions, not conretions.
    • 5) ISP = Interface Segregation Principle
    • make fine grained interfaces - client specific
  33. Class
    • 1) name
    • 2) attributes
    • 3) operations

    a representation of a type of object

    it is the BLUEPRINT, PLAN, TEMPLATE that describes the details of an object
  34. OOP
    a group of self sustainable objects

    a class represents these objects

    in order to manage these classes of a system and reduce complexity, designers use

    • Encapsulation
    • Abstraction
    • Inheritance
    • Polymorphism
  35. The primary goal of Software Architecture
    • define non - functional requirements of a system
    • define the environment
  36. Define Software Architecture
    The Rules, Heuristics, and Patterns governing:

    • 1) Partitioning the problem/system into discrete pieces
    • 2) Techinques used to create interfaces between pieces
    • 3) Techniques used to manage overall structure and flow
    • 4) Techniques used to interface the system to its environment
    • 5) Appropriate use of development and delivery approaches, techniques, and tools
  37. Why Architecture is important
    • controls complexity
    • enforces best practices
    • gives consistency, and uniformity
    • increases predictability
    • enables re-use
  38. Date Access Layer
    Basic interactions with DB


    • Create
    • Retrieve
    • Update
    • Delete

    this should be simple and efficient
  39. SOA
    Service Oriented Architecture

    seperates functions into Services which are available over a network in order to allow developers to combine, and reuse in the production of applications
  40. Use Case
    a thing an actor percieves from the system

    maps actors with functions

    defines the requirements for your system
  41. Method Overriding
    Allows a subclass to override a specific implementation of a method that is already provided by one of its super - classes
  42. Static
    a variable or functions associated with a class... rather than with objects of a class

    does not need impementation
  43. Encapsulation
    ex.. Interface

    • keeping or making the fields in a class private.
    • providing access to the fields via public methods

    • .get()
    • .set()
  44. Polymorphism
    the ability of an object to take on many forms

    the ability to request that the same operations be performed by a wide range of different types of things
  45. Interface
    Divide and Conquer

    • contains no method bodies
    • all methods must be used

    seperates the implementation and defines the structure

    • - must be implemented
    • - you can implement more than one interface
  46. Protected
    Only visible to the class itself, its subclasses, and classes in the same package
  47. Abstract Class
    • cannot be instantiated
    • can only be used as a super - class for other classes that extend the abstract class

    • more flexable than an interface
    • can provide some default behavior for base class
  48. Abstract Class vs. an Interface
    Abstract Class can not be instantiated.. it only allows other classes to inherit from it

    Interface has no implementation.. just empty methods without a body

    the main difference is that an class can implement more than one interface, but can only inherit from one class (abstract or not) interfaces are used for multiple inheritance..

    Flexability; Abstract classes are flexable because you can use only what you need from it.. while an interface requires that you implement all of its methods.
  49. Messaging
    an exchange of messages between software components

    • loosely coupled
    • indirect communication
    • senders do not need to have knowlege of recievers
  50. Superset vs Subset
    'a' is inside of 'b'

    • = 'a' is a subset of 'b'
    • = 'b' is a superset of 'a'
  51. Final
    a final Class can no longer be subclasses

    a final Method can not be overiddon

    a final Field can not be changed
  52. final vs. finally vs. finalize
    final = constant declaration (can not be changed)

    • finally() = finally block
    • try() {
    • }catch() {
    • }finally() { // used to release resources irrespective of expectations
    • }

    finalize() = a method that is invoked before an object is discarded by garbage collection
  53. What is the difference between

    • requestDispatcher() = server side redirect with
    • request objects
    • response objects

    • sendRedirect() = client side redirect with
    • new request objects
    • new response objects
  54. Generic Types
    a special kind of variable, whose 'value' will be whatever type you pass in

    • E - element
    • k - key
    • N - number
    • T - Type (most common)
    • V - value
  55. Synchronization
    threat safe

    it places a lock or hold on the method or block preventing two objects from accessing the same block or method at the same time.
  56. Synchronized Block vs. Synchronized Method
    synchronized blocks place locks for shorter periods than synchronized methods
  57. How do I find wheather a parameter exists in a request object?
    boolean hasParameter = request.getParameterMap().contains(theParameter);
  58. Casting
    the process of converting data from one type to another

    • implicit
    • explicit
  59. Implicit Casting
    • automatic type casting by the compiler
    • data of one or more subtypes can be converted to a supertype

    • ex..
    • double d;
    • long l;

    if(d > l) d = l;
  60. Explicit Casting
    needs to be done in the program

    • ex..
    • double da = 3.3;
    • double db = 3.3;

    int result = (int)da + (int)db;
  61. Parser
    the process of analyzing a text made up of a sequence of tokens.

    analyzing a group of words
  62. How do xml Parsers differ
    by the relationship between the xml parser client

    1) DOM Parser = returns a 'tree' of the document

    2) PUSH Parser = call clients methods with xml events

    3) PULL Parser = returns xml events to a client on request
  63. Difference between SAX & DOM Parsers
    • SAX = simple API for xml (small)
    • does not create any internal structure instead it takes the occurances of the components of an import document as 'EVENTS' and tells the client what it reads through the input document

    • DOM = document object model (big)
    • create a 'TREE' structure in memory from an input document and then waits for requests from client
Card Set
Java Basics
java basics