Software Engineering Design Patterns. Singleton Single instance of class Constructor is private static final Class instance constructed when application.

Slides:



Advertisements
Similar presentations
Systems Architecture Use Case Diagram, System Overview, Class Diagram Design Patterns (weve used) Refactorings (weve used) Table of Contents.
Advertisements

AspectWerkz 2 - and the road to AspectJ 5 Jonas Bonér Senior Software Engineer BEA Systems.
Practical Session 6 Multitasking vs. multithreading Threads Concurrency vs. Parallelism Java Threads Thread confinement Object/Class Immutability.
Design Validation CSCI 5801: Software Engineering.
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
Software Engineering Implementation Lecture 3 ASPI8-4 Anders P. Ravn, Feb 2004.
CSCI 6962: Server-side Design and Programming Input Validation and Error Handling.
Multiplexing/Demux. CPSC Transport Layer 3-2 Multiplexing/demultiplexing application transport network link physical P1 application transport network.
Exception Handling – illustrated by Java mMIC-SFT November 2003 Anders P. Ravn Aalborg University.
Written by: Dr. JJ Shepherd
Computer Monitoring System for EE Faculty By Yaroslav Ross And Denis Zakrevsky Supervisor: Viktor Kulikov.
1 Object-Oriented Software Development Project Aaron Christopher.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
INTERNET DATABASE. Internet and E-commerce Internet – a worldwide collection of interconnected computer network Internet – a worldwide collection of interconnected.
Fall 2009ACS-3913 R McFadyen1 Singleton Problem: Exactly one instance of a certain object is required (this object is called a singleton). We must ensure.
Chapter 10 Classes Continued
Java Review 3 Rem Collier. Java Wrapper Classes In Java, the term wrapper class commonly refers to a set of Java classes that “objectify” the primitive.
Proxy Design Pattern Source: Design Patterns – Elements of Reusable Object- Oriented Software; Gamma, et. al.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 4 Slide 1 Slide 1 Message Analysis Table.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
Chapter 26 GoF Design Patterns. The Adapter Design Pattern.
DaveAndAl.net Do Application Design Patterns Make Sense in ASP.NET? Alex Homer You may like to write these down now...
Patterns in programming 1. What are patterns? “A design pattern is a general, reusable solution to a commonly occurring problem in software. A design.
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
(c) University of Washington01-1 CSC 143 Java Programming as Modeling Reading: Ch. 1-6.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
Singleton and Basic UML CS340100, NTHU Yoshi. What is UML Unified Modeling Language A standardized general-purpose modeling language in the field of software.
Domain Driven Web Development With WebJinn Sergei Kojarski College of Computer & Information Science Northeastern University joint work with David H. Lorenz.
Patterns in programming1. 2 What are patterns? Answers to common design problems. A language used by developers –To discuss answers to design problems.
Proxy.
CS 4244: Internet Programming Network Programming in Java 1.0.
The Singleton Pattern SE-2811 Dr. Mark L. Hornick 1.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Developing Applications with the CSI Framework A General Guide.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
Design Patterns Introduction
Design Patterns SE464 Derek Rayside images from NetObjectives.com & Wikipedia.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
The OWASP Foundation OWASP Education Computer based training CERT Secure Coding Nishi Kumar IT Architect Specialist, FIS Chair, Software.
Project Scenario for OpX. High-level Overview In the Test GUI Controller, opXController, for the opX command there is conceptually a call to an appropriate.
WEB SERVER SOFTWARE FEATURE SETS
The Factory Method Pattern (Creational) ©SoftMoore ConsultingSlide 1.
The Singleton Pattern (Creational)
Written by: Dr. JJ Shepherd
INFSO-RI Enabling Grids for E-sciencE gLite C++ Configurator Practical experience gLite Configuration Meeting, March 1, 2005 Peter.
Reference Types CSE301 University of Sunderland Harry R Erwin, PhD.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 9: Arrays; Revision Session.
C++ General Characteristics: - Mixed typing system - Constructors and destructors - Elaborate access controls to class entities.
CSC 243 – Java Programming, Spring, 2014 Week 4, Interfaces, Derived Classes, and Abstract Classes.
Written by: Dr. JJ Shepherd
Chapter 5: Enhancing Classes
ODBC, OCCI and JDBC overview
EE2E1. JAVA Programming Revision Lecture.
The Singleton Pattern SE-2811 Dr. Mark L. Hornick.
Introduction To Design Patterns
Design Patterns in Operating Systems
Programming Design Patterns
CNT 4007C Project 2 Good morning, everyone. In this class, we will have a brief look at the project 2. Project 2 is basically the same with project 1.
What is Singleton Category: Creational pattern
Singleton Pattern Pattern Name: Singleton Pattern Context
Singleton design pattern
Singleton …there can be only one….
Overview of C++ Polymorphism
Design pattern Lecture 6.
Introduction To Design Patterns
Introduction To Design Patterns
06 | SQL Server and the Cloud
Presentation transcript:

Software Engineering Design Patterns

Singleton Single instance of class Constructor is private static final Class instance constructed when application loads or loaded only when need (lazy initialization) Examples of usage –to access database so that all threads go through one control point –Font class keeps memory load low

Singleton Example in Java public class DbaseConnector { private static final DbaseConnector instance=new DbaseConnector(); private DbaseConnector() { // database construction code….. } public static DbaseConnector getInstance() { return(instance); }

Singleton Example (lazy initialization) public class DbaseConnector { private static DbaseConnector instance; private DbaseConnector() { // database construction code….. } public static DbaseConnector synchronized getInstance() { if (instance==null) { instance=new DbaseConnector(); } return(instance); }

Wrapper/Adapter classes Problem –Different external technologies to connect to –Example for database connection ODBC(Microsoft) JDBC(Java standard) –Other examples External Credit card payment Network connection (Java and Microsoft) Data structure libraries

Wrapper classes Problem with coding directly –Code will end up messy –Hard to port –Hard to understand Benefits of wrapping code –easier to swap modules (e.g. CC function) –easier to implement standard functions (e.g. accountancy, error logs)

Wrapper example (unwrapped code) String sql="select * from customers"; try { java.sql.Statement s=dbConnection.createStatement(); int rows=s.executeUpdate(sql); } catch (Exception e) { status=sql+" "+e.toString(); };

Wrapped code public class SQLHelper { public void executeSQL(String sql) { try { java.sql.Statement s=dbConnection.createStatement(); int rows=s.executeUpdate(sql); } catch (Exception e) { status=sql+" "+e.toString(); }; }

Adapter interface (top level) Defines all common services and constants ICardProvider, I Provider All methods are virtual (no body) E.g. takeCardPayment(String cardno,

Abstract base Contains common code that will be used by all providers CardProviderBase implements ICardProvider –Details validation –HTTP request code ProviderBase implements I Provider –Code to connect to standard SMTP server –Code to handle store, addresses, contents, attachements

Common functionality on base class Name of service Priority Enabled or not Cost of service Blacklists ( or CC card) Risk management (card payment) Audit trails and logging

Implementation The actual providers need to implement the code to connect to particular service e.g. MetachargeCardProvider extends CardProviderBase Gmail Provider extends ProviderBase

Provider manager This will be a class which creates instances of providers and handles the requests Card payment –Might try more than 1 provider in turn until payment goes through –Again, tries different providers, some providers might be on or offline at any time

Summary Design patterns can help –code structure –code quality Using design patterns –look at design patterns example code –adapt design patterns for your own code –reference design pattern texts when designing your system