Calculate several metrics based on the compiled code

Assignment Help Software Engineering
Reference no: EM131472872

Assignment

Write a program to read one or more Java.class files, provided via command-line parameters, and calculate several metrics based on the compiled code.

Metrics

Your program must calculate the following metrics:

1. For each class: Lack of cohesion in methods 4 (LCOM4).
- This metric must be calculated for each class provided.
- For this purpose do not include constructors, toString() or equals() meth- ods.
- You should disregard all toString() or equals() methods, regardless of pa- rameters, not just those from Object.
- Do not calculate LCOM4 for interfaces.

2. For all classes: Coupling between object classes (CBO). CBO should be calculated based on the provided classes, to do this you will need to parse the code attributes, the constant pool itself will not provide the correct information

Input Data

Your program must accept the class filenames as command-line parameters (not via con- sole input). Each class filename may simply be "ClassName.class".

It may also have a path component; e.g., "dir/ClassName.class" or "/usr/local/ClassName.class" or "../../tmp/ClassName.class", etc.
Your code is required to work with .class files of version 51.0, corresponding to Java

7. You can handle other versions at your discretion. You should not try to parse the complete class file for a version you are not handling. You should produce an adequate error message and your README/report should detail which versions you are handling.

Error Handling

You MAY NOT assume that ANY input data (including the contents of the class files themselves) is valid! Your code must gracefully handle ALL potential errors relating to input data.
Specifically, your program must handle errors as follows:
- Give the user a helpful error message; and
- If possible, proceed with whatever input data is valid. Do not abort the program except as a last resort. (For instance, if a parsing error occurs in part of one class file, everything up to that point may still be usable. You should be able to attempt the remaining class files too.)

Output

You program must produce both a terminal and text file output as follows
- Terminal: a summary of each class's LCOM4, and the overall CBO
- Class names should be fully translated. i.e.: public, final, extends etc. . .
- Method names should be fully translated. i.e.: flags, return and parameter types.
- File: a Graphviz/Neato compatible file specifying the graphical representation of each class's LCOM4 diagram and the CBO diagram for all classes (wikipediapro- vides a basic introduction to the format required. See the documentation for more detail.)
- Classes may be represented by just their names.
- Method names may be abbreviated, only the name and parameters are required (in order to distinguish between overloaded methods).
- LCOM4 graphs should distinguish between class fields and methods.
- You DO NOT need to specify formatting information for the graphs, the syntax and core information will suffice.

Output Format

The output must be understandable to a user with no knowledge of the Java class file format (but still with knowledge of the Java language itself).
Specifically, adhere to the following when outputting information:
- Use indentation to make it easy to see which methods belong to which class.

- Constructors and static initialisers must be identified as such.
- Always show parameter types for methods and constructors, and return types for methods. Show types in a Java form, not a JVM form (e.g. "int" rather than "I"). You may keep or discard package names (e.g. "java.lang.") at your discretion.
- Avoid outputting unnecessary information (such as the constant pool entries).

Coding

You may optionally make use of the already-partially-implemented ClassFileParser pro- gram (available on Blackboard). You will have to decide how best to adapt it for your purposes.
You may write your code in any language, provided you can demonstrate it working on the Linux lab machines in building 314. ClassFileParser itself is written in Java.

Testing and Code Quality

To ensure your code is of high quality:
(a) Develop test cases to check all required functionality. Your tests must cover a broad range of situations, including boundary cases, complex cases and real-world cases. Obviously, your application should pass the tests!
For each test case, you must of course manually determine the expected metric results, to determine whether your code passes or fails the test. For this purpose, you may use the javap tool to see the JVM instructions, or simply calculate the metrics based on the source code. Remember that JVM can add things in.
Real-world test cases should involve typical (or better still, very complex) Java classes from open-source Java applications. For instance, you might consider classes from NetBeans, or from java.awt.swing, etc.
(b) Use RSM, PMD, or another tool approved by the lecturer to find and fix readabil- ity/maintainability issues. You may decide that some issues do not require fixing, but if so you must justify your decision.

Report

Prepare a report that includes the following (must be in .pdf format):
Compiling and Running: Briefly explain how to compile and run your code from the command-line on one of the Linux lab machines in building 314. If you have used Java, this may be as simple as:

[user@pc]? cd MySourceCodeDirectory [user@pc]? javac *.java
[user@pc]? java MyAmazingApplication filenames ...
However, if it's more complicated for any reason, please let the marker know! This should also be included in an appropriate README file.
Functionality: State which functionality you have successfully implemented, to the best of your knowledge.

Design: Explain your design:

(a)structurally, describing each class you have developed or modified, and (b)algorithmically, describing (in high level terms) the significant steps in your code and any important data structures it uses.

Testing: Describe your test cases, justify how you designed them, how you computed the expected values, and provide the actual results of your testing. Describe any bugs you are aware of.

