<JSTORM> Design Pattern - API JSTORM http://www.jstorm.pe.kr -1-
java API 2000-08-14 Public 2000-08-16 Draft (dbin@handysoft.co.kr), (pam@emotion.co.kr) HISTORY (csecau@orgio.net) 2001/2/15 9 10 jstorm pdf. -2-
-3-
caller callee interface subclass superclass getinfo() -4-
caller interface callee getinfo() interface->getinfo() interface getinfo() callee2 getinfo() -5-
1. 1-6-
: ç -7-
-8-
-9- JDBCHelper JDBCHelper() connect() close() commit() next() select() update() getstring() getstring() getint() getint() getfloat() getfloat() getdate() getdate()
-10-
-11- JDBCHelper2 JDBCHelper() connect() close() commit() next() select() update() getstring() getstring() getint() getint() getfloat() getfloat() getdate() getdate() preparedstatement() pstmtsetstring() pstmtsetfloat() pstmtsetint() pstmtsetnull() pstmtselect() pstmtupdate()
JDBCHelper3 JDBCHelper() connect() close() commit() next() select() update() getstring() getstring() getint() getint() getfloat() getfloat() getdate() getdate() preparedstatement() pstmtsetstring() pstmtsetfloat() pstmtsetint() pstmtsetnull() pstmtselect() pstmtupdate() callablestatement() cstmtsetstring() cstmtsetfloat() cstmtsetint() cstmtsetnull() cstmtupdate() cstmtregisteroutparameter() -12-
-13-
-14-
ç ç ç -15-
ç -16-
JDBCHelperFactory createjdbchelper() getfactory() <<Interface>> JDBCHelperFactoryIF <<Interface>> JDBCHelper connect() close() commit() next() select() update() getstring() getstring() getint() getint() getfloat() getfloat() getdate() getdate() setstring() setfloat() setint() setnull() regoutparameter() JDBCStatementHelper JDBCPreparedStatementHelper createjdbchelper() 1. 2 PreparedStatement JDBC Helper - Factory Method Pattern -17-
-18-
-19- JDBCHelper connect() begintransaction() commt() select() update() getstring() getstring() getint() getint() getfloat() getfloat() getdate() getdate() setstring() setfloat() setint() setnull() regoutparameter() <<Interface>> JDBCStatementHelper JDBCPreparedStatementHelper JDBCHelperFactory getfactory() JDBCHelperFactoryIF getfactory() <<Interface>> JDBCCallableStatementHelper
CodeConverter convertfromdefault() converttodefault() createconverter() CodeConvert8859_1 convertfromdefault() converttodefault() CodeConverterKSC560 1 convertfromdefault() converttodefault() -20-
-21-
-22- SQLFactory createsqlfactory() getsearchsql() AnsiSQLFactory getsearchsql() OracleSQLFactory getsearchsql() MSSQLServerSQL Factory getsearchsql()
-23- : (Cache Management Pattern) 1 Refactoring : :.
-24-
2 GOF : Gang of Four : Design Pattern : the reusable Object 4 GOF Book.. -25-
-26-
-27-
-28-
-29-
-30-
-31-
Box ç ç ç Client uses Facade class1 class2 2. 3 Facade Pattern -32-
Product CreationRequestor operation1() operation2() requests-creation ConcreteProdu ct operation1() operation2() FactoryIF createproduct() Factory createproduct() 3. 4 Factory Method Pattern -33-
Client AbstractStrategy operation() ConcreteStrategy1 ConcreteStrategy2 operation() 4. 5 Strategy Pattern operation() -34-
-35-
??? (Refactoring).,.......,.. -36-
Extract Method. void printowing(double amount) { printbanner(); //printdetails System.out.println( name: +_name); System.out.println( amount: +amount); }, printdetails. void printowing(double amount) { } printbanner(); printdetails(amount); void printdetails(double amount) { } System.out.println( name: +_name); System.out.println( amount: +amount); Extract Method.....,. Refactoring : Improving the Design of Existing Code,1999... -37-
. (Anti-Pattern)......,,.. 6 5. 3 1. 2....(from www.antipatterns.com)...?.. 3. - : - : - : -.. - (Spaghetti Code ) :. - ( Stovepipe System ) :. - (Analysis Paralysis ) : -38-
. - (Swiss Army Knife ) :. - ( Ambiguous Viewpoint ) :.. - Anti Patterns : Refactoring Software, Architectures, and Projects in Crisis,1998 by William J.Brown & - Anti Patterns and Patterns in Software Configuration Management, 1998 by William J.Brown & -39-
1. -40-
5. 6 - System Use Case -41-
6. 7 3 Produce-Consumer Model -42-
-43-7. 8 -
-44-8. 9
-45-9. 10.
- - - -46-
1. 2 : Request Diispatcher Exception -47-
-48-
: RequestDispatcher : ServerSocket : MasterThread : ServerProtocolHandler : ServerProtocolHandlerIF : ObjectInputStream : Command : ObjectOutputStream while loop start while loop end 1: ServerSocket(int) 2: accept( ) 3: MasterThread(Socket) 4: start( ) 5: getinstance( ) 6: getcommand(inputstream) 7: readobject( ) 8: execute( ) 9: send(outputstream, Object) 10: writeobject(object) -49-
-50-
-51-
RequestDispatcher (from server) port : int RequestDispatcher() run() main() MasterThread (from server) $ SOCKET_TIME_OUT : int = 300000 MasterThread() run() -$handler ServerProtocolHa ndlerif (from server) send() getcommand() ServerProtocolHandler (from server) ServerProtocolHandler() getinstance() getcommand() send() Command (from cmd) execute() getname() -52-
: Client : : EchoCommand ClientProtocolHandler : ClientProtocolHandlerIF : Socket : ObjectOutputStream : ObjectInputStream 1: setstring(string) 2: connect( ) 3: Socket(String, int) 4: getinstance( ) 5: sendcommand(inputstream, OutputStream, Command) 6: writeobject(object) 7: readobject( ) -53-
-54-
ServerException (from client) Client $ SOCKET_TIME_OUT : int = 300000 port : int Client() connect() run() main() (from client) ServerException() ServerException() ClientProtocolHandler (from client) ClientProtocolHandler() getinstance() send() receive() sendcommand() EchoCommand (from cmd) setstring() execute() getname() -$handler ClientProtocolHandl erif (from client) Command sendcommand() (from cmd) execute() getname() 4 40. -55-
-56-
-57-
-58-
: RequestDispatcher : ServerSocket : MasterThread : ServerProtocolHandler : ServerProtocolHandlerIF : ObjectInputStream : CommandQueue : Queue : Command : ObjectOutputStream 1: ServerSocket(int) 2: accept( ) 3: MasterThread(Socket) 4: start( ) 5: getinstance( ) 6: getcommand(inputstream) 7: readobject( ) CommandQueue.push, CommandQueue.pop added 8: push(command) 9: push(object) 10: wait() 11: execute( ) 12: send(outputstream, Object) 13: pop( ) 14: pop( ) 15: notify( ) -59-
Invoker AbstractCo mmand Manages 1 doit() 0..n +creator/invoker undoit() 1 CommandManager Creates-and-invokes +invokeeconcreatec ommand 0..n doit() undoit() -60-
-61-