Вы находитесь на странице: 1из 6

JOURNAL OF COMPUTING, VOLUME 3, ISSUE 4, APRIL 2011, ISSN 2151-9617

HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 44

Software Testing Approach for Detection


and Correction of Design Defects in
Object Oriented Software
Dinesh Kumar Saini1 Lingaraj A. Hadimani 2 and Nirmal Gupta 3
1 Faculty of Computing and Information Technology, Sohar University, Oman
2. Caledonian College of Engineering, Oman
3. Computer Science Departments, I.P.C.Unit, BITS Pilani, India
Abstract:
The presence of design defects in object oriented software can have a severe impact on the quality of software. The detection
and correction of design defects is an important issue for cost effective maintenance. In this work we propose an automatic
detection technique which uses the design patterns as reference for good design to detect the design defects in existing
software design. We also propose the correction technique which can refactor the code to meet the design specifications using
the concept of class slicing. We can use this technique for any code in which classes are excessively coupled together thereby
not meeting with the good design specifications for an object oriented software.

——————————  ——————————

1 INTRODUCTION
from high level design problems such as antipatterns to
Software systems have become a indispensable part of low level or local problems such as code smells”. Since
business and commerce in modern world. Therefore the the design defects are because of bad solutions to recur-
quality has become vital both to ensure the proper func- ring problems design, whose origins are from poor design
tioning of the systems and to reduce costs of development practices [5] and also different defects which are “devia-
and maintenance. The quality of software is evaluated tions from specifications or requirements” which may
and improved during the whole life cycle of software de- result in failures in the operations [6] [7]. They include
velopment, which aims to detect errors earlier during problems at different levels of granularity: Architectural
development. The errors caused during software design problems such as anti-patterns [8] and problems such as
are called design defects [1]. If these errors and defects are low bad smells [9] which are usually signs of anti-
caught earlier in design phase they can not move to the patterns. Anti-pattern is defined as a design pattern that
next stage of development or maintenance or in worst may be commonly used but is ineffective and/or coun-
case to the client. terproductive in practice [10].
Software is said to be evolved. In software mainten-
ance when the software is enhanced, modified or changed The anti-pattern may be the result of a developer not
for a new requirement, the software code becomes more knowing any better design pattern or doesn’t have suffi-
complex and the software design changes from the origi- cient knowledge or expertise in solving any particular
nal design. One important step towards maintaining ob- type of problem, solves it or applies a perfectly good pat-
ject oriented software is to detect its design defects oth- tern in the wrong context. Such practice produces a de-
erwise it may cause problems for maintenance. According sign defect in solving a problem. So the design defects
to Fowler [2] a “design defect” is bad smell of design must be prevented and therefore systematic ways to
mainly due to violation of one or more design principles. detect and correct design defects are needed. An example
These design principles were called as heuristics by Reil of such a design defect is the Spaghetti Code [11] which
[3] and he described that such rules should be thought of characterizes the use of procedural programming in a
as a series of warning bells that will ring when violated. system by objects. The Spaghetti Code is revealed by
According to Moha [4] the design defect is defined as classes that have no structure, declaring many methods
“design defects are “bad solution” to recurring design without parameters using global variables. The names of
problems in object oriented systems. Design defects are classes may suggest a procedural programming. It does
problems resulting from bad design problems ranging not operate and prevents the use of mechanisms of object-
oriented programming such as polymorphism and inhe-
ritance. This defect occurs because the correct object
————————————————
oriented design rules are violated resulting in Spaghetti
 Dinesh Kumar Saini is with Faculty of Computing and Information Tech-
nology, Sohar University, Oman. Code.
 Lingraj Hadimani is with Caledonian College of Engineering, Oman
 Nirmal Gupta is with Dept. of Computer Science , BITS Pilani , Rajasthan
Inida .
The defects have a negative impact on the quality of
JOURNAL OF COMPUTING, VOLUME 3, ISSUE 4, APRIL 2011, ISSN 2151-9617
HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 45

