Reusability 11/29/2018© 2006 ITT Educational Services Inc.

Slides:



Advertisements
Similar presentations
Using.NET Platform Note: Most of the material of these slides have been taken & extended from Nakov’s excellent overview for.NET framework, MSDN and wikipedia.
Advertisements

©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Refactoring: Improving the Design of Existing Code © Martin Fowler, Martin Fowler.
Component-based Software Engineering Marcello Bonsangue LIACS – Leiden University Fall 2005 Component Model Comparison.
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
JAVA BEANS By Madhuri Kakumanu. What is a Java Bean? “ A Java Bean is a reusable software component that can be visually manipulated in builder tools.”
Software Engineering Module 1 -Components Teaching unit 3 – Advanced development Ernesto Damiani Free University of Bozen - Bolzano Lesson 2 – Components.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
ACM/JETT Workshop - August 4-5, 2005 UML Modeling using MagicDraw UML for Java Programmers.
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.
Introducing JavaBeans Identify the features of a JavaBean Create and add a bean to an application Manipulate bean properties using accessor and mutator.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
Java Beans.
.NET Framework Introduction: Metadata
Design Patterns.
VS.NET Syllabus By Peter Huang.
MVC and MVP. References enter.html enter.html
CIT241 Prerequisite Knowledge ◦ Variables ◦ Operators ◦ C++ Syntax ◦ Program Structure ◦ Classes  Basic Structure of a class  Concept of Data Hiding.
Refactoring: Improving the Design of Existing Code © Martin Fowler, Martin Fowler.
® How to Build IBM Lotus Notes Components for Composite Applications 정유신 과장 2007 하반기 로터스 알토란.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
JavaBeans Components. To understand JavaBeans…  Proficient experience with the Java language required  Knowledge of classes and interfaces  Object-Oriented.
CIS 644 Aug. 25, 1999 tour of Java. First … about the media lectures… we are experimenting with the media format please give feedback.
Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02.
1/26 On-demand Learning Series Software Engineering of Web Application - Object-Oriented Development & UML Hunan University, Software School.
Refactoring: Improving the Design of Existing Code © Martin Fowler, Martin Fowler.
Introduction to Java Beans CIS 421 Web-based Java Programming.
05/26/2004www.indyjug.net1 Indy Java User’s Group May Knowledge Services, Inc.
Java Beans. Definitions A reusable software component that can be manipulated visually in a ‘builder tool’. (from JavaBean Specification) The JavaBeans.
Obsydian Component Model Ranjit Sahota Chief Architect Obsydian Development Ranjit Sahota Chief Architect Obsydian Development.
Refactoring II Dealing with Polymorphism. Switch in Rental Switches on Movie! class Rental … public double getCharge() { double result = 0; switch (getMovie().getPriceCode()){
CSE 332: Design Patterns Review: Design Pattern Structure A design pattern has a name –So when someone says “Adapter” you know what they mean –So you can.
Design Patterns.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
ANDROID AND MODEL / VIEW / CONTROLLER. Slide 2 Design Patters Common solutions to programming problems are called design patterns Design patterns are.
Refactoring. Announcements HW7 due today, HW8 coming up tomorrow (I’m taking a late day on posting HW8) Grades and feedback for HW0-5 in Homework Server.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Introduction to Software Components: the JavaBeans specs Babak Esfandiari.
Java Programming: Advanced Topics1 Introduction to Advanced Java Programming Chapter 1.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
Refactoring Improving code after it has been written.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
Building Custom Controls with ASP.NET and the Microsoft ®.NET Framework Rames Gantanant Microsoft Regional Director, Thailand
Refactoring (1). Software Evolution Cope with change Feature bloat Design decay Code duplications “Pattern time is refactoring time” Make future changes.
A (Very) Simple Example Consolidate duplicate conditional fragments if (isSpecialDeal()) { total = price * 0.95; send (); } else { total = price * 0.98;
Introduction to Object-oriented Programming
Design Patterns Source: “Design Patterns”, Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides And Created.
Structure of a web application
Basic 1960s It was designed to emphasize ease of use. Became widespread on microcomputers It is relatively simple. Will make it easier for people with.
Introduction to Advanced Java Programming
MPCS – Advanced java Programming
Chapter 11 Object-Oriented Design
Java Beans Sagun Dhakhwa.
Outline A. What is Refactoring? B. Why do we Refactor?
Reference: COS240 Syllabus
Microsoft .NET 3. Language Innovations Pan Wuming 2017.
Enterprise Java Bean. Overview of EJB View of EJB Conversation Roles in EJB, Types of Enterprise Beans Lifecycle of Beans Developing Applications using.
Un</br>able’s MySecretSecrets
Object Oriented Analysis and Design
CBSE 2014 Modeling Components with UML
Refactoring.
private double amountFor(Rental aRental)
IMPORTANT NOTICE TO STUDENTS:
JavaServer Faces: The Fundamentals
Software Design Lecture : 14.
An Introduction to Software Architecture
Object Oriented System Design Class Diagrams
ADVANCED OBJECT-ORIENTED PROGRAMMING
SDMX IT Tools SDMX Registry
Presentation transcript:

Reusability 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 1

Objectives Identify the benefits of building applications using frameworks. Describe how a framework differs from a design pattern. Use design patterns. Identify the four elements that define a pattern Use refactoring to improve code maintenance and reusability. List the benefits of refactoring Identify situations in which refactoring might cause problems Write a program that uses the following components: Component Object Model (COM), ActiveX control, .NET component, JavaBean, Web service Describe how you would use a COM object. Describe how you would use an ActiveX control. Describe how you would use a .NET component. Describe how you would use a JavaBean Describe how you woul use a Web service 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 2

Patterns A pattern name The problem the pattern solves Conditions that must be met for the pattern to be applicable The solution to the problem brought by the pattern Elements involved and their roles, responsibilities, relationships, and collaborations Not a concrete design or implementation The consequences of applying the pattern Time and space Language and implementation Effects on flexibility, extensibility, and portability 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 3

Observer Pattern 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 4

Frameworks Provide abstract classes and base classes Provide default implementations Apply multiple patterns Can be based on: White box (classes and inheritance) Black box (object composition) 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 5

MVC Framework 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 6

Java 2 Platform 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 7

Java, the Language 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 8

Java.awt.image Package 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 9

Interfaces versus Classes 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 10

JavaBeans Events Properties Introspection Customization Persistence 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 11

JAR Files May include: A set of class files A set of serialize objects Optional help files (HTML) Optional localization information Optional icons held in .icon files in GIF format Other resources needed by the bean 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 12

Basic Java Services Reflection Object serialization Java native interface Java AWT and JFC/Swing 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 13

COM Component with a Single Interface 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 14

COM Component with Multiple Interfaces 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 15

Depiction of a COM Object 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 16

COM Object Containment 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 17

COM Object Aggregation 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 18

ActiveX Controls COM objects, but with additional features Self-registering Handle events Expose design-time properties Support persistence 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 19

.NET Common Type Systems 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 20

Side-by-Side Interface Versioning 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 21

COM Interoperability with .NET COM Callable Wrapper COM Application .NET component Runtime Callable Wrapper .NET Application COM component 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 22

.NET Assemblies Shared assemblies Stored in the Global Assembly Cache Must be strong-named Publisher policy Application policy Assemblies can also be private to an application All assemblies require a manifest 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 23

Refactoring – Key Points Build a good set of tests before you start Make a small change, then test 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 24

Class Diagram of Starting Program 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 25

Interactions for the Statement Method 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 26

Refactoring First Example public String statement() … switch (each.getMovie().getPriceCode()){ case Movie.REGULAR: thisAmount+=2 if(each.getaysRented() > 2) thisAmount+= (each.getdaysRented -2) * 1.5; break; case Movie.NEW_RELEASE: thisAmount+= each.getDaysRented()*3 } Extract out into its own method Pass each as a variable Return thisAmount 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 27

Rename Variables private double amountFor(Rental aRental) { double result = 0; switch (aRental.getMovie().getPriceCode()){ case Movie.REGULAR: result +=2 if(aRental.getaysRented() > 2) result += (aRental.getDaysRented -2) * 1.5; break; case Movie.NEW_RELEASE: result += aRental.getDaysRented()*3 case Movie.CHILDRENS: result += 1.5; if (aRental.getDaysRented() > 3) result += (aRental.getDaysRented()-3) * 1.5; } return result; 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 28

Move the Method to the Rental Class double getCharge() { double result = 0; switch (aRental.getMovie().getPriceCode()){ case Movie.REGULAR: result +=2 if(aRental.getaysRented() > 2) result += (aRental.getDaysRented -2) * 1.5; break; case Movie.NEW_RELEASE: result += aRental.getDaysRented()*3 case Movie.CHILDRENS: result += 1.5; if (aRental.getDaysRented() > 3) result += (aRental.getDaysRented()-3) * 1.5; } return result; In Customer, delegate to the new method and test If it works, find calls to the old method and change them 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 29

Class Diagram After the Move 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 30

Replace the Conditional Logic with Polymorphism Move the getCharge method to Movie Pass daysRented 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 31

Using Inheritance on Movie 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 32

Using the State Pattern on Movie 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 33

Interactions with the State Pattern 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 34

Class Diagram after the State Pattern 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 35

Why Refactor Improve software design Make software easier to understand Find bugs Develop code more quickly 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 36

When to Refactor If you do the same thing over and over When you add functionality When you need to fix a bug During code review 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 37

Potential Problems Databases Changing interfaces Design changes that are hard to refactor 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 38

Summary In this unit, students learned: Using patterns Using frameworks Using Java 2 Platform Using JavaBeans Using COM Using ActiveX Using .NET components Using Web Services Refactoring 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 10 Slide 39