Learning Software Engineering Principles

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Session S3H

Learning Software Engineering Principles


Using Open Source Software
Jagadeesh Nandigam, Venkat N Gudivada, and Abdelwahab Hamou-Lhadj
[email protected], [email protected], [email protected]

Abstract - Traditional lectures espousing software such as TextPad. They also typically do not get opportunities
engineering principles hardly engage students' attention to examine others’ code which prevents them from
due to the fact that students often view software understanding the challenges of writing code that others can
engineering principles as mere academic concepts easily comprehend and maintain. Just as reading good
without a clear understanding of how they can be used in writing is used as a basis to teach students to write well, we
practice. Some of the issues that contribute to this believe that examining the code written by software
perception include lack of experience in writing and professionals entails several benefits for aspiring software
understanding large programs, and lack of opportunities engineers.
for inspecting and maintaining code written by others. Therefore, the overarching goal of this project is to
To address these issues, we have worked on a project teach students a subset of basic software engineering
whose overarching goal is to teach students a subset of principles by focusing on the practical aspect of software
basic software engineering principles using source code engineering. For this purpose, we selected a subset of
exploration as the primary mechanism. We attempted to activities that we believe can enrich significantly the
espouse the following software engineering principles students experience when dealing with software. These tasks
and concepts: role of coding conventions and coding include browsing and exploring an open source code base,
style, programming by intention to develop readable and assessing the quality of the design based on computed
maintainable code, assessing code quality using software software metrics, applying reverse engineering techniques to
metrics, refactoring, and reverse engineering to recover synthesize higher abstractions, and performing refactoring
design elements. Student teams have examined the and assessing the impact of proposed changes to the code
following open source Java code bases: ImageJ, Apache base.
Derby, Apache Lucene, Hibernate, and JUnit. We have The software engineering course where this project is
used Eclipse IDE and relevant plug-ins in this project. incorporated into the syllabus is offered as a junior/senior
undergraduate level course. It should be noted that the intent
Index Terms – Eclipse, Open source software, Source code of our approach is not to provide any quantitative metrics on
exploration, Software engineering education. the tasks that the students were engaged in, but rather to
qualitatively assess the effect that the approach had on
INTRODUCTION students’ understanding of basic software engineering
Teaching software engineering (SE) principles and concepts concepts and principles at both conceptual and pragmatics
in a one-semester undergraduate software engineering levels.
course is a challenging task. Students often view software The remainder of the paper is organized as follows. In
engineering principles as mere academic concepts with less the next section, we describe the SE principles taught to our
practical value. We believe that this perception is a result of students. The open source software (OSS) and Eclipse plug-
the various projects they were involved with in the previous ins that were used in our project are discussed next.
computer science courses such as computer science I, Following this, the details of the procedure used in this
computer science II, data structures and algorithm analysis, project are provided. Related work in using open source
where the focus was on mere programming tasks rather than software in software engineering and computer science
analysis, design, implementation, and maintenance of education is described next. The last section concludes the
software systems. As a result, the largest programs that they paper.
have written did not exceed few hundred lines of Java code SOFTWARE ENGINEERING PRINCIPLES
with at most eight to ten classes. Though, they have a
conceptual understanding of how to structure a system into We used source code exploration of open source software
subsystems using constructs such as Java packages, they applications as the primary means to expose students to
have not applied these concepts due to the trivial nature of various software engineering concepts. The SE concepts we
the programming problems that they have worked on thus focused on in this paper include:
far. In addition, their exposure to Integrated Development • Familiarizing students with the contents of an open
Environments (IDE) is limited to the simpler ones such as source software applications at various levels of detail
DrJava and BlueJ, and in some cases it is just a simple editor using Eclipse IDE perspectives and views.
978-1-4244-1970-8/08/$25.00 ©2008 IEEE October 22 – 25, 2008, Saratoga Springs, NY
38th ASEE/IEEE Frontiers in Education Conference
S3H-18
Session S3H
• Assessing conformance with established coding software quantitatively so to enable classification,
conventions and style. comparison, and analysis tasks. In addition, metrics provide
• Programming by intention as a way to develop simple, support for planning, monitoring, controlling and evaluating
clear, readable, and maintainable code. the software process and/or product. In this paper, we focus
• Understanding and appreciating the role of software mainly on software product metrics such as size metrics,
metrics in assessing code quality. logic complexity metrics, cohesion, coupling, and certain
• Reverse engineering parts of the code to recover various OO metrics. These metrics can be automatically computed
design elements in the form of UML diagrams. using Eclipse plug-ins. The goal of this activity is to drive
• Understanding what and how of refactoring and home the point that there are quantitative aspects to the
applying some basic refactoring techniques to the target software engineering activities.
source code. V. Reverse Engineering
Reverse engineering is the process of analyzing a software
I. Source Code Browsing system to create representations of the system at higher
Eclipse IDE with JDT (Java Development Tools) [1] and levels of abstraction [7]. The primary goal of reverse
related plug-ins are used for the source code exploration engineering is to help software engineers understand a
activities of the open source software applications studied. poorly documented software system when solving
JDT offer four perspectives to understand various parts of a maintenance tasks. Reverse engineering has many key
project: Java, Java Browsing, Java Type Hierarchy, and objectives, but the ones that are directly relevant to our
Debug. A perspective in Eclipse workbench is a collection project consist of generating alternate views and
of editors and views. An editor allows you to read and/or synthesizing higher abstractions from the source code. These
write a particular file type. A view is a metadata presentation views are represented using UML. For this purpose, Eclipse
of information on the workbench. Some commonly used UML plug-ins were used. A secondary goal of this activity
views in JDT include Package Explorer, Outline, and is to emphasize the importance of producing and preserving
Hierarchy. Using these perspectives and views, one can gain analysis and design artifacts and their role in comprehending
good understanding of the various components that make up large software systems.
the source code of a software package. For most of our VI. Refactoring
students, this is the first time that they have been exposed to
software systems that are comprised of various packages and The goal of refactoring is to improve the design or internal
significant number of classes within packages. structure, make it easier to understand and cheaper to modify
[2, 3]. Refactoring is an on-going activity during
II. Coding Conventions and Style development and should be done when new functionality is
Coding conventions and style contribute to readability and added, defects are fixed, code is reviewed, and bad code
maintainability of an application. In this project, we used smells are detected [3]. Major IDEs available in the market
coding conventions for the Java language developed by Sun today provide some degree of support for performing
Microsystems. While browsing the source code, students refactoring activities on source code. Our project uses
were asked to qualitatively assess the extent to which their Eclipse IDE which provides good support for refactoring.
code adheres to the Sun coding conventions and consistency Students recognize that just as any good piece of writing
in style through manual inspection and/or using a relevant requires a few iterations and revisions, producing quality
Eclipse plug-in. The goal here is to impress upon the software requires continuous improvements throughout the
students that coding conventions and style are essential to development life cycle.
any real-world software system which is typically developed
by scores of software engineers. OPEN SOURCE SOFTWARE USED