object-oriented systems and make it difficult to address sign defects are software defects at the architectural level
debugging and development system. Therefore, their de- and their detection and correction to them is important to
tection and correction early in the development process improve software quality. They presented techniques and
can significantly reduce development costs and mainten- tools to detect design pattern defects and a case study that
ance [12]. But their detection requires significant re- illustrates the use of these techniques and tools.
sources in time and personnel and is subject to many er- Big part of the effort is spent on identifying those parts
rors because the defects usually involve several classes of the system that are affected by particular design de-
and methods. fects, and which need to be redesigned in order to achieve
the reengineering goal. In [18] Radu Marinescu presented
a metrics-based approach for detecting design prob-
1.1 The Problem of Detection and Correction of lems, and describes two concrete techniques for the
Object Oriented Design Defects detection of two well-known design problems: god-
The quality of the software applications is the major con- classes and data-classes. The detection and correction of
cern for the development team. Development of a fault design defects are two different approaches and there
free maintainable and adaptable code is a hard task. Dur- exists a conceptual gap between these two stages. There is
ing maintenance of the software, one needs to analyze the a lack of appropriate support for the automated mapping
code to understand its structure and behavior. After that of design defects to possible solutions. In [19] Adrian Tri-
the identification of correct location is needed so that new fu et. al. describes an approach based on the concept of
requirements could be added or existing defects could be “correction strategies” which serve as reference descrip-
removed. Also, another challenge is to see that the mod- tions that enable a human assisted tool to plan and per-
ifications should not break the functionality of rest of the form all necessary steps for the safe removal of detected
software. Around 75% of software life cycle efforts and design defects, with special concern towards the targeted
around 80% of development time goes with maintenance quality goals of the restructuring process.
of the software [25]. The correction of extension of soft- These techniques are restricted by the services plat-
ware can be done by experts who are capable with both form for discovering the underlying defects. They mainly
the forward and reverse engineering skills. The accurate use the measurements to detect defects, while ignoring
identification of object oriented design defects is a must to other important characteristics of systems, such as archi-
perform the maintenance task. After identification devel- tecture. Refactorings are structural transformations that
opers can use refactoring techniques to eliminate defects. can be applied to a software system to perform design
Design defects can be classified in three categories name- changes without modifying its behavior. They are actual-
ly: Intraclass, Interclass and behavioral design defects ly the change suggestions and are not directly applicable
[13]. To address intraclass design defect class slicing [14] over a system. There are different stages of a refactoring
can be used as a refactoring technique to redesign the technique. A review and a thorough analysis begin before
classes and maintain their relationship and behavior. applying a refactoring technique, which results in a list of
findings. These various refactoring stages [20] are as fol-
lows:
2. BACKGROUND STUDY: 1. Identify spots within the software system where
it needs to be refactored
2. Determine the refactorings that may be applied
Several approaches have been proposed for detection and in these spots
correction of software design defects. According to Moha 3. Apply the refactorings (whether manual or au-
[4] the detection and correction of design defects due to tomatic)
poor design choices, are difficult because of the lack of 4. Use some automated tools (metric-based, for in-
precise specifications of defects and tools for their detec- stance) to make sure the quality of the design has
tion and correction. He provides a technique for automat- actually increased as an effect of the refactoring
ic generation and detection of algorithms from the design 5. Synchronize the refactored code with other re-
specifications. Other techniques described by Radu [15] lated software artifacts (documentation, tests,
provide metric based rules to detect ten important flaws etc.)
of object-oriented design found in the literature. The in- Refactoring document is a correction sequence specifi-
ternal structure of the source code helps the programmers cation corresponding to the system design specification. It
to evolve and understand a system to improve the overall is automatically executed to achieve the appropriate sys-
design. If something goes wrong with the source code, it tem behavior without changing the system behavior. The
gives rise to code smell [9]. Munro [16] addresses the bad framework to support automatic or assisted generation of
smells by identifying the characteristics of a bad smell refactoring document is needed to provide very high lev-
through the use of a set of software metrics. There are el (big) refactorings for design improvement, using refac-
various techniques available in literature to detect and toring plan generation together with the defect detection
correct the design defects in object oriented software. techniques that suggest redesign proposals.
Moha et al. [17] define design defects as occurring errors
in the design of software that come from the absence or
the bad use of design patterns. According to him the de-
JOURNAL OF COMPUTING, VOLUME 3, ISSUE 4, APRIL 2011, ISSN 2151-9617
HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 46

2.1 Defect Detection Approach: 4. Object Oriented Design Knowledge base: An object
We provide an approach to get a systematic method to oriented design knowledge base consists of basically four
detect design defects precisely and correct them through parts which are called as design principles, design de-
a refactoring technique. The basic concept for design de- fects, design metric suites and features. The design fea-
fect detection and correction technique is shown in Figure tures relate the primary classifier to this level. Actually
1. design defects are violations of the design principles. A
design pattern can be a reference for a good design. Ac-
tually a design pattern describes a standard solution to

