Halstead Calculator Doc Final

45
WKES 3206 Software Engineering II Project Report Group 6 2013/2014 Title: Halstead Calculator Group Members: Tang Kun Loon WEK 110059 Lee JengHaur WEK 110027 Lam Weng Fai WEK 110026 Lecturer: Dr Mumtaz Begum Mustafa

description

Report for creating a halstead calculator with component based development in java

Transcript of Halstead Calculator Doc Final

Page 1: Halstead Calculator Doc Final

WKES 3206 Software Engineering II

Project Report

Group 6

2013/2014

Title: Halstead Calculator

Group Members: Tang Kun Loon WEK 110059

Lee JengHaur WEK 110027

Lam Weng Fai WEK 110026

Lecturer: DrMumtaz Begum Mustafa

Date: 22nd April 2014

Page 2: Halstead Calculator Doc Final

Table of Contents

Interview Report.............................................................................................................................................2

Chapter 1:Introduction of Component-Based Development...........................................................................5

1.1 Introduction....................................................................................................................................5

1.2 Concepts and definitions.................................................................................................................5

1.3 Purpose or objective........................................................................................................................6

Chapter 2:NetBeans IDE GUI Builder Analysis.............................................................................................7

2.1 Introduction....................................................................................................................................7

2.2 Analysis of Identified or Reviewed Component Builder Tools.......................................................7

2.3 NetBeans IDE GUI Builder Scenarios (Conceptual Diagram)........................................................9

2.4 Use Case Diagram for NetBeans IDE GUI Builder......................................................................10

Chapter 3:Halstead calculator Application using NetBeans IDE GUI Builder.............................................12

3.1 Introduction..................................................................................................................................12

3.2 Halstead Metrics Definitions........................................................................................................12

3.3 Program Justification using Halstead Metrics...............................................................................14

3.4 Object Oriented Design.................................................................................................................14

3.4.1 Component Diagram....................................................................................................................14

3.4.2Class Diagram...............................................................................................................................15

3.4.3Architecture Diagram...................................................................................................................15

3.4.4Activity Diagram..........................................................................................................................16

3.5 User Interface Design...................................................................................................................16

Chapter 4:Implementation of Application....................................................................................................20

4.1 Introduction..................................................................................................................................20

4.2 System Environment.....................................................................................................................20

4.3 Programming Language................................................................................................................20

4.4 Operating Environment.................................................................................................................20

4.5 Component Specification and Standard........................................................................................20

4.6 System Implementation and Execution.........................................................................................21

4.7 System testing...............................................................................................................................21

Chapter 5: Comparison between Component Based and Traditional Development Methodology................23

5.1 Comparison between Monolithic and Componentized..................................................................23

5.2 Advantages and Disadvantages.....................................................................................................24

Page | 1

Page 3: Halstead Calculator Doc Final

Appendix......................................................................................................................................................25

Interview Report

Nature of Report

In order to gain insight into the component based software development and the opportunities

available for us to develop a component based application by using their existing product, the

students of Software Engineering II were instructed to interview a software company named F-

Secure. There were no stipulation about the medium used for the interview but the types of

questions that needed to be asked were examined by our lecturer, Dr.Mumtaz Begum binti Peer

Mustafa. Studentswere permitted to select their own respondent in hopes that they would be able to

interview someone or company involved in component based software development that the

student found interesting. The report aims to increase the knowledge and understanding level of

the students about component based software development.

Respondent's Background

The respondent we conducted an interview is a software architect named LiewSweeMeng is in the

midst of completing a degree in UPM Bachelor of Science (Mathematic/Computer Science),

master of Information Technology. He has 14 years of experience in Information Technology

career and as of now, he is working in F-Secure.

Why this Respondent was Chosen

Alan which is one of our group members, who finished his internship last semester in F-Secure,

knows Mr. Liew during his internship period. From Alan, we know that Mr. Liew has lots of

experience in component based software development and also the other software development

methodologies. Therefore, we chose to interview Mr. Liew after a deep consideration.

Goals for the Interview

Page | 2

Page 4: Halstead Calculator Doc Final

We had several specific goals in mind when we approached this interview. First of all, we wanted

to learn more about the processes during the component based software development. We think

