Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [recommenders-dev] How to start with Recommender's source code

Hi Marcel,

I am happy to have a chance to work for Recommenders with you guys. I have a trial of SnipMatch, you said SnipMatch is developed by you guys, and now want to merge it into Recommenders, then release it in Eclipse 4.2, right?

I can not find much documents about SnipMatch, Here is my understanding of its structure (Correct me if i am wrong).
1. SnipMatch store many common code template in remote server side, in MySQL, MongoDB or etc.
2. Every user can create and store his own code template in SnipMatch, we call it personal code template. Each code template have code content and search label. In the demo:

Code template content:
${import(java.util.Random)}
Random generator = new Random();
int randomIndex = generator.nextInt(${int}+1);

Search Label:
generate a random number between 0 and $int

3. User login in Eclipse, print "Ctrl + Enter", if use input some search label, SnipMatch Eclipse client will search remote server ( both in common DB and user's personal DB) to get the corresponding code template content, replace parameter define, then paste these aim code into Eclipse editor.

This is how SnipMatch works, in my trial, SnipMatch works well, and it even has "an code template editor". If you want to merge it into Recommenders, i think it is easy. Now, you want to do some improvement job, right ?

Now i think my GSoC project will be:
1. User get code template search result, i should supply parameter replace module, and then paste the aim code in to Eclipse editor.
2. Add configuration module in Eclipse preferences for SnipMatch.
3. You words "local data storage". User can store his personal code templates in local environment, keep synchronous with remote server. Meanwhile, add an cache for his frequently used code templates or most popular code template in remote server into  local data store environment.

Am i right ? And some other things, see comments below :-)

2012/2/17 Marcel Bruch <marcel.bruch@xxxxxxxxx>
Hi Chen,

Recommenders is definitely an excellent project to get started with open source - and your help is welcome! 

Regarding GSOC projects:

We are currently working on 5 different areas:

* Intelligent Code Completion
* Extended Documentation
* Snipmatch Template completion
* Code Search, and 
* Stacktrace Search

For GSOC, my favorite project would be the refinement of IDE/UI integration of Snipmatch - our community driven code snippets store for Eclipse (see http://snipmatch.com/ for some demo videos). Snipmatch is about to move to Code Recommenders and as far as I can see a helping hand to make it ready for Eclipse Juno Release would be welcome.  Doug, what do you think? Wouldn't it be a great GSOC?

We've currently four students working on Snipmatch-related areas. Johannes Born and Johannes Dorn are working on different mining  strategies to automatically find code snippets from example code, Andreas Kaluza worked on sophisticated algorithms to merge templates with already existing code, and Jakob Eichler just started on an code template editor for Snipmatch to ease the creation of snippets in Eclipse. What's missing (Doug, correct me if I'm wrong) is someone who works on the completion engine itself and the surrounding parts like preferences, local data storage etc. etc. 

The only "problem" with this is, there there is some time pressure. We'd love to have Snipmatch ready for Eclipse Juno, which means that a significant amount of work needs to be done before the GSOC ends ;)

If my code can be released in Eclipse Juno, it will be a really happy thing for me and give me more power :-)

About the time pressure, it is OK, GSoC supplies a start point for my open source life, but the open source job and result is more important. If my GSoC project was accepted, it is ok for me to finish the whole things before GSoC's end to catch Eclipse Juno's release.
 


Regarding your test generation proposal. I like the idea much, but at the moment I think the team must focus on its existing core projects to make Code Recommenders a success for Eclipse 4.2 (Juno) release in June. There is still a lot work to do. Things might change after Juno and we investigate your test generation proposal more deeply. Sounds OK?

Yeah, if i integrate into Recommenders' community deeply, we can discuss the Unit test features in the future. CodePro AnalytiX's code analyse and unit test creation features are really amazing and very useful, but this project is not open source.  If Recommenders supplies features like this, it will be more powerful. I hope that way will come true in the future 
 

Let me know if joining the "Snipmatch venture" sounds interesting as GSOC.

Best,
Marcel



On 17.02.2012, at 04:01, chen cheng wrote:

Hi Marcel,

In my daily work, i used open source project much, and want to do some open source job. Recently, i found Recommenders is interesting and useful in my daily coding work. So i dream to become a committer of Recommenders if possible, working together with you guys. Meanwhile, I think unit test is important, if i can supply unit test auto-creation solution for Recommenders, it is a perfect solution.  Google Summer of Code [1] is a good start point for new open source participant like, this is why i post my GSoC idea here.


[1]  http://www.google-melange.com/gsoc/homepage/google/gsoc2012 

2012/2/17 Marcel Bruch <marcel.bruch@xxxxxxxxx>
Hi Cheng,

thanks for the detailed examples. Test case generation is indeed an interesting and useful topic for software developers. But I'm not sure how much can be achieved in three months. In addition there are tools out there that already do test case generation as Code Analytix Pro for instance (http://code.google.com/javadevtools/codepro/doc/features/junit/test_case_generation.html). There is also a lot of research work on test generation I'm not very familiar with (but know about their complexity at least).

So, I wonder whether your proposal wouldn't  be better positioned as extensions to existing tools that already have test case generation support?

I want to merge my aimed tool into Recommenders. If i build my proposal and my tool based on existing tools, just like Code Analytix Pro, it is Ok for me. But i do not want to be a lonely open source developer, if you guys think it is also a good solution to merge Code Analytix Pro based unit test tool into Recommenders, i will be very happy and start the solution survey and develop job soon.

So if Recommenders is ok for existing tools, i am ok for existing tools :-)
 