Figure 1. Design defect detection and correction process

The detection process is explained below: solve a common design problem. The solution given by a
design pattern is based on the design concepts of expe-
1. Specify the quality goals: For any particular system rienced software engineers [21]. The design knowledge
the quality goal which has more priority than other quali- base consists of a meta model to represent the design pat-
ty goal must be chosen. For any specific quality goal de- terns. There exists various meta models to represent the
sired for the software we can only decide the defects design patterns but they are not specifically designed to-
which are required to be detected. The impact of the spe- wards detection and code transformation. We can use a
cific quality factor is only desired so in relation with that meta model given in [13]. The meta model will consist of
quality goal the decision of detection of any particular a set of entities and interaction rules among them.
design defect can be determined. In this context only The design principles consist of rules for good design
those design defects must be considered and decision is as described by the meta model for design patterns. These
required to be taken which actually have impact on the design rules are based on the design principles and their
quality in consideration. goal is to improve quality factors of the system and avoid
occurrence of design defect.
2. The static program analysis: It follows the program
analysis techniques like control and data flow analysis 5. Detection Process: The detection process is a two level
techniques so that it gives a program dependency graph. process. The first level is a primary classifier which aims
This program dependency graph works as an abstract at indicating a preliminary indication of design defect.
model for the program and can be used effectively by the Detection of potential defects is done by some primitive
metric computation block to compute the object oriented rules defined in the object oriented knowledge base for
metrics for the given program. the specified design defects. For describing the categories
at this level the fuzzy terms are most suitable because
3. Metric Computation: The user may be especially inter- they can be configured later for purpose of flexibility by
ested in some specific quality goals. Therefore according different systems and it also reflects the uncertainty of the
to those specific quality goals the corresponding quality precise value in detection of design defects.
metrics may be targeted. The computed object oriented At the second level of detection the aim is to detect the
metrics include metrics like size, complexity, coupling design defects accurately. At second level the secondary
and cohesion metrics. This type of model provides a classifier measures more details about the defects de-
strategy for detecting design defects using metrics. Metric tected by primary classifier. To improve the accuracy of
values are divided into five different levels: "very low", level two measurements we measure each design feature
"low", "medium", "high" and "very high". Classes which by using several metrics.
have metrics values belonging to a specified level are kept
as candidate.
JOURNAL OF COMPUTING, VOLUME 3, ISSUE 4, APRIL 2011, ISSN 2151-9617
HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 47