that component based software development is a major breakthrough in software development as

the component can be reused, increase productivity and conquering complexity. Therefore, we

wanted to develop a deeper understanding of the mechanics that go into creating component.

Additionally, we wanted to expose ourselves into real working environment by meeting the real

software people rather than only study the textbooks.

Narrative of the Interview

The interview was conducted face to face on 28th of March from 12.30pm until 1.45pm, there were

totally 14 questions. At first, we were concerned that he might be too busy with his project.

Luckily, this was not the case. He answered our questions very promptly and clearly, which was a

relief. As the interview was done through face to face, we asked a lot of questions and anything

that we do not understand, he was willing to teach and share his experience with us. At the end of

the interview, we were thanking him for his time.

Impression of the Interview

Our impression from this interview was very positive. Not only did he answer our questions, but

his answers were also witty, insightful and clear. He also told us more about the component based

software development, which made us have a proper understanding about it. Before the interview,

we were worrying about the outcome of the interview. However, we were pleased with the

outcome of the interview and also the interviewee.

Impact on Our View of Component Based Software Development

From this interview, we know what is component and how does the component interact with each

other. Before this, we were so confusing how to differentiate OOP and COP. We could not get the

big picture of the component based software development. As Mr. Liew told us more and more

through the sample provided, we finally have a clear understanding about it. The main goals of

component based software development were conquering complexity, increase productivity and

reusability. Other than the benefits, we also know the difference between the life cycle of

component based software development and the life cycle of the traditional software development.

Page | 3

Page 5: Halstead Calculator Doc Final

For example, everything start from the scratch in traditional software development. However, we

can reuse the existing components in the market and then assemble them into a new application in

component based software development. Hence, this can increase the productivity and also reduce

the project life cycle significantly. In the end of the interview, Mr. Liew advices us to explore the

component application and this is an excellent advice as we would like to experience it through

practical.

Information that is still needed

We wish that we had been able to get more information about the component application of F-

Secure in the interview and the source code of the component. However, he was not very

convenient to tell us about that especially the source code of the component application that was

developed by his company as it was understandable that those components was not open source.

We found what we could get some source code through online, but we think it would have been

helpful to have a littlemore information.

Conclusion

Overall, we think the interview was very successful. We learned more about component based

software development that we are interested in, and we were able to explore the real working

environment in the field of professional software development. We hope we can use the

knowledge that we gain from this interview to complete our component application and also

provide a clear and better understanding of the component based software development to our

classmates.

Page | 4

Page 6: Halstead Calculator Doc Final

Chapter 1:Introduction of Component-Based Development

1.1 Introduction

This group project was held to give more understanding on component-oriented programming

(COP). Component oriented programming is a method of decomposing a problem into major

sections and each has a particular role or domain of responsibility in solving the problem.In this

group project, the concept on component-based development will be implemented by constructing

a Halstead Calculator application using existing components and comparing with non-component

based development.

1.2 Concepts and definitions

In this section, main concepts and definitions in the field of Component-Based Software

Development (CBSD) are introduced as below:

CBSD

Component-based software engineering (CBSE) is a process that emphasizes the design and

construction of computer-based systems using reusable software components. CBSE is changing

the way large software systems are developed. The main objectives of CBSE include reduction of

cost and time for building large and complicated system, improving the quality of the software and

ease the detection process of defect within the systems.

Component

Component is a piece of reusable unit of deployment and composition that has its own

functionality. A component is a building block that can be combined with other components in the

same or other computers in a distributed network to form an application. Examples of a component

include: a single button in a graphical user interface, a small interest calculator, an interface to a

database manager.

Interface

Interface is a subset of the Cartesian set of the power sets of properties, methods, and events, defines the communication parts of the component to the outside world.There are 2 kinds of interfaces:

Provided interface – one that provides certain functions for other components to utilise. Used interface – one that requires and uses functions as provided by other components.

Page | 5

Page 7: Halstead Calculator Doc Final

Connector

A connector is a first class architectural element that reflects the specific features of interactions

among components in a system. Connectors are channels for passing on the control to other

components.

Component Composition

Component composition is the integration of several components together to generate a new

component or application with composition operators defined in a component infrastructure. A

