1 / 11

Architectures

Architectures. Classic Client/Server Architecture Classic Web Architecture N-tier (multi-tier) Architecture. Classic Client/Server Architecture. Client: User interface (presentation) (and maybe some business logic). Application: Business logic and calls to the database server.

gali
Download Presentation

Architectures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Architectures Classic Client/Server Architecture Classic Web Architecture N-tier (multi-tier) Architecture Databaser og Modellering

  2. Classic Client/Server Architecture • Client: User interface (presentation) (and maybe some business logic). • Application: Business logic and calls to the database server. • Database server: For instance some SQL-based DBMS. Dedicated Client Application Server Database Server DB Databaser og Modellering

  3. Classic Web Architecture • Client: User interface (presentation) (and maybe some business logic). • Application: Business logic and calls to the database server. • Database server: For instance some SQL-based DBMS. • Web server: Accesses the database server and generates HTML response to the client. • Browser: Presentation (and maybe some business logic in form of scripts embedded in the HTML) Browser Client Internet Web Server Dedicated Client Application Server Database Server DB Databaser og Modellering

  4. Problems with the Classic Web Architecture • Much business logic (code) is duplicated in the web server. • No re-use. • Difficult maintenance. • And what if we want to add a new client (a smart phone, for instance)? Browser Client Internet Web Server Dedicated Client Application Server Database Server DB Databaser og Modellering

  5. N-tier (multi-tier) Architecture • Database access layer: All code to access database is here. Makes it possible to change data store. • Web server accesses application layer – not the database directly. • Easier maintenance: • No business logic in the web server (or other clients). • Application server: All (almost) business logic is re-used. • New client may be added without code duplication. Client accessing web services Browser Client Internet Dedicated Client Web Server Application Server Backend Database Server Mobile Client New Dedicated Client Database Access Layer DB Databaser og Modellering

  6. Sample Application - Architecture • Architecture: • The Controller is responsible for communication with the database connection classes (DBLayer). • The DBLayer encapsulates the code for accessing the database and stores and builds objects. • The DBLayer takes the role of containers. View Code SQL Server Databaser og Modellering

  7. Architecture – in Visual Studio • One Solution – 5 projects, each project having its own namespace. • Architecture: • Model: (old Banking4). The controller is put in its own project: Controller. • Banking5 is the old GUI. • The DBLayer has classes for accessing the database and storing and building objects. • BankingWithFullMonty is the main project with the new start-up form Databaser og Modellering

  8. DBLayer • We use a SQL Server Database. • The Class AccessDbSQLClient is responsible for opening and closing the connection and for creating a Command object that can be passed to the SQL Server. • The class CustomerDBSQLClient is responsible for retrieving and storing Customer objects in the database. Databaser og Modellering

  9. The Controller //public void AddCustomer(Customer c) //{ // customers.Add(c); //} public void AddCustomer(Customer c) { CustomerDBSQLClient.CreateCustomer(c.CustNo, c.Name); } //public List<Customer> Customers //{ // get { return customers; } //} public List<Customer> Customers { get { return CustomerDBSQLClient.GetCustomers(); } } • Old implementation using lists is changed • Instead we use calls to the database. Databaser og Modellering

  10. The Controller //public Customer GetCustomer(int no) //{ // //if customer not found, null is returned // Customer c = null; // inti = 0; // bool found = false; // while (!found && i < customers.Count) // { // c = customers[i]; // if (c.CustNo == no) // found = true; // else // i++; // } // return c; //} public Customer GetCustomer(int no) { return CustomerDBSQLClient.FindCustomerByNo(no); } • Complex search loops are replaced by calls to the database. Databaser og Modellering

  11. class CustomerDBSQLClient public static Customer FindCustomerByNo(intcustNo) { string sql = @"select * from Customer where custNo = " +custNo; dbCmd = AccessDbSQLClient.GetDbCommand(sql); IDataReaderdbReader; dbReader = dbCmd.ExecuteReader(); Customer c; if (dbReader.Read()) c = new Customer(Convert.ToInt32(dbReader["custNo"].ToString()), dbReader["name"].ToString()); else c = null; dbReader.Close(); AccessDbSQLClient.Close(); return c; } The SQL Statement is build Command object with this SQL statement is build The command is sent to the SQL Server and executed The result is returned in a reader object – The Customer object is build from the reader DB Connection is closed Eventually the Customer object is returned. Databaser og Modellering

More Related