6. Design Defect Identification: Identifying the all possi- toring activities to refine and clean-up inconsistent or
ble design defects doesn’t make sense because when it is insufficient design decisions.
performed automatically it may lead to a large number of The decision is influenced by the fact that behavior
probable design defects present in the system. These au- preserving conditions must be checked. Class slicing con-
tomatically generated defects must be inspected manually siders PDG (Program Dependency Graph) and applies
and the user must decide which are relevant according to Object Oriented program slicing to extract class. The
earlier defined quality goals. It identifies the design de- strategy to refactoring a class involves various steps. In
fects in terms of design patterns that is the rules which first step we break SCC (Strongly Coupled Classes).
were not properly followed during the software design. In Figure 2 for any given two nodes X and Y
(represents two classes X and Y) in PDG, CXY denotes the
7. Suggest changes: In this step the process suggests the measure of coupling (CBO) between classes X and Y [23].
required changes to be done in the design to achieve the CBO is a count of the number of other classes to which a
quality goals earlier specified. These changes required are class is coupled. CBO is measured by counting the num-
actually UML specifications obtained from design pat- ber of distinct non- inheritance related class hierarchies
terns. These change suggestions can be used to do the on which a class depends. Excessive coupling prevents
correction in defective design. reuse [24].The higher the coupling the more sensitive the
system is to changes in other parts of the design, and
therefore maintenance is more difficult.
2.2 Defect Correction Approach:
The correction approach, on receiving the suggested 3. Slicing Classes: This step searches for a class which can
changes, generates the required changes in the code. The be isolated at first place. The main purpose of this step is
technique to eliminate design defect considers the de- to search a class that can be isolated. We separate this
scription of solution and its variation to some given defect class to break cycles from the SCC.
which is identified with some quality goal. The technique First of all. we must select one cycle to be considered at
is explained through an example in figure 2. a time. But the first priority type is the smallest cycle of all
The technique is based on class slicing technique [22]. SCCs from cycle detection. If desired class is found, we
The technique targets correction which includes the spe- will use class slicing to separate and order them. After
cific behavior preserving code transformation technique that the adjacency cycle is connected and class slicing is
including a redesign proposal. It may contain code refac- repeated until no cycle remains.
toring technique, behavior altering transformation, condi-
tional or iterative behavior altering transformations. The 4. Software Redesign: Software redesign is concerned
code refactoring technique which includes refactoring with identification, application and refinement of new
plan can either be executed automatically or in a semi ways to improve and transform software processes.
automatic manner. The overall behavior of the code Based on the suggestions to change the design this step
should not change, means the preconditions and post modifies the earlier design in defect.
conditions of the method remains the same. In this way
the behavior of class object would be same as a whole. 5. Result Refinement: The detected design defects must
be checked again to remove the false positives. The source
The following are the steps through which the tech- code is again analyzed for the detected/undetected de-
nique will work. sign defects. The design defects which look to affect se-
verely must be figured out first.
1. Trimming the classes: This step takes PDG (Program
Dependency Graph) as input and forward trim starts with
all nodes with no ancestors and removes them and all
their edges. After removal the nodes with no ancestors 3. CONCLUSION AND FUTURE WORK:
may appear so this trimming will continue until no more
nodes can be removed [22]. Similarly the backward trim Detection of design defects is important for improving the
performs the same operation but starts with classes with quality of object oriented software systems to facilitate
no descendants and uses topological sorting to find test their development. The total cost of software develop-
orders. The purpose of trimming is separating those ment is also reduced because the manual detection of de-
classes with no concerning cycles and pre ordering these fective design is tedious and time consuming. In this
classes. work we presented a systematic technique that covers the
process of design defects detection using object oriented
2. Refactoring Formalization: We look for a refactoring patterns as knowledge base, and given a correction tech-
formalization method which can be used to deal with the nique which uses class slicing to refactor the classes to
system architecture. The refactoring of the target software improve the design. This method may facilitate the de-
architecture must be done step-wise via a number of well- velopment of concrete tools for the detection and correc-
defined, small increments. Each increment might include tion of design defects. The tool developed will be helpful
a top-down refinement activity to detail and complete the for validating the concepts by applying to various case
software architecture. We can also use bottom-up refac- studies.
JOURNAL OF COMPUTING, VOLUME 3, ISSUE 4, APRIL 2011, ISSN 2151-9617
HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 48

Figure 2. Defect correction through slicing classes