new and more complex component can be borned.

Component Model

A component model is a definition of standards for component implementation, documentation

and deployment. Examples of component models include Enterprise JavaBeans (EJB)

model, Component Object Model (COM) model, .NET model and Common Object Request

Broker Architecture (CORBA) component Model.

Composition Environment

Composition environment is a program that is used to construct an application out of deployable

components and it is usually accompanied by a component infrastructure (component framework).

Composition environment can be considered as places where all components is gathered,

connected and configured to become complete software.

Component Specification

A Component Specification is a generic description of a component. It defines its dependencies to

other components, what actions that can be performed on it and how those actions affect the

dependencies. It also defines what artifacts the component can export to other components.

1.3 Purpose or objective

To develop a Halstead Calculator GUI application using Netbeans IDE GUI Builder.

To understand Component-Based Software Development through development of Halstead

Calculator with the use of component framework and whiteboard component model.

To differentiate between Components based development fromthe traditional development

methodology.

Page | 6

Page 8: Halstead Calculator Doc Final

Chapter 2:NetBeans IDE GUI Builder Analysis

2.1 Introduction

Integrated Development Environment abbreviated as IDE, a programming environment integrated

into a software application that provides a GUI builder, a text or code editor, a compiler and

interpreter or debugger. Visual Studio, Delphi, JBuilder, FrontPage and DreamWeaver are all

examples of IDEs. The boundary between an integrated development environment and other parts

of the broader software development environment is not well-defined.

Support for alternative languages is often provided by plugins, allowing them to be installed on the

same IDE at the same time. For example, Eclipse and Netbeans have plugins for C/C++, Ada,

GNAT (for example AdaGIDE), Perl, Python, Ruby, and PHP, among other languages in use. For

this CBSE project, we are going to choose NetBeans IDE GUI Builder as our IDE builder to

construct an application that so-called Halstead Calculator application. Within this Chapter2, the

analysis of existing IDE builders will be described and also the reason of NetBeans IDE GUI

Builder chosen is given.

2.2 Analysis of Identified or Reviewed Component Builder Tools

No.

Tools Descriptions

1. Microsoft Visual Studio

If you are looking for the definitive IDE for Windows application

development, look no further than to Microsoft's own developer

toolset. Visual Studio products cover languages like C++, C# and

VB.NET. In addition, you are also able to develop for the

Windows x86, Windows RT, and Windows Phone. The latest

version of Visual Studio is also designed to be optimized for touch,

just in case you happen to be writing code on a Microsoft Surface.

Page | 7

Page 9: Halstead Calculator Doc Final

2. Oracle Netbeans If you are more of a Java developer, Oracle's got your back with

their Netbeans IDE. Of course, despite the fact that excellent Java

support is its claim to fame going as far back as the Sun

Microsystems days, other languages like C/C++, Ruby, HTML5,

PHP and more are supported as well. Netbeans is extremely

extensible via its plugin-centric design, allowing you to add

additional language syntax support and libraries, among other

things. Netbeans is free under theCommon Development and

Distribution License (CDDL) v1.0 and GNU General Public

License (GPL) v2.

3. Eclipse This IDE is quite comprehensive and even similar to Netbeans in a

variety of ways, including its use of Java and plugin architecture.

However, Eclipse as an IDE comes in a wild variety of flavors,

catering to various needs and objectives in software development

workflows. The Eclipse Foundation even provides a comparison

page to view the differences between the variants of Eclipse.

Eclipse is free under the terms and conditions of the Eclipse

Foundation Software User Agreement unless otherwise specified.

4. Code::Blocks Unlike the other products seen thus far, Code::Blocks, which is

built on the wxWidgets framework, is exceptionally lightweight in

size, yet still quite functional and feature-rich IDE. You can load

up a number of under-the-hood compiler engines, ranging from

GCC and LLVM, to Digital Mars and Open Watcom.

Code::Blocks also takes advantage of multi-core compiling,

allowing you to get the job done faster. Code::Blocks is distributed

under the GPL v3.0 license which means it can be used freely by

anyone.

5. Aptana Studio If web and scripting languages are more of your style, Aptana is

well suited for the task. PHP, Ruby on Rails, and Python are

