Presentation is loading. Please wait.

Presentation is loading. Please wait.

Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Software Development using Oracle and Oracle Jaime Chavarriaga.

Similar presentations


Presentation on theme: "Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Software Development using Oracle and Oracle Jaime Chavarriaga."— Presentation transcript:

1 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Software Development using Oracle and Oracle Jaime Chavarriaga William Lovaton

2 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Initial Questions Can you develop enterprise applications using PHP? Using PHP and Oracle? What is the appropriated architecture for enterprise development using PHP and Oracle?

3 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Agenda Enterprise Applications –Differences with Web Applications Enterprise Applications Architecture –The (suggested) Software layers Development options using PHP and Oracle –Technological options –Implementation ideas Enterprise Applications Architecture using PHP and Oracle –The selected strategy A Case Study –Cicklos - Coomeva

4 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Are enterprise applications just like another web application?

5 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications The enterprise applications are different to traditional web applications –Even, when the enterprise applications are based on web technologies (http, html, xml, etc.)

6 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications The enterprise applications… –Include “business logic” (often complex, ever changing) –Include reports and user defined queries (ever growing number) –Must handle different user interface types and information needs. –Define different “views”. (Not all the users can access the same data and/or options) –Often include several data sources. –Often require integration with other enterprise applications (sync, web services, RPC, EDI)

7 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture The enterprise applications architecture must consider these differences… –The ever-changing business logic. –The multiple user interface views and options. –The ever-changing number of reports and queries. –The need for application integration strategies.

8 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture It’s necessary reuse the business logic –In every new interface / form / report It’s necessary keep the business logic… –Easy to maintain –Easy for detect/correct bugs Almost all the enterprise applications architecture are based on layers definition –Logic separation of the software. –Let you to isolate the changes on each one of the layers

9 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture What is a software (abstraction) layer? –The simplest explanation –If you duplicate functionality (i.e. validations, business processes, etc.) across all the application It’s harder to maintain It’s harder to detect the errors It’s harder to correct them

10 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture i.e., the database access… Mysql_connect(…) MySQL

11 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture If you define a function for that functionality… connect(…) MySQL function connect() { Mysql_connect(…) }

12 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture …it’s easier to maintain and detect errors. connect(…) PostgreSQL function connect() { pg_connect(…) }

13 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture The layers are created defining a interface to access a specific set of functionalities –Can be procedural- or object oriented-based interfaces (API). –To use these functionalities, the program must call these functions or class methods –The application is easier to maintain. –The application (can) get slower. Dilemma: maintainability vs. performance

14 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture Which are the layers for an enterprise application? About the layered architecture there are several proposals… –Three layers architecture (Fowler / Microsoft) Presentation – Domain Logic – Data Access –Five layers architecture (Brown) Presentation – Controller / Mediator – Domain Logic – Data Mapping – Data Sources Always… isolating the business logic.

15 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture The three layered architecture Presentation Layer Domain Logic Layer Data Access Layer Presentation Controllers View Components Domain logic components Data Access Components External Applications

16 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture The Business Logic The approach is create an abstraction layer for the business logic. There is two different architectural styles depending on the implementation of this business logic layer –Procedural style – using transaction modules. –OO style – using domain models.

17 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture Procedural style The procedural style is normally based on transaction script modules. –Modules running transactions over a database management system –Every use case is implemented issuing SQL statements or database server requests. –i.e: Database stored procedures MTS components (Microsoft DNA) Session EJB (Java)

18 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture Procedural style Transaction Module doUseCase1 (…) doUseCase2(…) : BEGIN TRANS… SELECT … INSERT … UPDATE … COMMIT … The transaction modules define the database operations to perform the business logic…

19 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture Procedural style Presentation Layer Domain Logic Layer Data Access Layer Front Controllers Template based view Transaction Scripts Data Gateways External Application s …but the business logic doesn’t should do SQL (must be isolated).

20 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture Procedural style Transaction Module doUseCase1 (…) doUseCase2(…) : Data Gateways get(…) getAll(…) update(…) delete(…) : SQL Statements Validations and Operations Data gateways (DAOs, in example) can be used for data access.

21 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture Procedural style The procedural style normally behave well with non-too complex domain logic –The business logic can be defined using simple algorithms The overall performance depends mainly on the speed of database connection / interaction. It fits perfectly in the nothing-shared PHP behavior approach

22 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture OO style The object oriented style is based on the handling of an domain object model. –Functions and methods executing operations over objects in memory. –The data must be loaded from databases to in- memory objects. –The operations over the objects must be mapped back to the database. –i.e: Components or Beans Entity EJB (Java)