Quality: State any code quality issues raised by RSM, PMD or the relevant tool used, and give your response to each.

Referencing: State precisely which code is yours and which isn't. Of the source files that make up your application, state precisely:

(a)which files are entirely your work,

(b)which pre-existing files are entirely unmodified (if any), and (c)which pre-existing files you modified (if any), where, and how.
As before (in Assignment 1), your report should:
- Have normal spacing and a sensible layout.
- Be logically structured, using headings where appropriate.
- Use good English, with proper spelling and grammar.
- Comprehensively demonstrate that you know what you are doing!

Submission

Submit the following electronically to the Assignment 2 area on Blackboard:
- A completed Declaration of Originality;
- The complete source code for your application, including any pre-existing code you use (so that the marker can easily compile and run your application);
- The complete source code for your test cases;
- Your report (in .pdf format);
- The output from RSM or PMD (or the relevant equivalent tool) in a single file called quality.txt, quality.html or quality.zip (if there are multiple files).

Attachment:- ClassFile.rar

Verified Expert

When we have a low cohesion means that we have a bad design, with classes that are very complex. This can also indicates that the classes are complex, very big and can produce a lot of bugs. When we have a high cohesion that we have a very good encapsulation, each class do only one thing but it does very good. Normally, these classes are not very long, the complexity of them is not very high and is simple to understand and work with. A connected component is a set of method that are related at class level The LCOM for is the one it seems to be the accurate. LOCM provide to improve accuracy of design and also help to overcome problem from bad design. In this assignment we calculate degree of LOCM.

Reference no: EM131472872

Questions Cloud

Describe briefly how the sdf approach can be implemented : The SDF approach discussed in this chapter can be used for evaluating the performance of mutual and hedge funds. Describe briefly how the SDF approach.
Alongside general services managers : Financial managers may work alongside general services managers to address certain measures of liquidity.
Define the prediction error : Kahneman and Tversky (1973) postulate that the concept of representativeness explains why people are prone to underestimate regression to the mean.
Describe why it is important to use a tool like ms project : Describe why it is important to use a tool like MS Project instead of using other tools (e.g., MS Word, MS Excel) to manage and track your schedule.
Calculate several metrics based on the compiled code : Compiling and Running: Briefly explain how to compile and run your code from the command-line on one of the Linux lab machines in building 314
Discuss some of the pitfalls in the empirical analysis : Despite the recent developments in asset pricing theory and practice, many statistical problems can still potentially compromise some of the empirical findings.
Which of the given is an extreme programming advantage : Which of the following is an eXtreme Programming advantage? According to the agile software development manifesto, the 17 anarchists came to value.
Reputable and popular sweater manufacturer : K.K. Legume, Incorporated is a reputable and popular sweater manufacturer. Does Arrow have an ethical obligation to pay a higher price,
Chech the given case was that legal : Armond wrote a check payable to Gaston. Gaston negotiated this check to Wright using a blank indorsement. Fearing that she would lose the check.

Reviews

inf1472872

5/15/2017 5:17:58 AM

Now give the path of class file in lcom and CBO. java file after giving the path of class file you can run lcom and CBO java file you will get output. how to give the path of class file in lcom and CBO.java file? No after give the path of class file you can run lcom and CBO java file you will get output you mean by running javac LCOM.java and javac CBO.java and then run these files as java LCOM and java CBO yes i did that, but it shows me an error that the class LCOM does not have a main method use NetBeans create new project in NetBeans and add all lcom,cbo and entity .java file in it then right click on lcom file and then choose option run file it make easy to you run application. but i have to use unix machine, not on any IDE Ok then please use dos, use command java filename.java that does not work. I did javac LCOM.java and then to run i did java LCOM. but does not work Kindly First change the directory of command prompt and then run it I am in the correct directory Run this command >Javac LCOM.Java After run another Command >appletviewer LCOM.java You can see output screen

inf1472872

5/15/2017 5:17:49 AM

I have put all comment need for understand code and also has provided instruction.txt file which is class file Hi, could you please provide instructions for how to compile these programs. Do i have to do javap -c instruction.class? I do not have instruction.class file You have to first compile instruction.java from command prompt using javac command file then .class will be created Then to decompile .class file use javap command Okay, so could you send me Instruction.java? Or do I just need instruction.class? I have already send instruction.class file ,Could you please check once again. Instruction.java file is sufficient You have only sent the Instruction.class but not Instruction.java okay so after i decompile the class using javap -c Instruction.class, then what do i do?

inf1472872

5/15/2017 5:17:29 AM

