© Raphael Gfeller, [email protected] 1
Upgrading of component-based application
Program Analysis and TransformationMSE-Seminar
09.12.2008
© Raphael Gfeller, [email protected] 2
Agenda
• Component-based Software Engineering, CBSE– History– Benefits – Challenges
• Change management on CBSE– Approaches to reduce the effort for the consumer
• New fields of application• Questions• References09.12.2008
© Raphael Gfeller, [email protected] 3
Component-based Software Engineering, CBSE
Component-based Software Engineeringalso known as Component-Based Development (CBD) or Software Componentry
- focus that software should be developed by combining prefabricated components together
(like in the field of electronics or mechanics)
In contrast to object-oriented programming, (OOP) which
- focus on modeling real-world interactions
Component based programming(for example
JavaBeans, DCOM)Distributed object computing
(for example CORBA)Object oriented programming
(for example C++, C#, Java)
Procedural programming(for example C)
Abst
racti
on
09.12.2008
© Raphael Gfeller, [email protected] 4
Component-based Software Engineering, CBSE
History• 1968, Idea that software should be componentized from Douglas
McIlroy pipes and filters are included in UNIX
• 1986, definition of the modern concept of software component by Brad Cox Objective-C (Smalltalk-style messaging to C)
• 1990, IBM invents their System Object Model • 1990, as a reaction, Microsoft released OLE 1.0
– OLE custom controls (OCX)• 1993, Component Object Model (COM) as an interface standard
for software componentry was introduced by Microsoft
09.12.2008
© Raphael Gfeller, [email protected] 5
Component-based Software Engineering, CBSE
Benefits• Decrease of development time and total cost
because systems are not developed from scratch.• Results in standard and reusable architectures• Separation of skills
because much complexity is packaged into specific frameworks.• Fast access to new technology
because we can acquire components instead of developing them in house.• Improved reliability by shared components• …Challenges• Change management (many stakeholders involed)
focused in this presentation• Robustness (input validity, error handling)• Composable with other components• Realizing an independent component• …09.12.2008
© Raphael Gfeller, [email protected] 6
Change management on CBSE
Problem 1:A new version of a component may
• Change the behavior or• Not change the behavior
(no behavior changes are often done by refactorings)
Behavior changes Behavior does not change
09.12.2008
© Raphael Gfeller, [email protected] 7
Change management on CBSEProblem 2:• Multiple stakeholders are involved
Producer, multiple consumer, multiple competitors, state, …Problem 3:• Different interests of the stakeholders
Size of the circle: Effort for the consumer Occurs most
09.12.2008
© Raphael Gfeller, [email protected] 8
Change management on CBSE
Problem 4:There is no deterministic reaction by the consumer if a new
component is shipped.
Possible reaction:• Ignore the new version• Adapt his software for using the new component. – That is the most common approach
• Adapt the shipped component to make it compatible with the exiting application– source code has to be available
• Create a compatibility wrapper for the new component09.12.2008
© Raphael Gfeller, [email protected] 9
Change management on CBSE
Problem 5: Dilemma for
the component consumer
Using of the new version or not ?
Benefits• Less bugs• Performce
improvements• New features
Costs• New behavior?• Upgrading the
software• Retest the software
Decision drivers:• Group change steps (remove features, add features,
bug fixing, …) together better ratio between benefits and efforts for the consumer
• Reduce the effort to adapt the new version focused on the next slides
09.12.2008
© Raphael Gfeller, [email protected] 10
“Using the new version of a component in a successful way;
Implicates that the changes between the current and the new one are known!”
2008, Raphael Gfeller
09.12.2008
© Raphael Gfeller, [email protected] 11
Approaches to reduce the effort for the consumer
Detection of behavioral changes• Communicated within release notes• Detected by the consumer by doing faithful Unit Testing's.
To reduce the effort for the consumer, the producer should write release notes careful!
09.12.2008
© Raphael Gfeller, [email protected] 12
Approaches to reduce the effort for the consumer
Detection of non behavioral changes• Approach 1:
No communication• Approach 2:
Communicated within release notes• Approach 3:
Using helper keywords within the programming language
API documentation \ release notes
Example 1:
Example 2:
09.12.2008
© Raphael Gfeller, [email protected] 13
Approaches to reduce the effort for the consumer
• Approach 4:Using Naming conventions
Old clients still use the old version New clients can us the new features orcan still use the old version
Example 2:
Example 1:
09.12.2008
© Raphael Gfeller, [email protected] 14
Approaches to reduce the effort for the consumer
• Approach 5:Coexistent
Old clients still use the old version New clients use the new features
Example 1:
Two versions of the “Person” exist in coexistent within the component09.12.2008
© Raphael Gfeller, [email protected] 15
Approaches to reduce the effort for the consumer
• Approach 6: COM-Style interface query, Coexistent
Clients using their favorite versionExample 1:
Two versions of the “Person” exist in coexistent within the component09.12.2008
© Raphael Gfeller, [email protected] 16
Approaches to reduce the effort for the consumer
• Approach 7:Automatic approach based on approach 3– Find code that is marked as deprecated– Find calls to deprecated code– Calls to deprecated code are replaced by their bodiesRealized by Jeff H. Perkins
Can handle about 80% of all deprecated codeExample 1:
Body of the deprecated method09.12.2008
© Raphael Gfeller, [email protected] 17
Approaches to reduce the effort for the consumer
• Approach 8:Automatic approach, Record and replay refactoring– Producer records all applied refactorings
Extension to the refactoring engine– Recorded refactorings are shipped– Consumer replays the refactoringsDemonstrated by Johannes Henkel and Amer Diwan in CatchUp
Example 1:
Source: Henkel & Diwan: “CatchUp! Capturing and Replaying Refactorings to Support API Evolution”International Conference on Software Engineering, 2005
09.12.2008
© Raphael Gfeller, [email protected] 18
Approaches to reduce the effort for the consumer
• Approach 9: Automatic approach, detects refactorings
used by approach 8Uses – a fast syntactic analysis that finds candidates for refactoring– a precise semantic analysis step that finds the refactoring
Demonstrated by Daniel Dig in RefactoringCrawlerDetects up to 85% of applied refactorings
09.12.2008
© Raphael Gfeller, [email protected] 19
Approaches to reduce the effort for the consumer
Summary:
Best method to be used is approach 8 “Record and replay refactoring”
Less effort for the producer and consumer Information is collected on the source
Unfortunately the tool chain is not existent
Further work has to be done – Publicize this approach– Realizing a tool chain than can be used by everyone – Make these tools as a standard fitting for modern development environment – Shipping refactoring logs should be a part of new setup and deployment
assistants.09.12.2008
© Raphael Gfeller, [email protected] 20
New fields of application
Based on approach 9:
Detect an illegal usage of a componentSituation:– Company A writes a well tested component CA, test T, test results R,
– Company B writes a component CB that includes CA in a illegal way and apply refactorings to hide the origin of CA. CB =some functions + CA + refactorings
It is not obvious that CA has been integrated into CB.
Solution:– Detect refactorings between CA and CB.– Replay this refactorings on T T’– Rerun T’ on CB R’
– If R and R’ are equal the chance that CA has been integrated into CB is high.09.12.2008
© Raphael Gfeller, [email protected] 21
New fields of application
Based on approach 9:
Detect cheating of studentsSituation:– Students have to solve a given problem in Java including writing of Unit Tests
Solution 1-n– A cheating student B will use the solution from student A. Apply refactoring to hide its
cheat. SB =some edits + SA + refactorings.
It is not obvious that SB has cheated.
Solution:– Detect refactorings between SA and SB.– Replay this refactorings on T T’– Rerun T’ on SB R’– If R and R’ are equal the chance that B has cheated is high.
Remarks:– Only valid if the given problem results in given solution09.12.2008
© Raphael Gfeller, [email protected] 22
New fields of application
Based on approach 8:
Reduce the transferred data in a CVSSituation:– Textual changes are transmitted from the client to the server– Assume that the often used method doLog is renamed to doLogging.
large amount of data has to be transferred
Optimization:– Transfer refactorings instead of the textual changes, if possible
Requirements– Client has to be able to record refactorings– Server has to have knowledge about the project structure like Microsoft Team Foundation Server does– Server has to be able to replay refactorings
CVS Client
transmit the changed file
CVS Server
CVS Client
transmitt refactoring
CVS Server
09.12.2008
© Raphael Gfeller, [email protected] 23
New fields of application
Based on “approach 8” and “Reduce the transferred data in a CVS “:
Extend change management within a small companySituation:– A Company uses their common code C in different Projects P1-n
– During evolution, multiple versions of C exits. P1-n reference on one of the special versions of C.
Bug fixing of C becomes painful
Optimization:– Server has to have knowledge about all projects in a company.– Transmitted refactorings are forwarded to the C and to the referenced
projects P1-n that are using C.
Only one version of C exists. All projects within the company are using the actual version of the C.
09.12.2008
© Raphael Gfeller, [email protected] 24
New fields of application
Based on “approach 9”:
Component EvaluationSituation:– Normally more than one component does the same job. Evaluation is a time intensive job.Assumption:– If a component CA is doing nearly the same job as CB
API of CA and CB is similar
Optimization:– Test the application with CA test T, application A and test result R
Realize a tool that:1. Find refactoring between CA and CB Ref
2. Apply Ref on A A’, on T T’3. Run T’ on A’ R’, store R’4. [For all component goto 1]5. Display all R’6. Convert A to use with the best component C.
Programcould do the job with
Component 1 from
Vender A
Component 2 from
Vendor B
Component 3 from
Vendor C
09.12.2008
© Raphael Gfeller, [email protected] 26
References• Gfeller Raphael, Upgrading of component-based application, [Online]
7.12.2008. [Citied 7.12.2009]http://wiki.ifs.hsr.ch/SemProgAnTr/wiki.cgi?AUTOMATEDUPGRADINGOFCOMPONENT-BASEDAPPLICATIONS
09.12.2008