supported as well as the likes of Adobe AIR. Even the studio itself

is available as a plugin for Eclipse if you prefer the way Aptana

Page | 8

Page 10: Halstead Calculator Doc Final

handles your work and want to combine it with a more

comprehensive IDE. Aptana Studio 3 is free and available solely

under the GNU General Public License.

Page | 9

Page 11: Halstead Calculator Doc Final

2.3 NetBeans IDE GUI Builder Scenarios (Conceptual Diagram)

Scenario Descriptions:

1. User imports components from repository.

2. Select the appropriate components needed for a specific application

3. Sometimes there is necessary to change a component and replace it with another one.

4. The selected components are being composed in case all the needed components are

available and no inconsistency exist among the components

5. Run the completed application to see the result of composition.

6. Save the completed application for future reuse.

Page | 10

Component RepositoryAvailable Components

Composition of selected components

Executable Application

Select

User

Run Save

Visualization

Coding

Runtime

Assembling

Change/Replace

Page 12: Halstead Calculator Doc Final

2.4 Use Case Diagram for NetBeans IDE GUI Builder

Use Case Actor Flow of Events

Add Components

Developer 1. In orderto add components to build an application in Netbean GUI Builder, developer has to create a Java container using the JFrame component and places the container in a new package.

2. Hence, the GUI form in the GUI Builder has been created by using the Netbean IDE.

3. A list of available components containing tabs for JFC/Swing, AWT, and JavaBeans components are shown in the palette section of GUI Builder provides.

4. Developer selects the desired component from the list by clicking and releasing the mouse button and then move the cursor to the form in the GUI Builder and clicks desired place within the form to place the chosen component in that location.

Remove Components

Developer 1. In order to remove component from the composed components in Netbean GUI Builder, developer click on

Page | 11

Page 13: Halstead Calculator Doc Final

the component chosen to be deleted within GUI form.2. Developer right clicks that particular component after the3. Component is targeted.4. Afterward right click the component and a “delete” option

will be available in the options list for developer to click.5. Developer clicks the “delete” option to remove that

particular component from the GUI form.

Compose Components

Developer 1. The use case begins when a developer desires to compose the components within the design form of GUI builder.

2. Developer aligns components within the design form to have a desired design structure.

3. Developer may add event interactions between the components (exp: jButton&jTextfield) by creating the events (exp: actionPerformed) and listeners handlers.

4. After all the adjustments are done, developer clicks “Save” button as the java file will automatically compiling when saved in NetBeans IDE.

5. The components within the form are considered composed together successfully after the compiling without errors.

Run Composed Application

Developer 1. In order to run the composed application to see the results, developer clicks the Preview Form button in the GUI Builder’s toolbar.

2. Byallowing developer to test it prior to building and running, the form opens in its own windowing. By the way developer has to makes sure there is no error that can be seen in the Output window at the bottom.

3. Developer clicks on the “Run Main Project” option from “Run” list at IDE toolbar and then clicks OK to accept the main class of the project.

Save Application

Developer 1. In order to save the application for distribution outside of the IDE, developer has to “Compile” and “Save” the main project.

2. Builds the application (Build > Build Main Project), the IDE automatically provides a copy of the library's JAR file in the application's dist/lib folder.

3. Afterward zips the project's dist. folder into a ZIP archive if want to prepare the GUI application for distribution outside of the IDE.

Page | 12

Page 14: Halstead Calculator Doc Final

Chapter 3: Halstead calculator Application using NetBeans IDE GUI Builder

3.1 Introduction

Halstead complexity measurement was developed to measure a program module's complexity

directly from source code, with emphasis on computational complexity. The measures were

developed by the late Maurice Halstead as a means of determining a quantitative measure of

complexity directly from the operators and operands in the module. They are strong indicators

of code complexity. Because they are applied to code, they are most often used as maintenance

metric.

3.2 Halstead Metrics Definitions

According to Halstead, a computer program is an implementation of an algorithm considered

to be a collection of tokens which can be classified as either operators or operands. For

example, a program can be thought of as a sequence of operators & their associated operands.

All Halstead’s metrics are functions of the counts of these tokens: By counting the tokens and

determining which are operators and operands, the following base measures can be collected:

