Successfully reported this slideshow.

More Related Content

Related Audiobooks

Free with a 14 day trial from Scribd

See all

CG_CS25010_Lecture

  1. 1. Enterprise Systems & Frameworks CS25010 - Web Programming Connor Goddard 5th November 2015 Aberystwyth University 1
  2. 2. INTRODUCTION In today’s session, we will aim to cover the following: • Multi-tier Architectural Patterns • Enterprise Systems • Web Frameworks 2
  3. 3. INTRODUCTION If you’re on Twitter, jump on your phones! During the presentation, look out for tweets from @cgddrd with the hashtag #cs25010. These tweets will contain links to other material you may find useful. Feel free to tweet back with any questions. 3
  4. 4. A LITTLE BIT ABOUT ME I’m a fifth-(and final!)-year MEng Software Engineering student. Previous web modules include: CS15020, CS25010, CS25210, SE31520 & SEM5640 (so pretty much them all…) I spent my IY working at Renishaw plc, developing advanced web and mobile applications (Android, iOS & hybrid) I’ve played around with most web-related technologies including: • PHP, ASP.NET, Node.js, Ruby-on-Rails, Python & OO-Javascript 4
  5. 5. WEB APPLICATIONS • What do we mean by a “web application”? • What makes a web application different to other applications? • Where does “the cloud” fit into it all? 5
  6. 6. WEB APPLICATIONS To a typical consumer, web applications can appear… mystical. Most do not appreciate all that has to go on “under the hood”. What problems could this present on development projects? 6 [1] [1] http://imgflip.com
  7. 7. ENTERPRISE SYSTEMS When designing non-trivial web applications, we typically will want to decompose the system into smaller parts. • Separate presentation from business logic and data sources. • Possibly delegate across multiple servers. These are known as “multi-tier/n-tier” or “enterprise” systems. As a consequence, interconnectivity between separate systems and their servers becomes essential. 7
  8. 8. MULTI-TIER ARCHITECTURES 8 Web Server Application Server Database Server [1] https://en.wikipedia.org/wiki/Multitier_architecture
  9. 9. MULTI-TIER ARCHITECTURES 9 Web Server Application Server Database Server Model View Controller e.g. HTML, ASP.NET, PHP, JSP, XML, JSON e.g. PHP, JavaBeans, C#, Ruby Business Logic Business Objects Business Objects RDBMS File StoresOO-DMS e.g. MySQL, PostgreSQL, MongoDB, XML Presentation Tier Logic Tier Data Tier
  10. 10. MULTI-TIER ARCHITECTURES 10 Example: Online Store Presentation Layer Logic Layer Data Layer
  11. 11. MULTI-TIER ARCHITECTURES There is a distinction between tiers and layers. What is the difference between the two terms? 11
  12. 12. MULTI-TIER ARCHITECTURES There is a clear distinction between tiers and layers. What is the difference between the two terms? ‣ Layer: Logical organisation/separation of code (e.g. separating code associated with presentation from that of business logic) ‣ Tier: Physical deployment of layers (e.g. across multiple servers) 12
  13. 13. MULTI-TIER ARCHITECTURES Why would we want to use multi-tier systems? • What would be the advantages? • What would be the disadvantages? 13
  14. 14. MULTI-TIER ARCHITECTURES Why would we want to use multi-tier systems? Advantages: • Separation of concerns • Improved scalability • Help to avoid single point of failure • Improved problem solving/bug tracking (isolation of issues to specific part of system) • Easier mapping of system entities to developer workload Disadvantages: • Could prove to be ‘overkill’ for very small projects • Likely increase in code size and complexity • Steeper learning curve - greater potential for bugs to be introduced • Use of M-TA introduces greater risk for poor design choices - these can become expensive to fix later • Easier mapping of system entities to developer workload - “Too many cooks spoil the broth.” 14
  15. 15. WEB FRAMEWORKS 15
  16. 16. WEB FRAMEWORKS What frameworks do people know about? Has anyone got any preferred frameworks? 16
  17. 17. WEB FRAMEWORKS 17 PHP C# / VB / F# Adobe Coldfusion Javascript PHP Javascript Ruby
  18. 18. WEB FRAMEWORKS 18 Good community support High feature set Long history Fast and easy to scale Simple to set-up Lightweight + good community support Many tools ‘out of the box’
  19. 19. WEB FRAMEWORKS Frameworks aim to assist in the development of web applications by alleviating some of the overhead associated with common tasks: • Database access, ORM, templates, authorisation, web services, scaffolding, testing, caching, session management etc. Web frameworks are not the same as CMS software (e.g. Wordpress or Drupal) • Frameworks provide general solutions to developing web applications. • CMS software builds on top of underlying frameworks. 19
  20. 20. SCAFFOLDING Scaffolding refers to a process whereby the ‘skeleton’ of an application is automatically generated by the web framework. 20 Typically the reference to a database is given, from which the code relating to standard CRUD operations is enacted without input from the developer. Scaffolded systems provide a good starting point from which the main application can be built upon. [1] https://scaffoldinginsouthwest.wordpress.com/ [1]
  21. 21. SCAFFOLDING - RoR One of the first ‘mainstream’ frameworks to support scaffolding was Ruby-on-Rails. Generating a new web application in RoR takes 3 lines of code: 21 1 # Step 1: Generate new web application. 2 rails new mywebapp && cd mywebapp 3 4 # Step 2: Create new model entity and scaffold 5 CRUD operations (controller and views). 6 rails generate scaffold User surname firstname 7 age:integer is_student:boolean 8 9 # Step 3: Migrate the new model into SQLite 10 database (pre-created) 11 rake db:migrate 12 13 # Step 4: Start the server (navigate to http://<url>/users) 14 rails server
  22. 22. SCAFFOLDING - ASP.NET ASP.NET is another framework that provides automatic creation of web controllers and views from a pre-existing data model. This is particularly useful within MVC projects where we are also utilising object-relational mapping. 22
  23. 23. OBJECT-RELATIONAL MAPPING Object-relational mapping (ORM) provides a mechanism for representing and querying relational entities using an object- based paradigm. In other words: ORM allows us to map data stored in a relational/tabular format into an OO format for use in applications. ORM helps to address an issue known as ‘Object-Relational Impedance Mismatch’. 23
  24. 24. OBJECT-RELATIONAL MAPPING Relational - Object mapping: With ORM, it doesn’t matter what persistent storage mechanism we are using (e.g. MySQL, NoSQL, XML data files etc.) The framework handles this all for us. 24 Relational Model ORM Table Class Row Instance Field Property
  25. 25. FRAMEWORKS, ORM & MVC Many frameworks adopt an MVC pattern, supported by mechanisms including scaffolding and ORM. 25 Generated via ORM Class for each model responsible for: • Handling incoming requests • Retrieving model data • Re-directing user to appropriate view templates Template files used to render dynamic data to end user (e.g. HTML, XML, JSON) [1] https://en.wikipedia.org/wiki/Model–view–controller [1]
  26. 26. MVC - MODEL 26 ASP.NET (C#) PHP 1 namespace HelloMVC.Models 2 { 3 public class BlogPost 4 { 5 6 public virtual int Id 7 { 8 get; set; 9 10 } 11 12 public virtual string Title 13 { 14 get; set; 15 16 } 17 18 } 19 } 1 <?php 2 3 class BlogPost { 4 5 public $id; 6 public $title; 7 8 public function __construct($id, $title) { 9 $this->id = $id; 10 $this->title = $title 11 } 12 13 function save(); 14 function setTitle(); 15 ... 16 17 } ?>
  27. 27. 1 namespace HelloMVC.Controllers 2 { 3 public class BlogPostController : Controller 4 { 5 private HelloMVCContext db = new HelloMVCContext(); 6 7 public ActionResult Index() 8 { 9 return View(db.BlogPosts.ToList()); 10 } 11 12 public ActionResult Create() 13 { 14 return View(); 15 } 16 17 [HttpPost] 18 [ValidateAntiForgeryToken] 19 public ActionResult Create([Bind(Include = "Id,Title")] BlogPost blogPost) 20 { 21 if (ModelState.IsValid) 22 { 23 db.BlogPosts.Add(blogPost); 24 db.SaveChanges(); 25 return RedirectToAction("Index"); 26 } 27 28 return View(blogPost); 29 } 30 } 31 } MVC - CONTROLLER 27 ASP.NET (C#) PHP 1 <?php 2 3 class BlogController { 4 5 function indexAction(); 6 function createAction(); 7 8 ... 9 10 } ?> GET Request POST Request
  28. 28. MVC - VIEW 28 1 {% block title %}Blog Posts{% endblock %} 2 3 {% block body %} 4 5 <h2>List of Posts</h2> 6 7 <ul> 8 {% for item in blog_posts %} 9 <li> 10 <a href="{{ path('blog_show', {'id': post.id}) }}">{{ post.title }}</a> 11 </li> 12 {% endfor %} 13 </ul> 14 15 {% endblock %} 1 @model IEnumerable<HelloMVC.Models.BlogPost> 2 3 @{ 4 ViewBag.Title = "Blog Posts"; 5 } 6 7 <h2>List of Posts</h2> 8 9 <ul> 10 @foreach (var item in Model) { 11 12 13 <li> 14 <a href="@Html.ActionLink("Details", "Details", new { id=item.id })"> 15 @Html.DisplayFor(modelItem => item.Title) 16 </a> 17 </li> 18 } 19 20 </ul> ASP.NET (Razor) PHP
  29. 29. APPLICATION SERVERS Of course, once we have developed our web application, we need to be able to host and run it. Application Server: Software designed to handle communication between a front-end website, and a business back-end system. Features include: • Performance optimisation (caching, profiling etc.) • Database management (population, transactions etc.) • Load Balancing • Logging/Debugging • Security • Data integrity support • Deployment • Recovery management (application isolation) 29
  30. 30. APPLICATION SERVERS Application servers provide services and features appealing for enterprise systems. Remember: Enterprise systems imply large volumes of data, high potential for scalability and co-ordination of business processes across multi-tier architecture. 30[1] http://maaw.info/ArticleSummaries/ArtSumDavenport98.htm [1]
  31. 31. APPLICATION SERVERS 31 Glassfish (Oracle) JavaEE IIS (Microsoft) ASP.NET Wildfly (Red Hat) Java Zend Server PHP Tomcat (Apache) Java Servlets & JSP
  32. 32. IDEAS FOR ASSIGNMENT 32 While use of frameworks and multi-tier architectures is not an explicit requirement for the assignment, you could always investigate their use for your own learning… … plus perhaps for some extra marks (cough cough) Ideas to consider include: • Database management functions • Templates/server-side includes • ORM
  33. 33. 33 Many thanks for your time. Questions? @cgddrd clg11@aber.ac.uk http://cgddrd.me

×