23 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture OO style The use case controllers perform operations over object structures… Use Case Contollers doUseCase1(…) doUseCase2(…) : obj = Registro.get() obj.setValue(value) obj.remove(obj2) …

24 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture OO style Presentation Layer Domain Logic Layer Data Access Layer Front Controller Template based view External Application s Use Case Controllers Object Relational Mapper Collections Objects … the business logic don’t know anything about the database

25 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture OO style In the object oriented style the transactions requires the creation of objects in memory (upload) for all the transaction-related data. Map the data from the database to memory and write it back to the database represents one of the biggest performance issues. The application performance is often based on a shared object space. –Don’t load all the objects (lazy load) –Don’t load the object twice

26 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture OO style Use Case Controllers doUseCase1 (…) doUseCase2(…) :

27 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Applications Architecture OO style Currently, you cannot define a shared object space for different PHP processes (threads ) Normally… –You need load all the (necessary) objects, all the time –You can get better performance for OO business logic processing in other technologies (Java?) –In the future, SRM (Script Running Machine) and its “banana” PHP-programming, will offer a better OO solution.

28 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Implementing the Architecture How implement the architecture ?

29 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Implementing the Architecture A set of classes for business logic and data access are needed. Transaction Scripts + doOperation() + doOperation2() RowData Gateway + add() + remove() + update() + getAll() + getById()

