TOOLS FOR DESIGN AND DEVELOPMENT ENVIRONMENTS. Case study - ECLIPSE Lecture notes 7.

Slides:



Advertisements
Similar presentations
Introduction to Maven 2.0 An open source build tool for Enterprise Java projects Mahen Goonewardene.
Advertisements

Refactoring Overview  What is refactoring?  What are four good reasons to refactor?  When should you refactor?  What is a bad smell (relative to refactoring.
CS 211 Inheritance AAA.
ITEC200 – Week03 Inheritance and Class Hierarchies.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 Chapter 12 More OOP, Interfaces, and Inner Classes.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
20-Jun-15 Eclipse. Most slides from: 2 About IDEs An IDE is an Integrated Development Environment.
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of The Java Development Tools project.
Introduction to Refactoring Excerpted from ‘What is Refactoring?’ by William C. Wake and Refactoring: Improving the Design of Existing Code by Martin Fowler.
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of Creating Eclipse plug-ins.
13-Jul-15 Refactoring II. Books Design Patterns is the classic book by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides Basically a catalog.
Systems Analysis and Design in a Changing World, Fifth Edition
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Eclipse – making OOP Easy
CISC6795: Spring Object-Oriented Programming: Polymorphism.
© 2012 LogiGear Corporation. All Rights Reserved Robot framework.
1 v1.6 08/02/2006 Overview of Eclipse Lectures 1.Overview 2.Installing and Running 3.Building and Running Java Classes 4.Refactoring 5.Debugging 6.Testing.
Refactoring Cristescu Marilena. Definitions Loose Usage: Reorganize a program(or something) As a noun: a change made to the internal structure of some.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single.
Prepared by: Sanaz Helmi Hoda Akbari Zahra Ahmadi Sharif University of Tech. Summer 2006 An Introduction to.
Design and Programming Chapter 7 Applied Software Project Management, Stellman & Greene See also:
TOOLS FOR DESIGN AND DEVELOPMENT ENVIRONMENTS. Case study - ECLIPSE Lecture notes 4.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
Refactoring Improving the structure of existing code Refactoring1.
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
July 2011CMSC 341 CVS/Ant 1 CMSC 341 Java Packages Ant CVS Project Submission.
Systems Analysis and Design in a Changing World, 3rd Edition
Refactoring1 Improving the structure of existing code.
Comp 249 Programming Methodology Chapter 13 Interfaces & Inner Classes Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia.
Refactoring Deciding what to make a superclass or interface is difficult. Some of these refactorings are helpful. Some research items include Inheritance.
Ant & Jar Ant – Java-based build tool Jar – pkzip archive, that contains metadata (a manifest file) that the JRE understands.
Eclipse 24-Apr-17.
1 CSC/ECE 517 Fall 2010 Lec. 3 Overview of Eclipse Lectures Lecture 2 “Lecture 0” Lecture 3 1.Overview 2.Installing and Running 3.Building and Running.
Refactoring. Refactoring Overview  What is refactoring?  What are four good reasons to refactor?  When should you refactor?  What is a bad smell (relative.
Refactoring 2. Admin Blackboard Quiz Acknowledgements Material in this presentation was drawn from Martin Fowler, Refactoring: Improving the Design of.
REFACTORINGREFACTORING. Realities Code evolves substantially during development Requirements changes 1%-4% per month on a project Current methodologies.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
Overview of the Automated Build & Deployment Process Johnita Beasley Tuesday, April 29, 2008.
Software Development COMP220/COMP285 Seb Coope Introducing Ant These slides are mainly based on “Java Development with Ant” - E. Hatcher & S.Loughran.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
1 Software Maintenance and Evolution CSSE 575: Session 3, Part 3 Dealing with Generalization Steve Chenoweth Office Phone: (812) Cell: (937)
Chapter 1 Introducing Ant. What is ant? Ant is a build tool  Automate the tasks of compiling code, running test, and packaging the results for redistribution.
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
Refactoring1 Improving the structure of existing code.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Classes, Interfaces and Packages
TOOLS FOR DESIGN AND DEVELOPMENT ENVIRONMENTS. Case study - ECLIPSE Lecture notes 5.
Refactoring. DCS – SWC 2 Refactoring ”A change made to the internal structure of software to make it easier to understand and cheaper to modify without.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
Module 9. Dealing with Generalization Course: Refactoring.
Eclipse 27-Apr-17.
Using Ant in Eclipse Dwight Deugo Nesa Matic
Lecture Transforming Data: Using Apache Xalan to apply XSLT transformations Marc Dumontier Blueprint Initiative Samuel Lunenfeld Research Institute.
Java IDE Dwight Deugo Nesa Matic
Principles and examples
Module Road Map Refactoring Why Refactoring? Examples
Introduction to Triggers
Object-Oriented Programming & Design Lecture 14 Martin van Bommel
Eclipse 20-Sep-18.
Overview of Eclipse Lectures
Improving the structure of existing code
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
Refactoring.
MS Confidential : SharePoint 2010 Developer Workshop (Beta1)
Presentation transcript:

TOOLS FOR DESIGN AND DEVELOPMENT ENVIRONMENTS. Case study - ECLIPSE Lecture notes 7

Refactoring the code Refactoring = making system-wide code changes without affecting the behavior of a program. Eclipse provides an extensive list of commands that automate Java code refactoring. Ex. of refactoring operations: Moving and renaming Java elements requires changes in dependent files. Extract Interface help generalize a design in preparation for the next iteration of development.

Refactoring the code Is done in small bursts (not scheduled) when changes are needed: to make the software easier to understand and cheaper to modify; Ex. When encountered: duplicated code / large classes / long methods / tightly coupled components, etc. to add a new feature to a software; Ex. As the code grows, it may be easier to understand and extend if a package is divided into two logical units. to expose previously defined methods as part of the public API. It may be necessary to extract new interfaces from concrete class implementations. Martin Fowler describes a Rule of Three for deciding when to refactor: "The first time you do something, you just do it. The second time you do something similar, you wince at the duplication, but you do the duplicate thing anyway. The third time you do something similar, you refactor.“

Refactoring the code Refactoring -makes software easier to understand and cheaper to modify -prepares a design for the next development iteration -does not change the current behavior. Several different refactoring operations are often applied in a sequence to accomplish a complex task. For example, extracting a group of interfaces is accompanied by renaming a package, moving types, and introducing factory methods. Refactoring operations can update references to changed elements and save a large amount of time compared to performing the same changes manually. Recommendations: Run a complete JUnit test suite both before and after refactoring to determine if program's behavior is unchanged by refactoring. Commit all code to a repository before and after refactoring to establish known states for rolling back changes. Preview the results of refactoring operations to omit individual changes or cancel an entire operation that does not accomplish what you expected.

Refactoring the code Catalog of all refactoring operations available in Eclipse - categorized by common tasks during refactoring activities. Common refactoring tasks: –Composing Methods –Moving Features Between Objects –Organizing Data –Making Method Calls Simpler –Dealing with Generalization –Organizing Classes and Packages

Refactoring the code Catalog (continued) Composing Methods Aim: Composing methods to package code properly. Sugestive names to describe their separate purposes. Eclipse operations: Extract Method. 1.Turn a code selection into a new method whose name explains the purpose of the method. 2.Replace the selection with a reference to the new method. Is useful for cleaning up lengthy, cluttered, or overly complicated methods. Get a valid selection range by using the menu command Edit > Expand Selection To > Enclosing Method (or shortcut keys: Alt+Shift+Up-Arrow ). Inline Method. 1.Put the method's body into the body of its callers 2.Remove the method. When method's body is as clear as its name, or it may perform unnecessary simple delegation.

Refactoring the code Catalog (continued) Moving Features Between Objects Aim: To correct design mistakes or to reassign responsibilities when an evolving code base would be simpler with different class responsibilities. Move methods when: -classes have too much behavior, -classes are collaborating too much and are too tightly coupled, -after moving a field, if needed. Eclipse operations: Move Field. Move a field declaration from one type to another. Additional refactoring is usually required to resolve broken references to a private field. Move Method. 1.Create a new method with a similar body in the class it uses most. 2.Either turn the old method into a simple delegation or remove it altogether. Extract Class. 1.Create a new class 2.Move the relevant fields and methods from the old class into the new class. This refactoring is not included in any Eclipse menus, but it can be accomplished via a series of Move Field and Move Method refactorings.

Refactoring the code Catalog (continued) Organizing Data Aim: Organize fields, local variables, and constants in a class to make working with its data easier. Eclipse operations: Encapsulate Field. Make a field private and provide getter and setter methods. This operation includes an option that changes current field access to use the getter and setter methods. Extract Local Variable. 1.Create a new variable assigned to the selected expression 2.Replace it with a reference to the new variable. Valid selection range by using the menu command Edit > Expand Selection To > Enclosing Method. Extract Constant. 1.Create a static final field from the selected expression 2.Substitute a field reference; optionally rewrite other places where the same expression occurs. Convert Local Variable to Field. 1.Turn a local variable into a field. 2.If the variable is initialized on creation, then the operation moves the initialization to the new field's declaration or to the class's constructors. Inline Local Variable or Constant. Replace references to a local variable or static constant with the expression that is assigned to that variable or constant. Optionally remove the variable or constant declaration.

Refactoring the code Catalog (continued) Making Method Calls Simpler Aim: Help make object interfaces easier to understand and use. Rename methods with more descriptive names. Keep method's signature (name, parameters, return type, and visibility) as simple as possible without sacrificing relevant information. Eclipse operations: Rename Method. Change the name of a method. Optionally update all references to this method. Change Method Signature. 1.Change parameter names, parameter types, parameter order, or thrown exceptions 2.Update all references to the corresponding method. Parameters also can be removed or added, and the method return type or visibility can be changed. Introduce Parameter. Add a new parameter to a method signature. 1.Select an expression in the method body before starting this refactoring. 2.The containing method is given a new parameter 3.The selected expression is copied into the argument list of all the callers. Introduce Factory. 1.Replace the selected constructor with a factory method. 2.Create a new static factory method in the specified class 3. Replace all uses of the constructor with the new method.

Refactoring the code Catalog (continued) Dealing with Generalization Aim: Help to manage the inheritance hierarchy of classes and interfaces. Move methods and fields up or down the hierarchy. Create new interfaces to represent relevant subsets of behavior. Generalize type references to more abstract types. Eclipse operations: Push Down. When behavior on a superclass is relevant only for some of its subclasses. Move a set of methods and fields from a class to its subclasses. This refactoring can be applied to one or more methods and fields declared in the same type. Often used when you are extracting a new subclass. Pull Up. Eliminate duplicate behavior in two or more subclasses. -Move a field or method to a superclass of its declaring class. -Declare the method as abstract in the superclass. ( in the case of methods ) This refactoring can be applied to one or more methods, fields, and member types declared in the same type.

Refactoring the code Catalog (continued) Dealing with Generalization (continued) Eclipse operations:(continued) Extract Interface. 1.Create a new interface with a set of methods selected from a class 2.Make the selected class implement the new interface. 3.Optionally change references to the class to use the new interface wherever possible. Generalize Type. Replace a type with one of its supertypes. 1.Select a declaration of a variable, parameter, field, or method return type in the Java editor 2.The refactoring wizard shows the supertype hierarchy for the original type and updates the declaration with the selected supertype. Use Supertype Where Possible. Replace occurrences of a type with one of its supertypes after identifying all places where this replacement is possible.

Refactoring the code Catalog (continued) Organizing Classes and Packages Aim: Design for reuse and extensibility of Java libraries. Help reorganize Java packages and types and update their references. Eclipse operations: Rename Type or Package. 1.Rename a type or package. 2.Optionally modify all references to the changed element. Move Package. 1.Move one or more packages (and all of the types they contain) to a new source folder. 2.Move the underlying operating system folders and files to the new location. Move Type. -Move one or more types to a new destination package. -Move inner classes into a different class.

Refactoring the code Catalog (continued) Organizing Classes and Packages (continued) Eclipse operations: (continued) Rename Source Folder or Project. 1.Rename a source folder or project. (Does not affect Java elements directly) 2.Update project configuration properties with the new name. Move Member Type to New File. 1.Create a new Java compilation unit (file with.java extension) for the selected member type; 2.Update all references as needed. For non-static member types, a field is added to allow access to the former enclosing instance. Convert Anonymous Class to Nested. Convert an anonymous inner class to a named member class.

Continous integration Successful agile development requires that you deliver complete, tested applications at the end of an iteration. An iteration is completed in a specific time interval and often integrates the results of several small teams. Integrating one set of changes at a time makes it easy to identify problems and prevents a surprise at the end. The developers and customers working on a team keep a view of the iteration's progress. It is important to have tools that support a fast, automated build and test cycle. It is also needed a reasonably complete test suite that verifies successful integration of each new or modified component.

Continous integration Continuous integration occurs at two points in the development cycle. 1.Each developer uses Eclipse to keep his or her view of the project's code synchronized with a team repository. The automated project builders within Eclipse assist developers in performing continuous compilation and unit testing of their component. 2. A build machine is used to compile and test the application in a clean environment. Eclipse includes support for writing and running Ant build files that automate the build process. Continuous integration with a team repository

Continous integration Automatic incremental build Workspace and projects configured correctly  continuous integration is automatic and nearly instantaneous. Automatic build includes project dependencies that integrate modules from other teams. The default Java project builder compiles all code from the source folders into the output folders. The builder runs automatically whenever any source file is updated. Automatic build can be disabled  Rebuild manually one or all projects. It is also possible to clean all output from one or all projects and rebuild them from scratch.

Continous integration Automatic incremental build (continued) Supplementary steps in a project's build process: Are performed by Java applications or by running non-Java tools that are executed from the command line. Relevant examples: -generate code from database or XML Schemas; -generate code from models (see the Eclipse EMF and UML2 technology projects); -package JAR archives; -generate Javadoc files; -use FTP to deploy an application to a test server. External Tools menu: -Any external tool can be configured and run from within Eclipse. -It's more common to use Ant build files to run other Java or non-Java tools.

Continous integration Introduction to Ant Ant – used to implement customized build process.  Part of the Apache open source project.  Java-based build tool designed to be cross-platform, easy to use, extensible, and scalable.  Works equally well in small personal projects or in large, multi-team, distributed development efforts. Ant's benefits – enabled by three core concepts: Ant build files use a declarative syntax to represent build targets, tasks, and dependencies. New tasks may be added that support additional tools or operations; The build files are written with an XML format that helps to provide a flexible and extensible structure. This also allows use of standard XML tools for editing and parsing the build files.

Continous integration Introduction to Ant (continued) The primary elements in an Ant build file : Project. Each build file contains one project. It's not necessary for an Ant project to be equivalent to an Eclipse project; an Ant project represents a logical group of related targets. Target. An Ant project contains one or more targets that produce the build output, such as a library archive, or that perform interim steps, such as compiling source code or running tests. Dependencies between targets assure that prerequisites are completed before a target is run. Task. Each target contains tasks that represent its individual operations. Ant includes a long list of built-in tasks for performing operations such as copying files, running the Java compiler, or setting property values. Other tools can contribute new tasks that extend Ant's capabilities. For a more detailed explanation of writing Ant build files for large projects and continuous integration, see the Ant Web site,

Continous integration Introduction to Ant (continued) Build Properties Set of properties used to parameterize aspects of the build file for an Ant project. Build Tasks –Built into the standard Ant library –Added by third-party extensions. Examples: ant— Run Ant on the supplied build file. copy— Copy a file or fileset to a new file or directory jar— Create a JAR file containing the specified set of files. javac— Compile the specified source file(s). junit— Run the JUnit testing framework. junitreport— Merge the individual XML files generated by the junit task and apply a stylesheet to produce an HTML report of the JUnit results. taskdef— Add a task definition to the enclosing project, such that the new task can be used in this project's targets. (see the Ant documentation for a complete list).

Continous integration Introduction to Ant (continued) Building a Project Steps, in project build file, required to prepare a complete build: 1.Generate Java code from XML Schemas that define data types and enumerated code lists. 2.Run all JUnit tests and generate an HTML report of the test results. 3.Generate Javadoc HTML files from the source code. 4.Automate the entire project build and test process so that it can be run either inside or outside of Eclipse.

Eclipse and Ant Ant is a declarative and extensible build tool, and its capabilities are seamlessly integrated with the Eclipse workbench; supplementing the default Java builder with Ant build files allows fulfill non-routine build requirements. Ant build file editor features: -coordinated Outline view -hover text tips -Content Assist -templates -automatic formatting. Workbench preferences for Ant include runtime configuration where additional JAR files may be added to the classpath used to run build files. Individual build files have their own runtime settings that can override or extend the defaults. Ant build files may be configured to run automatically whenever project resources are modified. The build file may be run either within Eclipse or independently on a separate build machine as part of an automated continuous build process.