Introduction to Component-Based Engineering Howard Abrams

Slides:



Advertisements
Similar presentations
JSP and Servelets.
Advertisements

JSP and web applications
Bringing Procedural Knowledge to XLIFF Prof. Dr. Klemens Waldhör TAUS Labs & FOM University of Applied Science FEISGILTT 16 October 2012 Seattle, USA.
Building Bug-Free O-O Software: An Introduction to Design By Contract A presentation about Design By Contract and the Eiffel software development tool.
Apache Struts Technology
Snejina Lazarova Senior QA Engineer, Team Lead CRMTeam Dimo Mitev Senior QA Engineer, Team Lead SystemIntegrationTeam Telerik QA Academy SOAP-based Web.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
Java Beans & Serialization CS-328 Dick Steflik. Java Beans Java based component technology –originally developed to provide java with a component technology.
JavaBeans introduction Klaus-Peter Heidrich for the University of Karlstad Inst. for Information Technology Dept. of Computer Science.
Object-Oriented Analysis and Design
ASP.NET Programming with C# and SQL Server First Edition
Apache Struts Technology A MVC Framework for Java Web Applications.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Introducing JavaBeans Lesson 2A / Slide 1 of 30 JDBC and JavaBeans Pre-assessment Questions 1.Which of the given symbols is used as a placeholder for PreparedStatement.
TIBCO Designer TIBCO BusinessWorks is a scalable, extensible, and easy to use integration platform that allows you to develop, deploy, and run integration.
UNIT-V The MVC architecture and Struts Framework.
Component-Based Software Engineering Introduction to Java Beans Paul Krause and Sotiris Moschoyiannis.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
11. Java-Based Web: JSP, JSF. 2 Motto: Rule 1: Our client is always right Rule 2: If you think our client is wrong, see Rule 1. - Anonymous.
Java Beans.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
ITCS 6010 SALT. Speech Application Language Tags (SALT) Speech interface markup language Extension of HTML and other markup languages Adds speech and.
Software Component Technology and Component Tracing CSC532 Presentation Developed & Presented by Feifei Xu.
Agoracast: Design and Tools Review David Wallace Croft Senior Java Architect CroftSoft Inc Talk-Java/Drink-Java Las Colinas, Texas.
© 2006 IBM Corporation IBM WebSphere Portlet Factory Architecture.
Chapter 8 Script-free pages. Problem with scripting in JSP When you use scripting (declaration, scriplet, expressions) in your JSP, you actually put Java.
JavaBeans Components. To understand JavaBeans…  Proficient experience with the Java language required  Knowledge of classes and interfaces  Object-Oriented.
TM Introduction to JavaBeans™ Dimitrios Psarros Questra Consulting (716) x225.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
JSTL Lec Umair©2006, All rights reserved JSTL (ni) Acronym of  JavaServer Pages Standard Tag Library JSTL (like JSP) is a specification, not an.
Cohesion and Coupling CS 4311
Java Programming: Advanced Topics 1 JavaBeans Chapter 8.
SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits.
JSP Tag Libraries Lec Last Lecture Example We incorporated JavaBeans in “Course Outline” Example But still have to write java code inside java.jsp.
Java Bean Definition “A Java Bean is a reusable software component that can be manipulated visually in a builder tool.”
WEP Presentation for non-IT Steps and roles in software development 2. Skills developed in 1 st year 3. What can do a student in 1 st internship.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
Grid Services I - Concepts
Introduction to Java Beans CIS 421 Web-based Java Programming.
First Bean Compose SimpleBean Demo Simple Bean Discuss Manifest and Jar Add Properties to SimpleBean.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 27 JavaBeans and.
Java Beans. Definitions A reusable software component that can be manipulated visually in a ‘builder tool’. (from JavaBean Specification) The JavaBeans.
Advanced Java Session 4 New York University School of Continuing and Professional Studies.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 11 Object-Oriented.
MVC WITH CODEIGNITER Presented By Bhanu Priya.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Object-Oriented Design.
Software Reuse Course: # The Johns-Hopkins University Montgomery County Campus Fall 2000 Session 4 Lecture # 3 - September 28, 2004.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 32 JavaBeans and Bean.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
.NET Mobile Application Development XML Web Services.
Java Beans THETOPPERSWAY.COM. Contents What is a Java Bean? Advantages Properties Bean Developers Kit (BDK) What makes Bean possible? Support for Java.
Chapter 6 Chapter 6 Server Side Programming (JSP) Part 1 1 (IS 203) WebProgramming (IS 203) Web Programming.
Java Beans - Basics CIS 421 Web-based Java Programming.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Bayu Priyambadha, S.Kom. Static content  Web Server delivers contents of a file (html) 1. Browser sends request to Web Server 3. Web Server sends HTML.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
Java Beans Sagun Dhakhwa.
Stack ADT & Modularity 2 implementations of the Stack abstract data type: Array Linked List Program design: modularity, abstraction and information hiding.
JavaServer Faces: The Fundamentals
Tuesday Brown Bag Inversion of Control with Howard Abrams
Pre-assessment Questions
Knowledge Byte In this section, you will learn about:
Java Programming: Advanced Topics
Presentation transcript:

Introduction to Component-Based Engineering Howard Abrams

Introduction to CBE2 Object-Oriented Design  Goals: Ease of Maintenance Robustness Code Reuse  Primary sources of reuse: Libraries and web services  Marketplace of “object stores” not realized Go Beyond Objects!

Introduction to CBE3 Nature of Software Components  Unification of Data and Function  Data Hiding  Unique Identity } OOP  Independent  Interactive  Replaceable  Reusable } Use existing OOP techniques, but architect your apps as components.

Introduction to CBE4 Component Independence  Objects are extremely sticky. Objects as small as possible (object normalization) More efficient, but have unnecessary dependencies  CBD Solution: Self contained and independent Pass only “simple” (widely accepted) variables Don’t make them too general Components are slightly larger / Built using OOP

Introduction to CBE5 Component Interaction  Components are not plugins: Reusable in multiple applications Components can be connected to each other  Components built for an architecture: Java Beans Enterprise Java Beans JSP Tag Libraries Web Services

Introduction to CBE6 Component Replacement  Objects are only mildly replaceable.  Components must implement interfaces. Contracts or agreements Like a component’s Java Bean specification  Interfaces “out” are events (callbacks).  Think carefully about altering contract You can upgrade (add features) but don’t change Use versioning system or support old interfaces  When components only talk via interfaces, you can upgrade/enhance with lower risk.

Introduction to CBE7 Object Replacement?  Replacing objects means editing all references  System Testing Critical Forgotten references

Introduction to CBE8 Component Replacement  Each “unit” only talks to another unit via an interface.  Goal: Components can be safely replaced by unit testing the component’s interface  System testing is now less critical

Introduction to CBE9 Components Replacement Customer Name First Name Last Name  Component-to-component communication not always possible… Do you convert the data prior to calling? Do you modify the component to accept different data?

Introduction to CBE10 Components and Glue Code  Identify/isolate “glue code” put in controller  Components more independent/reusable  Easier to replace components Control (App Rules and Glue Code) Model (Components) View (User Interface)

Introduction to CBE11 Component Advantages  Can be upgraded Unit testing concentrates on testing interface Lower emphasis on system testing You can add, but you can’t take away  Can be reused Components can be made useful Less coding as your “Bag o’ Components” grows

Introduction to CBE12 Component Tips  Don’t pass around objects. Keep it simple.  Concentrate more on independence and reuse than on “object normalization.”  Create components based on “services” Function instead of form or features.  Unit testing is critical and essential.  Avoid the temptation to put in everything

Introduction to CBE13 Component Tips (con’t)  Live your component interface: Java Bean JSP Tag Library  Create a level of trust in your components  Pretend others will use your components Clean and simple interface Liberal documentation Include your JUnit test suite Include examples of using the component

Introduction to CBE14 JSP Tags  Add more interfaces to increase reuse  JSP TagLib interface Properties == Parameters JavaBean BeanInfo Property Editors Component Tips (con’t)  Code to the lowest deployment requirements  Non-GUI JavaBean is most versatile Need multiple methods? Create “tag wrappers” Tag 1Tag 2Tag 3 Component Functionality