30 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Implementing the Architecture The Business Logic : All in PHP <?php class BankAccountManager { function transferMoney ($originAccount, $targetAccount, $amount) { $data = DataGateway::get(“Accounts”); if($data->getBalance($originAccount) > $amount) { if ($data->decreaseBalance($originAccount, $amount) { $data->incrementBalance($destinationAmmount, $amount); } } } // other domain logic functions } ?>

31 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Implementing the Architecture The Business Logic in Oracle Two source code fragments are needed: –the specification and the body CREATE OR REPLACE PACKAGE BankAccountManager AS PROCEDURE transferMoney ( originAccount VARCHAR2(10), targetAccount VARCHAR2(10), amount NUMBER(9,2)) ; END BankAccountManager; /

32 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Implementing the Architecture The Business Logic in Oracle CREATE OR REPLACE PACKAGE BODY BankAccountManager AS PROCEDURE transferMoney ( originAccount VARCHAR2(10), targetAccount VARCHAR2(10), amount NUMBER(9,2)) IS balance NUMBER(9,2); BEGIN balance := BankAccountManager.getBalance(originAccount); IF balance > amount THEN BankAccountManager.decreaseBalance(originAccount, amount); BankAccountManager.increaseBalance(targetAccount, amount); END IF; END transferMoney; END BankAccountManager; /

33 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Implementing the Architecture The Business Logic : the PHP proxy <? class BankAccountManager { function transferMoney ($originAccount, $targetAccount, $amount) { // obtain an ADOdb connection with the proper config $db = ADOHandler::getConnection(); // build the calling code // the binding variables must include ‘:’ $plsql = "begin ". " :retval := ". " BanckAcountManager.transferMoney(". " :originAccount, :targetAccount, :amount); ". " end;";

34 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Implementing the Architecture The Business Logic : the PHP proxy // prepare the statement $stmt =& $db->Prepare($plsql); $db->Parameter($stmt, $retval, 'retval'); $db->Parameter($stmt, $originAccount, ' originAccount'); $db->Parameter($stmt, $targetAccount, 'targetAccount'); $db->Parameter($stmt, $amount, 'amount'); // execute the code $success = $db->Execute($stmt);

35 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Implementing the Architecture The Business Logic : the PHP proxy // there is an error ?? if (!$success) { trigger_error(("transferMoney error "), E_USER_WARNING); return FALSE; // the query returned a value } else if ($success->_numOfRows == 0 && isset($retval)) { return $retval; } // return the query result return $success; } ?>

36 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Implementing the Architecture Even, if you want, your program can select which business logic use.. –Including the full PHP business logic –Including the PHP-proxy for Oracle business logic –… you can use a PHP Object Factory

37 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Implementing the Architecture Selecting the business logic implementation <?php require_once “BankAccountManager.proxy.class”; // if you want, you can include the non-proxy php class // require_once “BankAccountManager.class”; // get the request parameters and call the function BankAccountManager::transferMoney ( $_REQUEST[‘originAccount’], $_REQUEST[‘targetAccount’], $_REQUEST[‘amount’]); ?>

38 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) PHP and Oracle Alternatives What options do you have when using PHP and Oracle?

39 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) PHP and Oracle Alternatives PHPOracle Presentation Domain Logic Data Access All in PHP… the database only as data store

40 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Use stored procedures for data handling PHP and Oracle Alternatives PHPOracle PL/SQL Presentation Domain Logic Data Access

41 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Use stored procedures for domain logic PHP and Oracle Alternatives PHPOracle PL/SQL Presentation Domain Logic Data Access

42 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Use java-based business logic (portable?) Oracle PHP and Oracle Alternatives PHPOracle Java EJB Presentation Domain Logic Data Access

43 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Architecture using PHP and Oracle What is the selected architecture ? Portability vs. Performance

44 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Architecture using PHP and Oracle The best of both worlds –Use PHP for the presentation logic. PHP (with opcode caching and template compiling) is a winner in web programming. –Use PL/SQL stored procedures for business logic and data access. 30% increase in insert performance 10 times improves on select speed http://php.weblogs.com/oracle_mysql_performance

45 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Use stored procedures for domain logic Architecture using PHP and Oracle PHPOracle PL/SQL Presentation Domain Logic Data Access

46 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Architecture using PHP and Oracle Something like this… Presentation Layer Domain Logic LayerData Access Layer Front Controller Template based view Transaction Scripts Basic Data Gateways Smarty plugins Action Commands Extended Data Gateways Proxy AuthACLLog

47 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Architecture using PHP and Oracle The database connection/access, the main bottleneck

48 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Coomeva Ciklos: A Case Study A real-life application

49 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Coomeva Ciklos: A Case Study General Architecture Gateways Table Modules Transaction Script Oracle ADODB Abstraction Layer BL ProxiesCache View SmartyBrowser Front Controller (PHRAME) PHP

50 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Coomeva Ciklos: A Case Study Web Servers PHP Turck mmCache Shared memory File-based cache Soon… Connection pool Business Logic Database servers Oracle Stored Procedures Databases

51 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Coomeva Ciklos: A Case Study Highlights of the Development Process MVC-2 pattern with a customized version of PHRAME Automatically generated gateways Automatic menu generation in JavaScript Error Handling and Logging Caching of data (AppCache) –File based cache (phpApplication) –Shared Memory based cache –Cache maintenance Performance monitoring

52 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Coomeva Ciklos: A Case Study Application Statistics 20 Offices around the country 480 PHP Sessions per day Up to 82 hits in the very same second 600 MB of access_log in seven days Memory consumption: –Only Apache: 2 GB (More than 200 Apache processes) –Apache and Tux: 800 MB (Up to 110 Apache processes) –Up to 16 MB for caching common data 58 Directories, 642 Files, Aprox. 500Kb of compressed code 8 Functional modules implementing business logic

53 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Coomeva Ciklos: A Case Study Optimization Strategies Always use a opcode caching system Tux – The kernel web server ADVX – Advanced extranet server (a modified Apache) SQLRelay – Database pool connection manager MSession – A session server with shared memory Caching database result sets in the application server Dynamic content compression (with PHP) Static content compression (with Tux) Turn off register globals Caching dynamic content (404 Error) Use the ADODB PHP module (C code runs faster)

54 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Coomeva Ciklos: A Case Study The Working Team Claudia Liliana Jaramillo (PHP Developer) William Alberto Lovaton (PHP Developer) Juan Carlos Madrid (Oracle Developer) Patricia Velez (Oracle Developer) Carlos Augusto Penilla (Graphic Designer) Farid Buenaventura (Process Engineer, Trainer) Monica Marcela Arias (Process Engineer) Jorge Arturo Zapata (Stake Holder, Trainer) Maria de Vuono (Stake Holder) Jesus Alberto Bolaños (Project Leader) Jaime Alberto Chavarriaga (Project Consultant)

55 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) In the future A better business logic framework Automatically generated Applications based on database metadata Development environments with better support for business logic / stored procedures

56 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Additional Resources Where can i learn more?

57 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Additional Resources Books –Martin Fowler et al. Patterns of Enterprise Applications Architecture. –Johnson et Al. Evolving Frameworks. –IBM. San Francisco Design Patterns / e- Business Design Patterns

58 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Additional Resources Web Sites –Martin Fowler website http://www.martinfowler.com –Design Patterns for eBusiness http://www.ibm.com/sanfrancisco –PHP optimization / PHP and oracle performance http://php.weblogs.com

59 Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Questions


Download ppt "Jaime Chavarriaga William Lovaton Universidad San Buenaventura - Coomeva EPS (Colombia) Enterprise Software Development using Oracle and Oracle Jaime Chavarriaga."

Similar presentations


Ads by Google