首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
代做data程序、代写Java程序设计
项目预算:
开发周期:
发布时间:
要求地区:
MP2: Design Patterns
1 Introduction
Since you are now familiar with the Jsoup project (at least you know how to build it ¨⌣), let’s
practice program analysis on the Jsoup project!
Imagine you are a software engineer working on a large project, there will be various programming
tasks you need to daily perform, including understanding existing code, modifying existing code, and
of course produce new code. As a graduate student in CS, you probably are already very good at such
tasks as you have learnt such skills from various courses. Meanwhile, other courses mainly teach you
how to automate various tasks in our daily life (such as financial services, transportation, healthcare,
and more) via programming, and you still have to manually perform those programming tasks. In
contrast, with program analysis, you can further automate programming tasks themselves!
2 Instructions
JavaParser (https://javaparser.org/) is a widely used analysis engine for Java programs. It
can transform any Java source code snippet into its abstract syntax tree (AST) form. Then, we can
build programs to traverse the ASTs to perform various code parsing, manipulation, and generation
tasks at the AST level. Note that JavaParser is largely built based on the Visitor design pattern
(https://en.wikipedia.org/wiki/Visitor_pattern). Here are also some useful links for getting
started with JavaParser:
• https://javaparser.org/: JavaParser homepage with various useful resources, including blogs
on how to use JavaParser in various ways.
• https://javadoc.io/doc/com.github.javaparser/javaparser-core/latest/index.html: JavaDoc
information for all JavaParser APIs.
• https://gitter.im/javaparser/home: the gitter channel for JavaParser, where you can ask
questions and search previously solved questions.
• https://tomassetti.me/wp-content/uploads/2017/12/JavaParser-JUG-Milano.pdf: a tutorial about JavaParser.
To simulate real-world software development, in this homework, you are expected to get familiar with the popular JavaParser analysis engine by yourself, and perform the following three tasks.
To simplify the implementation and auto-grading, you will revise an existing template Maven-based
project. You can download the template project using the command below:
git clone https://github.com/uiuc-cs427-f23/cs427-hw2
Note that the template project already includes the dependency of a popular JavaParser version
on Maven Central Repo. Furthermore, all the source code for Jsoup (which will be used as the
input data) has also already been included as test resources, which will be automatically copied into
target/test-classes directory during mvn test. Therefore, you do not need to install or change
anything for the project, except adding your implementation to the locations with “TODO” comments
(details will be shown in the later task description).
Your implementation should be able to pass all JUnit tests included in the edu.illinois.cs.analysis
package of the template project. You can run tests via mvn test command or through the IDE.
If you execute the tests through the command line, you can look at the generated Surefire report
(target/surefire-reports) for the details about your test failure(s), if any. Note that at the beginning, all the tests will fail, as the code is incomplete and cannot produce the expected results.
1
2.1 Task 1: Parsing existing code
Assuming you are working on the Jsoup project, and one day your manager asks you to compute
some statistics (such as the number of classes or methods) of the project. Of course, you have multiple
options even without knowing the concept of program analysis:
• Just do it manually. However, this will cost you forever in case of huge projects.
• Write some simple scripts based on string processing. It also works, but will take you a tremendous amount of time to consider all corner cases.
• Try to find some existing tools. Depending on the specific statistics, you may not find an ideal
tool that can compute all statistics.
In this task, you are expected to compute the number of methods satisfying ALL of the following
conditions within a java file based on the JavaParser program analysis tool:
• The method has actual body declaration (i.e., for method declaration n: n.getBody().isPresent()
should be true).
• The method has at least one input parameter.
• The method is public.
• The method is not static.
• The method has a return type, i.e., not void.
More specifically, you are expected to complete the TODO portions in the edu.illinois.cs.analysis.CodeParser
class so that it can automatically compute the precise number of methods. By default, it only computes the total number of methods within a file. When you are done with this task, make sure your
implementation passes all JUnit tests included in the edu.illinois.cs.analysis.CodeParserTest
class of the template project.
When you are done with the task, please also take a moment to think about the benefits of using
such a program analysis engine compared with all the other three ways for completing the same task.
It could save you even more time for a more complicated or specialized code-parsing task!
2.2 Task 2: Modifying existing code
Another day, your manager asks you to find all instances of null checks in any given Java file, and
then switch the operands for all found null checks (what a weird request! ¨⌣). Note that you shall
consider ANY binary expression that:
• includes null as an operand (either left or right side), and
• includes == or != as the operator.
You are expected to complete the TODO portions in the edu.illinois.cs.analysis.CodeModifier
class so that it can automatically make the change. When you are done with this task, make sure your
implementation passes all JUnit tests included in the edu.illinois.cs.analysis.CodeModifierTest
class of the template project.
2.3 Task 3: Generating new code
Yet another day, your manager comes and asks you to build a program that can automatically
generate the following method and add it to any given class:
2
@Override
public String toString() {
String str = super.toString();
int len=str.length();
if (len > 40)
return "OMITTED";
else
return str;
}
The reason for the change is that the original toString method (e.g., inherited from class Object)
may return very long string and cram the hard drive with large chunk of such log data. The new
toString method simply return “OMITTED” for any class with string representation longer than 40. In
this way, the space issue can be mitigated. You can assume that the given Java file does not include
toString declarations before your change (so you can directly add it without any check). You also do
not need to worry about the precision issue caused by the string omission.
You are expected to complete the TODO portions in the edu.illinois.cs.analysis.CodeGenerator
class so that it can automatically add the desired code for the given class. To help with your implementation, we have included partial implementation. Furthermore, we have also included the AST
tree information for the body of added method; you may find it helpful to follow this tree structure
to construct the corresponding code structure. You can also create the AST tree yourself by running the main method from class edu.illinois.cs.analysis.CodeGenerator. The execution will
dump a file named ast.dot in the root directory of this template project. You can simply copy the
file content and display it using any GraphViz software (e.g., you can also use the online version:
https://dreampuf.github.io/GraphvizOnline).
Figure 1: AST of the code to be generated
3 Deliverables
You are expected to upload a zip file including only the CodeParser.java, CodeModifier.java,
and CodeGenerator.java files you completed (no folders please). The name of the zip file should be
your NetID.
Warning: you may lose all your points if you violate the following rules:
• Please make sure that your zip file is named with your NetID and only includes the three specified
files: DO NOT include any folders in the zip file, and DO NOT change anything (including names) of the three files except the TODO parts.
• Please DO NOT use any absolute paths in your solution since your absolute paths will not
match our grading machines. Also, please only use “/” as the file separator in your relative
paths (if needed for this MP) since Java will usually make the correct conversions if you use the
Unix file separator “/” in relative paths (for both Windows and Unix-style systems).
3
• Please DO NOT fork any assignment repo from our GitHub organization or share your
solution online.
4 Grading rubric
The autograder will run tests on your submitted code and your final score for this MP will be based
on the success rate of test execution (including the 5 provided tests plus 5 hidden tests). The overall
score is 5pt:
• In general, your score will be proportional to the total pass rate, e.g., if you pass 8 out of the 10
tests, you will receive 4pt.
• However, we may manually check the actual code for some sampled solutions (those with more
hidden tests failing will get a higher chance to be sampled), and your score can be proportional
to your test pass rate or (very likely) lower.
4
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
urba6006代写、java/c++编程语...
2024-12-26
代做program、代写python编程语...
2024-12-26
代写dts207tc、sql编程语言代做
2024-12-25
cs209a代做、java程序设计代写
2024-12-25
cs305程序代做、代写python程序...
2024-12-25
代写csc1001、代做python设计程...
2024-12-24
代写practice test preparatio...
2024-12-24
代写bre2031 – environmental...
2024-12-24
代写ece5550: applied kalman ...
2024-12-24
代做conmgnt 7049 – measurem...
2024-12-24
代写ece3700j introduction to...
2024-12-24
代做adad9311 designing the e...
2024-12-24
代做comp5618 - applied cyber...
2024-12-24
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!