Despite that: are you interested in doing your GSOC in the scope of Eclipse.org even if it's not exactly this topic? I can imagine that you have a bunch of other ideas on how to improve a developer's day-to-day live, right? ;)

Yeah, i just want to find a good start to be a open source community member. As i am familiar with Eclipse plugin development, so doing GSoC for sub project of Eclipse.org may be the best choice, just like Recommenders. If this idea is not good enough, i will try to find another, or if you guys have some existing demand to do, i can also try to join it, try to find solution. 
 

Best,
Marcel



On 16.02.2012, at 15:47, chen cheng wrote:

Hi Marcel,

Class object simulate is just a small part of my idea, we can use mocking frameworks such as mockito to help us do some object simulate job, but that is not all. This tool is committed to create all necessary unit test code for a special method or a class with multiple methods. It helps saving our time, create unit test code for us intelligently.

For example, we have such a simple method which was used to math operations:

public static double operate(String ope, double numOne, double numTwo){
if(ope.equals("sum"))
return numOne + numTwo;
else if(ope.equals("min"))
return numOne - numTwo;
else if(ope.equals("mul"))
return numOne * numTwo;
else if(ope.equals("div")){
if(numTwo != 0)
return numOne / numTwo;
}
return Double.MIN_VALUE;
}

Now, we use this tool to create unit test code for this method, it will work like this:
This method has three parameters: ope, numOne and numTwo.