Introduction to CBE15 XmlQuery JavaBean Example  Need to retrieve data from XML file  XML libraries quite complex … Writing the same marshalling code over and over  Wrapper around XPath and DOM libraries  Properties: File - XML File Query - XPath Expression TrimWhiteSpace - boolean  Method: getValue() returns a String

Introduction to CBE16 XmlQuery is Serializable public class XmlQuery implements Serializable { // Property to hold the XPath query expression… protected String query = null; // Property when set will trim all returned values. protected boolean trimWhitespace = false; // Property to hold the XML file to parse protected File file = null; // Transient factory classes re-established as needed. transient DocumentBuilder docbuilder = null; transient DocumentBuilderFactory docfactory = null; // Support object to generate PropertyChange events. PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);

Introduction to CBE17 Serialization Issues  Transient variables Stateless variables Those that loose meaning on another system Factory methods  Don’t initialize transients in constructor Initialize them as you need them

Introduction to CBE18 XmlQuery Setters/Getters public String getQuery() { if (query == null) return ""; else return query; } public void setQuery (String newQuery) { String oldQuery = query; query = newQuery; changeSupport.firePropertyChange("query", oldQuery, query); }

Introduction to CBE19 Change Support Methods public synchronized void addPropertyChangeListener (PropertyChangeListener listener) { if (changeSupport == null) changeSupport = new PropertyChangeSupport(this); changeSupport.addPropertyChangeListener(listener); } public synchronized void removePropertyChangeListener (PropertyChangeListener listener) { if (changeSupport == null) changeSupport = new PropertyChangeSupport(this); changeSupport.removePropertyChangeListener(listener); }

Introduction to CBE20 Working with Bean Editors  Need to override the BeanInfo? Specify an icon representation Give a nicer interface to properties/methods  Manifest File By hand: Via Ant: Name: org/howardism/xml/XmlQuery.class Java-Bean: true

Introduction to CBE21 Property Editors  If a property accepts any but basic types, you’ll want to create an external editor.  You can create elaborate GUI editors…  A simple “text bridge” is usually better:

Introduction to CBE22 Property Editors: Example public class ExceptionEditor extends PropertyEditorSupport { public String getAsText() { if (getValue() == null) return ""; else return ((Throwable) getValue()).getClass().getName(); } public void setAsText(String value) throws IllegalArgumentException { if (value != null && ! value.trim().equals("")) setValue( Class.forName(value).newInstance()); }

Introduction to CBE23 Property Editors: Example AppComposerSun’s BeanBox Sun’s BeanBuilder

Introduction to CBE24 Alarm JavaBean Example  Generates an “event” at a particular time  Properties: Time- Particular date or time in the future Identity- To label each event  Methods: startAlarm- Must be called stopAlarm- To stop event prematurely  Generates a “AlarmEvent” to listeners

Introduction to CBE25 Alarm Listener Methods public synchronized void addAlarmListener (AlarmListener listener) { if (alarmListeners == null) alarmListeners = new java.util.Vector(); alarmListeners.addElement(listener); } public synchronized void removeAlarmListener (AlarmListener listener) { if (alarmListeners == null) return; alarmListeners.removeElement(listener); }

Introduction to CBE26 Alarm’s fireAlarm Method protected void fireAlarm (String identity) { java.util.Vector targets = null; synchronized (this) { if (alarmListeners != null) targets = (java.util.Vector) alarmListeners.clone(); } if (targets != null) { AlarmEvent evt = new AlarmEvent(identity); for (int i = 0; i < targets.size(); i++) { AlarmListener target = targets.elementAt(i); target.alarmGenerated(evt);

Introduction to CBE27 AlarmListener / AlarmEvent public interface AlarmListener extends EventListener { public void alarmGenerated (AlarmEvent event); } public class AlarmEvent extends EventObject { public AlarmEvent (String label) { super(label == null ? "" : label); }

Introduction to CBE28 Thoughts on Events  Event generation is the “output interface” Equivalent to a “Callback” Boils down to a simple function call  Java’s event mechanism not that nice Events in scripting languages generally nicer The “clean” event interface is a good thing  Tools like AppComposer compensate Helps client handle event-based communication

Thanks