n1: Number of distinct operators.

n2: Number of distinct operands.

N1: Total number of occurrences of operators.

N2: Total number of occurrences of operands.

In addition to the above, Halstead defines the following:

n1*: Number of potential operators.

n2*: Number of potential operands.

Halstead's metrics are all defined based on its set of base quantities

(n1, n2, N1, N2, n1* and n2*).

1. The vocabulary (n) of a program P is:

n = n1 + n2

2. The length (N) of a program P is:

N = N1 + N2

Page | 13

Page 15: Halstead Calculator Doc Final

3. The volume (V) of a program P is defined as:

a) A suitable measure for the size of any implementation of any algorithm

b) A count of the number of mental comparisons required to generate a program

V = N * log 2n

4. Programming effort (E) is defined as a measurement of the mental activity required to

reduce a preconceived algorithm to a program P. E is defined as the total number of

elementary mental discriminations required to generate a program:

E = VL =

n 1N 2N log2n

2 n2

5. The required programming time (T) for a program P of effort E is defined as:

T = ES =

n 1N 2N log2n

2n2 S

where S is the Stroud number, defined as the number of elementary discriminations

performed by the human brain per second. The S value for software scientists is set to 18.

The unit of measurement of T is the second.

Page | 14

Page 16: Halstead Calculator Doc Final

3.3 Program Justification using Halstead Metrics

A high Difficulty (D) result for an entire project offers the programmer justification for spending

more time on a project than another project of similar length or Volume (V). The Volume (V) for an

entire project is a better measure of project size than number of lines of code when trying to

determine how long it would take to read through and understand the project. When comparing

two programswhich accomplishing the same task, these metrics can be compared between

programs providing information for technical and non-technical managers. Volume

(V) andDifficulty (D) provide objective results respectively. However, they do not capture the

subjective manners in which two programs may differ.

The Volume (V) and Difficulty (D) per Function metrics are more valuable for embedded

programmers. A high Volume (V) may mean that a function should be split into smaller pieces. A

high Difficulty (D) indicates that a variety of different operations are performed and the purpose of

the function may need to be streamlined. These measurements work best when they are used to

quickly find problematic areas in a large code-base. It is the nature of some tasks that they lead to a

high Difficulty (D) or Volume (V), but softer rules like "All Volumes above 3000 must include

justification for their size in their comments" allow for this. (McCabe, 1996, 2.5 Limiting

Cyclomatic complexity to 10, para. 1)

Since all metrics are calculated when the project is finished the purpose of Time to Implement

(T) could be thought of as the time to re-implement, if the project needed to be rewritten in a

different language. Time to Implement (T) is the most controversial of Halstead's Metrics and

should be taken with a grain of salt. (Virtual Machinery, 2011, Halstead, para. 14)

3.4 Object Oriented Design

3.4.1 Component Diagram

Page | 15

Page 17: Halstead Calculator Doc Final

3.4.2Class Diagram

3.4.3Architecture Diagram

Page | 16

Page 18: Halstead Calculator Doc Final

Page | 17

Page 19: Halstead Calculator Doc Final

3.4.4Activity Diagram

3.5 User Interface Design

1) Figure 3.1 below shows the main page of the Halstead Calculator application.

Figure 3.1: Main page of Halstead Calculator application

Page | 18

Page 20: Halstead Calculator Doc Final

2) Upload a java fileby clicking on the button of Choose a file as shown in Figure 3.2.

Figure 3.2: Choose a file button

3) A file chooser window will be prompted and you are required to select a java which intended to be calculated.

Figure 3.3: File Chooser Window

4) Alternately, you can choose to upload a folder of java file which consist of a whole complete of program folder by clicking the Choose a folder button.

Figure 3.4: Choose a folderbutton

Page | 19

Page 21: Halstead Calculator Doc Final

5) A folder chooser window will be prompted and you are required to select a folder of program file which consists of more than one java file inside the folder.

Figure 3.5: Folder Chooser Window

6) Number of files which have been uploaded will be indicated on the main page of application as shown in Figure 3.6.

Figure 3.6: Uploaded files number

7) Click the Scan button to start the calculation of the uploaded java file.

Figure 3.7: Uploaded files number