"ope" was compared four times in the method:
ope.equals("sum"), ope.equals("min"), (ope.equals("mul") and ope.equals("div").
So "ope" in test cases will cover at least this four values "sum", "min", "mul" and "div", and some other generated  strings by *String Generate Alogirthm* (NOTICE: user can specify regular _expression_ to generate string values).

"numTwo" was compared one time in the method:
numTwo != 0
So "numTwo" in test cases will cover at least 0 and some other generated numbers.

And we can not find "numOne" detail compare statement, so we just generate by a *Integer Generate Algorithm*

About return value, user must special the *CORRECT* value for each test case manually. Now we get at least these five test cases (user can specify test cases' number, so we should have more, i just list five here to explain how this tool works):
@Test
public void test1() {
String operate = "sum";
assertTrue(hello.operate(operate, 24, 5) == input_ret);
}
@Test
public void test2() {
String operate = "min";
assertTrue(hello.operate(operate, 23, 0) ==  input_ret );
}
@Test
public void test3() {
String operate = "mul";
assertTrue(hello.operate(operate, 2, 0) ==  input_ret );
}
@Test
public void test4() {
String operate = "div";
assertTrue(hello.operate(operate, 1, 2) ==  input_ret );
}

        @Test
public void test5() {
String operate = "ranstr";
assertTrue(hello.operate(operate, 1, 2) == 0.5);
}
As this method's return statement is *double*, so decide to use assertTrue to compare the return value with user specified correct value.

Now, let's see a more complex method:
public static String operate(HttpServletRequest request, HttpServletResponse response){
String ope = request.getParameter("operate");
int numOne = 0;
int numTwo = 0;
try{
numOne = Integer.parseInt(request.getParameter("num1"));
numTwo = Integer.parseInt(request.getParameter("num2"));
}catch(Exception e){
return "bad parameter";
}
if(ope != null && !ope.trim().isEmpty()){
if(ope.trim().equals("sum"))
return String.valueOf(numOne + numTwo);
else if(ope.trim().equals("min"))
return String.valueOf(numOne - numTwo);
else if(ope.trim().equals("mul"))
return String.valueOf(numOne * numTwo);
else if(ope.trim().equals("div"))
return String.valueOf(numOne / numTwo);
}
return "bad parameter";
}

Do not like String,Integer,Double,Float, Boolean etc, HttpServletRequest  and HttpServletReponse are complex data type, we must use mockito to build parameter instances. We can get test case like this:
@Test
public void test() {
HttpServletRequest request = mock(HttpServletRequest.class);
when(request.getParameter("operate")).thenReturn("sum");
when(request.getParameter("num1")).thenReturn("1");
when(request.getParameter("num2")).thenReturn("2");
HttpServletResponse response = mock(HttpServletResponse.class);
assertEquals(hello.operate(request, response), "correct_value_specified_by_user");

We use *mock* function to build HttpServletRequest and HttpServletResponse instance, as aimed test method invoke  request.getParameter three times(request.getParameter("operate"), request.getParameter("num1") and request.getParameter("num2")) to get different parameter value, we use when(...).thenReturn(...) to simulate request, and use assertEquals to compare String return statement with user specified correct value.


This is just *MY PRELIMINARY IDEA*, i hope we can know what i mean. If you guys are interested, i will start the detailed project proposal prepare job soon :-)

2012/2/16 Marcel Bruch <bruch@xxxxxxxxxxxxxxxxxx>
Hi Chen,

good to know it works for you. I think, we should clean up the repository a bit more to reduce confusion. It's on my todo list now

On 16.02.2012, at 10:07, chen cheng wrote:

If we want to write unit test for it, we must build an special HttpServletRequest object for each test case, it will cost us much time. If Recommenders can help us to create unit test file, test cases and build parameter Class object. It is really cool,practical and useful, save time, save money.

How do you think ? Thank you :-)

Sounds interesting. Can you give more details on what exactly you'd like to create? A few examples explaining what you have in mind (maybe using the HttpServletRequest example) would be great. Another aspect: how would this relate to mocking frameworks such as mockito where you create simple mocks using Mockito.mock(class)?

Best,
Marcel

_______________________________________________
recommenders-dev mailing list
recommenders-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/recommenders-dev




--
Best Regards From Cheng Chen [chengchendoc@xxxxxxxxx]
_______________________________________________
recommenders-dev mailing list
recommenders-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/recommenders-dev


_______________________________________________
recommenders-dev mailing list
recommenders-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/recommenders-dev




--
Best Regards From Cheng Chen [chengchendoc@xxxxxxxxx]
_______________________________________________
recommenders-dev mailing list
recommenders-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/recommenders-dev


_______________________________________________
recommenders-dev mailing list
recommenders-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/recommenders-dev




--
Best Regards From Cheng Chen [chengchendoc@xxxxxxxxx]

Back to the top