REFERENCES:
10. Budgen, D. (2003). Software design. Second Edition, Addi-
1. Subramanyam, R. Krishnan, M. S., Empirical Analysis of
son-Wesley.
CK metrics for object-oriented design complexity: implica-
11. Brown et al. 1998, AntiPatterns, Refactoring Software, Ar-
tions for software defects, IEEE transactions on software
chitectures and Projects in Crisis. Wiley Computer
engineering, 2003, vol 29; part 4, pages 297-310.
Publishing.
2. M. Fowler. Refactoring - Improving the Design of Existing
12. Pressman, R. S. 1996 Software Engineering: a Practitioner's
Code. Addison-Wesley, 1st edition, June 1999.
Approach. 4th. McGraw-Hill Higher Education.
3. Riel, A. J. 1996 Object-Oriented Design Heuristics. 1st.
13. Guéhéneuc, Y. and Albin-Amiot, H. 2001. Using Design
Addison-Wesley Longman Publishing Co., Inc.
Patterns and Constraints to Automate the Detection and
4. Moha, N. 2007. Detection and correction of design defects
Correction of Inter-Class Design Defects. In Proceedings of
in object-oriented designs. In Companion To the 22nd
the 39th international Conference and Exhibition on Tech-
ACM SIGPLAN Conference on Object-Oriented Pro-
nology of Object-Oriented Languages and Systems
gramming Systems and Applications Companion (Mon-
(Tools39) (July 29 - August 03, 2001). TOOLS. IEEE
treal, Quebec, Canada, October 21 - 25, 2007). OOPSLA '07.
Computer Society, Washington, DC, 296.
ACM, New York, NY, 949-950.
14. Larsen, L. and Harrold, M. J. 1996. Slicing object-oriented
5. Perry, D. E. and Wolf, A. L. 1992. Foundations for the
software. In Proceedings of the 18th international
study of software architecture. SIGSOFT Softw. Eng. Notes
Conference on Software Engineering (Berlin, Germany,
17, 4 (Oct. 1992), 40-52]. They are the opposite of design
March 25 - 29, 1996). International Conference on Software
patterns [Gamma, E., Helm, R., Johnson, R., and Vlissides,
Engineering. IEEE Computer Society, Washington, DC,
J. (1995). Design Patterns - Elements of Reusable Object-
495-505.
Oriented Software, Addison-Wesley.
15. Radu Marinescu, Detection Strategies: Metrics-Based
6. Fenton, N. E. and Neil, M. 2000. Software metrics: road-
Rules for Detecting Design Flaws, Proceedings of the 20th
map. In Proceedings of the Conference on the Future of
IEEE International Conference on Software Maintenance
Software Engineering (Limerick, Ireland, June 04 - 11,
(ICSM 2004), IEEE Computer Society Press, pages 350 -359,
2000). ICSE '00. ACM, New York, NY, 357-370.
2004.
7. M. H. Halstead. Elements of Software Science. Elsevier
16. Munro, M. J. 2005. Product Metrics for Automatic
New Holland, New York, 1977.
Identification of "Bad Smell" Design Problems in Java
8. Brown et al. 1998, AntiPatterns, Refactoring Software, Ar-
Source-Code. In Proceedings of the 11th IEEE international
chitectures and Projects in Crisis. Wiley Computer
Software Metrics Symposium (September 19 - 22, 2005).
Publishing.
METRICS. IEEE Computer Society, Washington, DC, 15.
9. M. Fowler. Refactoring - Improving the Design of Existing
17. Naouel Moha, Duc-Loc Huynh, Yann-Gaël Guéhéneuc. A
Code. Addison-Wesley, 1st edition, June 1999.
JOURNAL OF COMPUTING, VOLUME 3, ISSUE 4, APRIL 2011, ISSN 2151-9617
HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 49

Taxonomy and a First Study of Design Pattern Defects.


Proceedings of the STEP International Workshop on
Design Pattern Theory and Practice, September 25-30,
2005, Budapest, Hungary.
18. Radu Marinescu, Detecting Design Flaws via Metrics in
Object-Oriented Systems, Proceedings of 39th
International Conference and Exhibition on Technology of
Object-Oriented Languages and Systems (TOOLS39), IEEE
Computer Society Press, 2001
19. Trifu, A., Seng, O., and Genssler, T. 2004. Automated
Design Flaw Correction in Object-Oriented Systems. In
Proceedings of the Eighth Euromicro Working Conference
on Software Maintenance and Reengineering (Csmr'04)
(March 24 - 26, 2004). CSMR. IEEE Computer Society,
Washington, DC, 174.
20. T. Mens, T. Tourwe: A Survey of Software Refactoring,
IEEE Transactions on Software Engineering, Vol. 30, No. 2,
February 2004.
21. Beck, K., Crocker, R., Meszaros, G., Vlissides, J., Coplien, J.
O., Dominick, L., and Paulisch, F. 1996. Industrial
experience with design patterns. In Proceedings of the
18th international Conference on Software Engineering
(Berlin, Germany, March 25 - 29, 1996). International
Conference on Software Engineering. IEEE Computer
Society, Washington, DC, 103-114.
22. Jaroenpiboonkit, J. and Suwannasart, T. 2007. Finding a
Test Order using Object-Oriented Slicing Technique. In
Proceedings of the 14th Asia-Pacific Software Engineering
Conference (December 04 - 07, 2007). APSEC. IEEE
Computer Society, Washington, DC, 49-56.
23. Briand, L. C., Daly, J. W., and Wüst, J. K. 1999. A Unified
Framework for Coupling Measurement in Object-Oriented
Systems. IEEE Trans. Softw. Eng. 25, 1 (Jan. 1999), 91-121.
24. A. A. Zakaria and H. Hosny. Metrics for aspect-oriented
software design. In AOM: Aspect-Oriented Modeling
with UML, AOSD, March 2003.
25. S. Woods, A. Quilici, and Q. Yang. Constraint-Based
Design Recovery for Software Re-engineering: Theory and
Experiments. Kluwer Academic Publishers, 1998.

Вам также может понравиться