III. Programming by Intention We have used the following open source software packages
in the source code exploration project:
Code readability is enhanced by making your intention clear • ImageJ – an image processing and analysis system
when you write code – programming by intention [2]. The (http://rsb.info.nih.gov/ij/) from the National Institutes
main idea of programming by intention is to make code as of Health (NIH).
understandable and intent-revealing as possible by • Apache Derby – an open source relational database
appropriately choosing the names of the identifiers used in a implemented entirely in Java
program such as classes, variables, methods, etc. Students (http://db.apache.org/derby/). This system has a small
recognize that producing quality software is a highly footprint that enables it to be embedded into real-time
intellectual activity, and never a mechanical task. applications.
IV. Software Metrics • Hibernate – an easy to use framework for mapping an
object-oriented domain model to a traditional relational
Software metrics measure various aspects of a piece of database (http://www.hibernate.org/).
software [5, 6]. They help characterize features of interest in

978-1-4244-1970-8/08/$25.00 ©2008 IEEE October 22 – 25, 2008, Saratoga Springs, NY


38th ASEE/IEEE Frontiers in Education Conference
S3H-19
Session S3H
• Apache Lucene – is a high-performance, full-featured • Obtain the source code of the assigned open source
text search engine library written entirely in Java. It is software, create a project in Eclipse, and import the
suitable for nearly any application that requires full-text source code.
search (http://lucene.apache.org/java/docs/index.html). • Each student team uses the IDE and the plug-ins to
• JUnit – a unit testing framework for the Java prepare responses to a generic questionnaire provided to
programming language (http://www.junit.org/). them. Teams submit their project results in the form of a
report.
The students were also required to download and install • Each student team is also required to present their
the following Eclipse IDE and related plug-ins. Eclipse project findings at the end of the semester.
Plugin Central (http://www.eclipseplugincentral.com) is a
central resource that offers the Eclipse community a Student teams pursue the project with the intent to
convenient portal to find useful open source and commercial provide answers to six broad source code exploration
plug-ins for the entire software development life cycle. activities specified earlier in the Section on Software
Engineering Principles. The aim is to provide hands-on
• Eclipse IDE for Java Developers learning of basic software engineering concepts. Details of
(http://www.eclipse.org/downloads/). This IDE is used these six activities are briefly discussed in the rest of this
for Java development and is crucial for exploring and section.
browsing large source code bases. I. Source Code Browsing
• Checkstyle plug-in for Eclipse (http://eclipse-
cs.sourceforge.net/). It is a configurable development Teams use Eclipse IDE and its perspectives (Java, Java
tool that verifies whether certain Java code adheres to a Browsing, and Java Type Hierarchy) and views (Package
coding standard. It comes with a default configuration Explorer, Outline, and Hierarchy) to obtain answers to the
file that supports Sun Java code conventions following questions:
(http://java.sun.com/docs/codeconv/). Students can • How many packages does your application contain?
define their own coding standards by changing the What are their names?
configuration file. • Browse the classes within a package using the Package
• Eclipse Metrics 3.3.1 plug-in (http://eclipse- Explorer. Based on the class names and the
metrics.sourceforge.net/). This tool calculates various documentation in the source code, can you tell what the
metrics such as lines of code, McCabe’s cyclomatic overall purpose of the package is?
complexity, coupling, cohesion, and OO metrics. • Select any package and one of its classes. Using the
• Metrics 1.3.6 plug-in (http://metrics.sourceforge.net/). Hierarchy View, list all the ancestral classes of the
This tool also calculates various size and logic class. Likewise, list all classes that are derived from
complexity metrics, cohesion and coupling OO metrics your chosen class.
based on the metrics proposed in [8, 9]. • In the Outline View, examine a non-trivial method of a
• EclipseUML plug-in by Omondo class. Is the code self-describing? Can you explain the
(http://www.eclipseuml.com/), a powerful Java reverse purpose of the method without too much difficulty? If
engineering tool that allows visualization of design not, what factors contributed to un-readability of the
elements of Java source code. This plug-in is used for code? Are the provided comments useful and seem
reverse engineering activities for the project. adequate?
• Refactroing functionality supported within Eclipse IDE. II. Coding Conventions and Style
PROJECT PROCEDURE This activity focuses on coding conventions and coding
style. For this purpose, coding conventions for the Java
The SE project that students worked on used the procedure language developed by Sun Microsystems are used. Student
described in this section. Students worked in teams. Each teams skim through these coding conventions to answer the
team is limited to two to three students. Each team is following questions:
assigned an open source software package from the list –
• Consider the coding conventions for line length in the
ImageJ, Apache Derby, Hibernate, Apache Lucene, and
Sun document. Browse your application source code
JUnit. Students were required to complete the following
and determine if this coding convention has been
tasks:
consistently followed.
• Download and install the latest Java Development Kit
• Consider the coding conventions for line wrapping in
(JDK) from Sun.
the Sun document. Browse your application source code
• Download and install Eclipse IDE for Java Developers. and determine if this coding convention has been
• Download and install the plug-ins: Checkstyle, Eclipse consistently followed.
Metrics 3.3.1 and/or Metrics 1.3.6, and EclipseUML. • Consider the coding conventions for various types of
comments – block, single line, trailing, end-of-line, and
documentation – in the Sun document. Browse your
978-1-4244-1970-8/08/$25.00 ©2008 IEEE October 22 – 25, 2008, Saratoga Springs, NY
38th ASEE/IEEE Frontiers in Education Conference
S3H-20
Session S3H
application source code and determine if this coding the metric values obtained – is metric value within desired
convention has been consistently followed. range or outside the desired range. If the metric is outside
• Consider the coding conventions for declarations – the desired range, suggest what actions (possible refactoring
number per line, placement, and initialization – in the actions) need to be taken. A sample listing of metrics
Sun document. Browse your application source code computed using the chosen metrics plug-in is shown below:
and determine if this coding convention has been • McCabe's Cyclomatic Complexity
consistently followed. • Efferent Coupling
• Consider the coding conventions for statements – while, • Afferent Coupling
switch, and try-catch – in the Sun document. Browse • Lack of Cohesion in Methods
your application source code and determine if this • Total Lines of Code
coding convention has been consistently followed. • Number of Fields
• After answering the above questions qualitatively, the • Number of Levels
project teams ran Checkstyle plug-in on their source • Number of Parameters
code base. Next, they carefully interpreted the results • Number of Statements in Method
produced by the plug-in with their qualitative
• Weighted Methods per Class
assessment of the source code base by visual
• Number of Methods
examination.
• Number of Static Methods
III. Programming by Intention • Number of Classes
The goal of programming by intention is to develop • Number of Children
programs that are clear and readable by choosing names • Number of Interfaces
(identifiers) that are semantically transparent. Suggested • Depth of Inheritance Tree
patterns by Astels [2] for choosing names are - using nouns • Number of Overridden Methods
or noun phrases for class names; using either adjectives or • Specialization Index
generic nouns and noun phrases for interfaces; using verbs • Instability
and verb phrases for method names; using accepted • Abstractness
conventions for accessors and mutators; and using nouns and
noun phrases for variable names. Another suggested pattern V. Reverse Engineering
by Fowler [3] is not to use comments as “deodorant” and use
them for valid and necessary reasons. Students conduct reverse engineering activities on the
To complete this activity, student teams browse at least chosen code base using the EclipseUML plug-in. Students
about 10% of the source code. They browse in a way to are advised to start with a small scope (e.g., a package) to
cover code across different packages and classes. Teams understand how EclipseUML works and then increase the
answer the following questions, and justify their answer by scope to multiple packages or even the entire application.
documenting the parts of code visited and the observations The reverse engineering activities to generate higher
made. abstractions (primarily in graphical representation) of the
• Browse your application source code and determine if software system under exploration include:
class names subscribe to programming by intention • Generate a package diagram
principles. • Generate class diagrams
• Browse your application source code and determine if • Generate sequence or collaboration diagrams
interface names subscribe to programming by intention
principles. VI. Refactoring
• Browse your application source code and determine if
method names subscribe to programming by intention Fowler [3] recommends refactoring when bad smells are
principles. detected in code. Some example bad smells in code include
• Browse your application source code and determine if – duplicated code, long method, large class, lazy class, long
accessor and mutator names subscribe to programming parameter list, data class, overuse of switch statements,
by intention principles. inappropriate intimacy between classes, and unnecessary
• Browse your application source code and determine if comments. Effective refactoring requires knowledge of the
variable names subscribe to programming by intention domain and application code. However, we selected a subset
principles. of refactoring techniques that can be performed without
much domain knowledge since we do not expect students to
be knowledgeable of the domain of the target system.
IV. Software Metrics Student teams are encouraged to perform at least the
Using either the Eclipse Metrics 3.3.1 or Metrics 1.3.6 plug- following refactorings without spending too much effort to
in, student teams compute a set of software metrics for the understand the intimate details of the code base of the open
assigned open source software code base. They comment on source software package they are exploring.

978-1-4244-1970-8/08/$25.00 ©2008 IEEE October 22 – 25, 2008, Saratoga Springs, NY


38th ASEE/IEEE Frontiers in Education Conference
S3H-21
Session S3H
• Rename Method – If the name of a method does not students to larger projects, group work, distributed teams,
reveal its purpose, use this refactoring to change the and peer-review practice. Finally, Jaccheri and Osterlie [15]
name of the method. Similarly, one can rename classes describe how students can improve their programming and
and fields whose names are not semantically design skills by participating in open source projects.
transparent.
• Extract Method – Most of the problems come from CONCLUSIONS
methods that are too long. Short, well-named methods Teaching software engineering principles and concepts in a
are preferred. Fine-grained methods increase likelihood one-semester undergraduate Software Engineering course is
of method reuse. It also allows the higher-level methods a challenging task. Students often view software engineering
(that call the fine-grained methods) to read more like a principles as mere academic concepts with no practical
series of comments. In long methods, there is the value. To address and overcome these perceptions and
problem of semantic distance between the method name related issues, we used a project where we tried to expose
and the method body. students to some of the software engineering concepts in a
• Introduce Explaining Variable – Expressions can hands-on manner using open source software in Java,
become very complex and hard to understand. In such Eclipse IDE and related plug-ins. Each student team is
situations, temporary variables can be used to make assigned an open source software package to investigate
break an expression into one ore more parts that more using source code exploration activities.
readable and manageable. Student teams pursued the assigned project with the
• Remove Assignments to Parameters – In Java, intent to provide answers to six broad source code
parameters are passed by value. To avoid confusion and exploration activities – acquainting with an application, code
increase clarity, it is best not to assign to parameters. conventions and style, programming by intention, software
• Replace Magic Number with Symbolic Constant – using metrics, reverse engineering, and refactoring. The teams
magic numbers (literals) are one of the poor practices in have documented their findings as responses to a generic
computing. Their usage creates code that is less questionnaire provided to them by the instructor. The teams
readable and hard to maintain. Replace these magic have also presented their findings to the class.
numbers with symbolic constants. The project becomes a compelling exercise if we see its
merit qualitatively rather than quantitatively. During the
After these refactorings are performed, students are classroom presentations of the project, all student teams
asked to analyze the impact of each change, and to verify unequivocally asserted merit of the project as a means to
that the change is propagated correctly (i.e., code compiles quickly see the difference between writing a program and
after each refactoring). Of course, this is only part of the developing a software system. We suggest that this project
verification process required in any refactoring – proper test be assigned during the first week of semester and be
cases have to be run before and after each refactoring to completed within three weeks.
verify that observed behavior is still the same. Overall, the teams have obtained an increased
RELATED WORK appreciation for software engineering principles and
concepts in a very hands-on manner. More specifically, the
In recent years, there have been several attempts by project activities provided a solid backdrop for the SE
educators in using open source software for software course. Subsequent lecture and discussion on design metrics,
engineering and computer science education. Carrington and code maintainability, documentation, keeping the design and
Kim [10] describe how open source software engineering code synchronized at all times became more meaningful to
tools are used in a software design course where student the students. For example, for the first time, students could
teams inspect, report and modify or extend OSS tools to articulate quite eloquently about depth of class hierarchies,
perform reverse engineering, maintenance and refactoring and its practical ramifications.
activities. Raj and Kazemian [11] discuss the use of OSS in During the course of the project, students have also
several advanced courses – database systems, programming faced few frustrations that are common and expected when
language theory, and compilers. Student teams in these dealing with any real-world open source software. Importing
courses analyzed source code and made functional a code base into Eclipse and compiling it was the first
enhancements to OSS-based database engines, Scheme hurdle. It required students to discover code dependencies
tools, and compilers. Pedroni et al. [12] describe how and download related software packages. Instructor’s active
students in an advanced Java course were required to select involvement in the form of scaffolding is quite essential for
an open source project, identify parts (bug fixes, extensions, student success on this project. In summary, this project
and/or improvements) of the project to contribute code, provided an effective backdrop and platform for students to
make changes, and then report their experiences. Nelson and learn and apply software engineering concepts and
Ng [13] describe a computer networking course that made principles.
use of multiple open source packages. O’Hara and Kay [14]
describe popular open source licenses and the use of OSS in REFERENCES
computer science education and its potential to expose [1] Valcarcel, C, Eclipse 3.0 Kick Start, Sams Publishing, 2005.

978-1-4244-1970-8/08/$25.00 ©2008 IEEE October 22 – 25, 2008, Saratoga Springs, NY


38th ASEE/IEEE Frontiers in Education Conference
S3H-22
Session S3H
[2] Astels, D, Test-Driven Development – A Practical Guide, Prentice [12] Pedroni, M, Bay, T, Oriol, M, and Pedroni, A, “Open Source Projects
Hall, 2003. in Programming Courses,” SIGCSE, March 2007.
[3] Fowler, M, Refactoring – Improving The Design of Existing Code, [13] Nelson, D, and Ng, Y, M, “Teaching Computer Networking using
Addison-Wesley, 2004. Open Source Software,” ITiCSE, 2000, pp. 13-16.
[4] Booch, G, Rumbaugh, J, and Jacobson, I, The Unified Modeling [14] O’Hara, K, J, and Kay, J, S, “Open Source Software and Computer
Language User Guide, Addison-Wesley, 1999. Science Education,” The Journal of Computing Sciences in Colleges,
Vol. 18, No. 3, February 2003.
[5] Conte, S, D, Dunsmore, H, E, and Shen, V, Y, Software Engineering
Metrics, Benjamin Cummings, 1986. [15] Jaccheri, L, and Osterlie, T, “Open Source Software: A Source of
Possibilities for Software Engineering Education and Empirical
[6] Fenton, N, E, Software Metrics: A Rigorous Approach, Chapman and Software Engineering,” First International Workshop on Emerging
Hall, 1991. Trends in FLOSS Research and Development (FLOSS’07), 2007.
[7] Chikofsky, E, J, and Cross, J, H, “Reverse Engineering and Design
Recovery: A Taxonomy”, IEEE Software, January 1990, pp. 13-17. AUTHOR INFORMATION
[8] Henderson-Sellers, B. Object-Oriented Metrics – Measures of Jagadeesh Nandigam, Associate Professor, Computing and
Complexity”, Prentice Hall, 1996.
Information Systems, Grand Valley State University,
[9] Martin, R, C, Agile Software Development – Principles, Patterns, and Allendale, MI 49401, [email protected]
Practices, Prentice Hall, 2002.
[10] Carrington, D, and Kim, Soon-Kyeong, “Teaching Software Design Venkat N Gudivada, Professor, Engineering and Computer
with Open Source Software,” 33rd ASEE/IEEE Frontiers in Education Science, Marshall University, Huntington, WV 25755,
Conference, 2003.
[email protected]
[11] Raj, R, K, and Kazemian, F, “Using Open Source Software in
Computer Science Courses,” 36th ASEE/IEEE Frontiers in Education Abdelwahab Hamou-Lhadj, Assistant Professor, Electrical
Conference, 2006.
and Computer Engineering, Concordia University, Montreal,
Quebec H3G1M8, Canada, [email protected]

978-1-4244-1970-8/08/$25.00 ©2008 IEEE October 22 – 25, 2008, Saratoga Springs, NY


38th ASEE/IEEE Frontiers in Education Conference
S3H-23

You might also like