8) The total Distinct Operators and Distinct Operands will be calculated and prompted to user.

Figure 3.8: Operators and Operands

Page | 20

Page 22: Halstead Calculator Doc Final

9) Click Calculate button in order to obtain the metrics of the uploaded java file.

Figure 3.9: Calculate button

10) Halstead metrics will be calculated and prompted to user.

Figure 3.10: Halstead Metrics

11) Click the reset button if you intendto perform anothermetrics calculation for another java file and clear the previous data.

Figure 3.11: Reset button

1)

Page | 21

Page 23: Halstead Calculator Doc Final

Chapter 4:Implementation of Application

4.1 Introduction

Implementation of application is the phase that comes after system design. Using a suitable

programming language, functionalities are converted into maintainable program code to satisfy

the requirements of the user. Testing is a process which is done during and after

implementation to ensure good quality of the system.

4.2 System Environment

This section explains about programming language used to develop NetBeans IDE along with

the programming environment used. The external libraries which are utilized are introduced.

At last, the standards which should be practiced by the components which are imported in

NetBeans IDE are explained and discussed.

4.3 Programming Language

NetBeans is a product of Oracle Corporation, which is written in Java programming language.

Oracle Corporation own and manage the many other Java technologies and tools.

4.4 Operating Environment

NetBeans IDE is a cross-platform (multi-platform) development tool/software that can be run

on any operating system (OS) as long as the Java virtual machine (JVM) is installed. This is

because the NetBeans IDE is built from Java language, which is a platform independent

language. When the Java code is compiled, a byte code is generated which independent of the

system. The Java byte codes can be run in any OS that with Java Runtime Environment (JRE).

4.5 Component Specification and Standard

Any composition tool for software components sets some standards for the components that

are going to be imported by that tool. NetBeans IDE is not an exception. Components which

are going to be composed by NetBeans IDE must follow these standards:

I. The type of connector in components is message passing. The type of message passing for

NetBeans IDE is indirect method calling. For this purpose, each component that uses other

components’ methods should have some setter methods to getter the values of the external

component variables. For example: “public void getDOperator() {…;}”. Similarly, a

component should have setter methods for other components to get the values from the

component.

Page | 22

Page 24: Halstead Calculator Doc Final

II. Each component must have an XML file with the same name as the component which

identifies the component’s specification. This XML file must be in the same directory that

the component is located. For example, below is an XML library definition for a Bean.jar

As for Java components that are used in this application, we follow the implementation using a

Java component model that is taught in class. The component model enables automated

component assembly. The component model is supported by component framework, which

usually a runtime program that wires the components deployed. In our case, we will be using

the publish and consume whiteboard query-based component models. The working mechanism

of the whiteboard component model is based on common communication space between

components that is provisioned at runtime. The components, which are unknown to one another

prior to the assembly, get to know about other components through the common

communication facility and choose a companion to compose with. The standards and

specification of the component are as below:

I. Each component providing service through a provided interface must declare the providing

object to be of a type ComponentInterface.

II. Each component providing service through a provided interface must be package into

correct .jar file.

4.6 System Implementation and Execution

Programming Language that is used in this project will be Java. All the interfaces for each of the components are specified in component interfaces. The application that requires service from a component will be communicating through a common interface. Functioning components that are used in this application have to implements the ComponentInterface before it can be used and included into the whiteboard component model.

There are total of 4 components used in this application:

1. The first component will be the JavaFileChooser. This component is used to handle file choosing and returning an object of the java file chosen by the user.

2. The second component will be JavaDirectoryChooser which allows user to choose a folder or directory, and the component will look for each and every files and subdirectory of the folder. Finally it will return a list of java files found by the component.

3. The third component is the JavaScanner. JavaScanner is used to scan through the syntax of a java file given, returning the 4 essential Halstead metrics needed by the application.

4. The last component will be the HalsteadCalculator. This component responsible to calculate the result based on the metrics given.

Page | 23

Page 25: Halstead Calculator Doc Final

Operating System that is used to development this application is Windows 8.0 and the application can be execution on any computer with Java installed. Once all the Jar packages are placed in the same directory, the application can be executed with the following command:

java -cp .;./* componentRunner.ComponentRunner halsteadcalcapp.halsteadcalcapp

4.7 System testing

Testing is conducted on the complete, integrated system to make sure the expected

requirements are satisfied. This level is considered as black-box approach of software testing.

- Test reference

Halstead Calculator application is tested to ensure the requirements which are

identified are met.

- Features tested

Halstead Calculator application is tested to make sure all the buttons shown are

functioning well and the result displayedis able to meet the desired output.

- Features not tested

Halstead Calculator is not tested for component inconsistencies. If the components

which are chosen for composition are from different component models, the tool

behaviours are unexpected.

- Test ease identifiers

Each test case is assigned an identifier. This identifier starts with “TC” which is the

abbreviation of test case followed by a “_” and a number.

- Test cases

The functional test cases for the main operations of Halstead Calculator are

describes below.

Test Case ID TC_1

Test Items Choosea java file from local directory

Input Java file

Expected Outcome A java file is chosen and inserted into application

Test Status Pass

Page | 24

Page 26: Halstead Calculator Doc Final

Test Case ID TC_2

Test Items Choose a folder consists of more than single java file

Input A file folder

Expected Outcome A folder of java files is inserted into application

Test Status Pass

Test Case ID TC_3

Test Items Click scanbutton to analyse the chosen java file

Input Scanbutton is clicked

Expected Outcome Distinct Operator, Distinct Operand, Total Operator and

Total Operand in the program are calculated and shown.

Test Status Pass

Test Case ID TC_4

Test Items Click calculatebutton to calculate the Halstead metrics

Input Calculatebutton is clicked

Expected Outcome All the fields of Halstead metrics are being calculated and

shown based on operators and operands.

Test Status Pass

Test Case ID TC_5

Page | 25

Page 27: Halstead Calculator Doc Final

Test Items Click resetbutton to clear previous record

Input Resetbutton is clicked

Expected Outcome All the fields in Halstead Calculator application is being

cleared and left blank.

Test Status Pass

Chapter 5: Comparison between Component Based and Traditional

Development Methodology

5.1 Comparison between Monolithic and Componentized

Monolithic Halstead Componentized Halstead

Total line of code : 526 Total line of code : 1229

Total line of code (without GUI) : 462

Total line of code in main application class (without GUI) : 160

Total number of class : 1 Total number of class : 12

Startup time : ~ 0.3s Startup time : ~ 0.4s

5.2 Advantages and Disadvantages

Advantages Traditional Development Less line of code Single monolithic file/executable Straight forward Very effective for small scale program

Disadvantages Traditional Development Not able to reuse any part of it without digging into code level Writing GUI structure, layout and styling without using tool consume a lot of

time, more ugly Messy, hard to read More bugs, less secured, variable more likely to be modifiable by functions that

should not modify it Implementing change consume a lot if time, degrades the code, introduce many

Page | 26

Page 28: Halstead Calculator Doc Final

more bugs

Advantages Component Based Development Increased maintainability Increased readability, operations are grouped into functions Cleaner and organized codes Replaceable parts Easily reusable Loose coupling No compile-time dependency, only run-time dependency Workload can be split Application can be developed & compiled partly and separately NetBeans GUI builder makes interface fast completed and well looking Make program more scalable Less bugs, better security, variables less likely to be modified by different

function/component

Disadvantages Component Based Development More lines of codes More files Consume a little more system resources

Appendix

Interview Questions and Answers

Selected Questions for Interview

1. What is your position in this company? How many years have you worked as a

developer? How many years you worked in this company?

I’m LiewSweeMeng, software architect in F-Secure. I have completed my degree

inBachelor of Science (maths/comp science) in UPM and I also completed master in IT. I

have14 years in this field and 3 years of working experience in this company.

Page | 27

Page 29: Halstead Calculator Doc Final

2. What do you know about component based development

For example, Eclipse, is a component based application, build with OSGi, plug in can be

built on top of OSGi, example like SVN, git. Not only plugins, Eclipse itself is component

based, being built by components working together with OSGi. Software Component can

be Plugin component or service component. Remote Procedural Call (RPC) is the oldest

component based technology. Existed before cobra, cobra also considered outdated now.

After cobra will be web-based component/service. Cobra is internal network (intranet)

based. Cobra is out mainly coz of its security issue. Now cobra is used only in old and huge

company where they employed the use of cobra and still have the system running until

now. Mid of 2000 until now – SOAP, xml based. Client/application request WSDL file

from the component/service provider that contained service detail (API/interface), then the

client will know what is provided and how to use it.Recent 5 year – REST (HTTP) + json,

URL based services.The masterpiece of our company, F-secure Internet security – plugins

is also used, use everything in COP OOP SP. Not every part of the application can use a

component; it is just as subsets of objects to publish certain services they offer.

3. In your personal opinion, which programming technique do you prefer?

Not necessary limited to only one of those SP, OOP, COP. Program codes can be partly

structured, and little bit OOP. Coz SP is simple, straight forwards; paradigm nowadays has

shifted back to SP again.

4. From your experience, do you think that COP has more advantages than OOP? Why?

Cannot be compared so generally. It is totally depends on the nature and need of the

application. CBSE can minimal the development with the use of services, libraries,

frameworks.

5. What are the problems that you met before in component-oriented development?

Security, even REST, security must be well defined to secure the service, like REST, need

to do some security on URl, if not ppl can access easily. Management of component

interfaces is troublesome, interface must not change in order for things to work. But to

come out with a good interface is not easy. Interfaces are likely to change if requirement

change or to tolerate other part of the system. Performance is important, to handle more

user load. Component might not able handle that, coz do not how it actually works. If

Page | 28

Page 30: Halstead Calculator Doc Final

provider change interface, time is also needed for applications that use the

service/component to change to adapt with the current interface.

6. What kind of software specification or situation that you will suggest COP?

Depends on the application pattern, depends on the modelling of the application. Hard to be

describe in words. In general, if existing component/service exist, then go for COP. Still

many other factors that contribute to the use of COP.

7. Do you use component concept in your projects development before? If Yes: Can you list

out some examples with what types of project? In which way does component concept

helps? What are the difficulties that you faced when developing using this concept?

Yes, example: authentication. Another example will be back end services, with most of it

are web based products, but not all. Less code to write, centralize program management

and have a standard way of writing code.Almost impossible to build an application with

only component assembling without extra work, only suitable for simple application. In

realistic, it is hard to archive, only part of the application will make use of services.

8. Do you think that using Component Oriented Programming will affect your competition

with other IT companies?

The use of COP will not, but the feature/services that the company provided will. Another

factor is timing, delivering the right product that matches the people’s need and favourite.

For example the current trend, towards cloud computing, flat UI design, mobile-first

services.

9. Did you ever develop a project using component from third party/off the shelf product?

Yes. There are 2 kind of components can be used in development which are component

service which is publicly available such as google twitter apis and private/paid component

service such as customer relationship management.

10. How do you select the components? Based on what criteria?

Page | 29

Page 31: Halstead Calculator Doc Final

Assessment – budget, API provided, security, performance, availability, future expansion,

tools provided by the component vendor or other party eg. tooling/library provided to easy

the connection.

11. Did your company develop reusable component so that every team can develop project

using it?

Sometime will, sometime not, totally depends on developers on how to do it. If they want

to contribute, they will go ahead. Otherwise they won’t do it. Usually internal components

that are being produced will be publicised to other member of the company through email

or info sharing session to let the rest of the company to know about it. The developers who

created the component themselves have to take initiative to do so.

12. How do you segmentise software system into software component? Is there any method

used to determine that?

There is no general way on how to do it, each depends on how easily to integrate, and the

API provided by the component/service.

13. Is software maintenance or bug fixing becomes easier when software system implement

COP?

For public free components – do report to the developers of the component, or contribute

ourselves if source code available (open source product), if not available, can self-write 1,

depends on the functionality, but usually the team will access it very clear before take the

use of the component, to reduce risk like bugs or failure caused by the component. For

Commercial paid component – contract the support team of the component vendor, and

wait for reply/solution for the component. Internal component – create feature request if

need new functionality of the component, and report bug to the maintenance team.

14. Could the size of project or organization affect the decision of approach used?

Now I would say no affect, but if for old time, OOP will be more preferable.

Page | 30

Page 32: Halstead Calculator Doc Final

Page | 31