Also could you please produce CBO diagram/graph as mentioned in the specification. CBO graph can't bcoz in lecture note also not given they had only calculation. but if you read the assignment specification, it says you have to output CBO in a graph and also terminal. Please see the assignment specification. Lecture notes is just for additional information on how it is calculated. Ok but I need time to do for graph I will send you soon please send me sample CBO graph here is a sample CBO output. Note: this is not related to the lecture notes. Its just a random sample. 22991976_1CBO.pdf Also send solution of coding with plenty of comments so client can understand. Please kindly find the attachment of CBO and LCOM graph with full screen. Now you can see LCOM graph with all attribute. I have solve screen problem and generate graph for CBO. Could you please provide comments on the source code so client understands what is going on. And could you please provide Instruction.txt

inf1472872

5/15/2017 5:16:44 AM

CBO has to be calculated by parsing the code attributes, see the assignment specification. and also LCOM value is not printed on the terminal, and also not shown in the graphical output. It just prints graphs, thats it. Additionally, please provide comments on source code so that can understand. From the graph output, from my point of view the LCOM should be 5. The testfile you are using is Instruction.java? Please find the attachment below, to show you exactly what LCOM and CBO output should be. 22991978_1Author.pdf 22991926_2CBO.pdf 22991983_3Charming.pdf I have checked it you are correct but LCOM is 10 because in graph window you can see on five graphs and other 5 you can't because java applete windows does not allow to scroll it only to scroll on web with applet. So if thats the case? how can I test a class that has LCOM of more than 5? The final result should show all the graphs. Ok you can try to resize screen if possible we have to change code for graph to see all graph. yes, because for testing and code quality purposes. I will have to test and cover wide range of test cases. Also please provide comments on source code so I can understand.

inf1472872

5/15/2017 5:16:23 AM

Please read the documentation: SM 207s1 Assignment2.pdf. It specifies the requirements of the assignment. The other .java files, are the existing code written by lecturer, if you read the specification. It says you may use these existing code, or create a new code to do the assignment. But so far the teacher has given that This is the requirement of the assignment 22991986_1SM 207s1 Assignment2.pdf I can also provide you lecture notes, in order to make you understand. 22991935_1SM Lecture03 StaticCodeMetrics.pdf 22991935_2SM Lecture05 CompiledCode.pdf please provide enough comments, description of the code, and how to compile the program. Also the program has to output the LCOM4 value on the terminal as well as in a file (outputting graphic representation). okay, but the LCOM value should also be printed in the terminal. Not just in terms of graph. But also value in the terminal. and what about the CBO?

inf1472872

5/15/2017 5:16:07 AM

These are the existing files for parsing 22991941_1ClassFileParserException.java 22991941_2ConstantPool.java 22991941_3CPEntry.java More files 22991971_1Instruction.java 22991971_2Opcode.java I will make the payment soon. Make sure you read the specification very very carefully. Also make sure, there is no plagiarism Could you please go lower in price wise? Your response will be highly appreciated. There you go. Thats all the existing source codes. 22991950_1ClassFileParser 2014-04-30.zip Make sure, no netbeans is used. Should be fully compiled in UNIX machine. No IDE's or netbeans to be used please.

Write a Review

Software Engineering Questions & Answers

  Dialog diagram for web-based system for airline

Describe each section of the dialogue box. Imagine, you are developing a web-based system for an airline. Sketch the dialog diagram for some sample screens that users will need to navigate through.

  Create a word document listing the software

Create a Word document listing the software you have found, a brief description of the functionality of the software and the URLs of the Web sites from which they can be downloaded.

  Describe two major erp systems

Create a 7-to10-slide presentation comparing and contrasting two major ERP systems from different ERP software providers. You may use various sources including the companies' websites

  Use vdm method to specify an automated transaction machine

CSCI410/CSCI910 - Software Engineering Formal Methods - Use VDM method to specify an automated transaction machine

  What would you look for in a company software system

Identify and explain reasons why you think that companies using a management systems approach might be in a position to perform better than competing companies. What would you look for in a company software system to support your ESH endeavors and ..

  A determine what variables explain likelihood of passing

a determine what variables explain likelihood of passing to each stage of funneli inquire for information ii attend

  How could core erp components aid improve business operation

How could core ERP components aid improve business operations at college? How could extended ERP components aid improve business operations at the college.

  Describe how genetic algorithms might be used

Describe how genetic algorithms might be used in the development and production of a new product that is a complex system, such as a self-driving car.

  Create a hierarchy chart depicting the chosen situation

Sending an e-mail to the student's teacher via the system on questions regarding the student's grades.

  Object oriented designing class

Object oriented design is making classes with both characteristics and behavior wrapped together. Taking data and the functions that operate on that information and storing them as one programming unit is extremely powerful.

  Formal programming languages and natural languages

As we know that there are problems of understanding natural languages as opposed to formal programming languages. As an illustration of the complexities involved in the case of natural languages,.

  The environment and the strategic business plan

1.What is the relationship between the environment and the strategic business plan? 2.What is the relationship between the firm's resources and the strategic business plan?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd