Ever consider Project Lombok?

Discuss issues related to PS3 Media Server development (only for programmers)

Ever consider Project Lombok?

Postby TheLQ » Tue Jul 17, 2012 7:08 pm

As I'm starting to learn PMS's API more and look at more code I'm noticing a few POJO's. One thing that I think might be helpful is Project Lombok ( http://projectlombok.org/ ). This allows you to specify getters, setters, tostring, hascode, etc with just an annotation. This does help reduce code clutter since you don't have a wall of getters and setters between major parts of your code. You could also start to phase out calling fields by their direct field names, which is generally bad practice.

If nobody wants to implement it I would be willing to help out when I finish my VLC project. Once again though I'm simply wondering if PMS devs are open to the idea.
TheLQ
 
Posts: 16
Joined: Wed Jul 11, 2012 6:18 pm

Re: Ever consider Project Lombok?

Postby chocolateboy » Tue Jul 17, 2012 7:19 pm

TheLQ wrote:This allows you to specify getters, setters, tostring, hascode, etc with just an annotation.


These are trivial to generate with an IDE. There are many things that should be improved in PMS. I wouldn't say this is one of them.
chocolateboy
Project Member
 
Posts: 2577
Joined: Wed Sep 16, 2009 10:05 am

Re: Ever consider Project Lombok?

Postby TheLQ » Tue Jul 17, 2012 7:25 pm

chocolateboy wrote:
TheLQ wrote:This allows you to specify getters, setters, tostring, hascode, etc with just an annotation.


These are trivial to generate with an IDE. There are many things that should be improved in PMS. I wouldn't say this is one of them.


Its an improvement though with little to no effort. See http://projectlombok.org/features/Data.html for example. I just mainly use it to reduce code clutter. 100 lines of getters and setters tends to bury real code
TheLQ
 
Posts: 16
Joined: Wed Jul 11, 2012 6:18 pm

Re: Ever consider Project Lombok?

Postby chocolateboy » Tue Jul 17, 2012 7:33 pm

I've seen it before (albeit many years ago and not in connection with PMS). IIRC, the main issue was debugging - which its code generation made much harder. Has that been solved?

More importantly, I'd rather have verbose and idiotic :-) Java code that spells things out than magical Java code that doesn't. The lack of "cleverness" is precisely what makes it so easy to understand and hack on.
chocolateboy
Project Member
 
Posts: 2577
Joined: Wed Sep 16, 2009 10:05 am

Re: Ever consider Project Lombok?

Postby taconaut » Tue Jul 17, 2012 7:42 pm

I like the idea.
Coming from c# that's one of the things I've never liked with java. Declaring a simple public property with getter and stter resumes to this
Code: Select all
public int MyNumber { get; set; }
If you always wanted to have your most recent videos at the top of the folder in the ps3 or wished you could group all videos with the same genre in one folder, have a look at pms-mlx
taconaut
Project Member
 
Posts: 1059
Joined: Sat Apr 11, 2009 12:29 am
Location: Switzerland

Re: Ever consider Project Lombok?

Postby Raptor399 » Tue Jul 17, 2012 8:03 pm

I feel old; I can't read the Lombok code. :oops:

The old code may be bulky, but it spells it all out and I don't have to be aware of what magic the annotations invoke under water (it may be gone from sight, but it still is there).
Raptor399
Project Member
 
Posts: 1916
Joined: Thu Mar 10, 2011 12:06 am

Re: Ever consider Project Lombok?

Postby TheLQ » Tue Jul 17, 2012 9:03 pm

In all honsetly the code was unstable in earlier versions but now it is extremely stable. Many large projects use it without any problems. And in the end if you can't get it to work or need the full code you can run delombok and get pure non-magic java code to work with
TheLQ
 
Posts: 16
Joined: Wed Jul 11, 2012 6:18 pm

Re: Ever consider Project Lombok?

Postby happy.neko » Tue Jul 24, 2012 8:20 pm

TheLQ wrote: This allows you to specify getters, setters, tostring, hascode, etc with just an annotation.

Another option is to use proper IDE. ;)
happy.neko
Project Member
 
Posts: 478
Joined: Fri Sep 23, 2011 5:38 pm

Re: Ever consider Project Lombok?

Postby chocolateboy » Thu Jul 26, 2012 2:20 pm

happy.neko wrote:Another option is to use proper IDE. ;)


Another option is to read the thread:

chocolateboy wrote:These are trivial to generate with an IDE.
chocolateboy
Project Member
 
Posts: 2577
Joined: Wed Sep 16, 2009 10:05 am


Return to Developers

Who is online

Users browsing this forum: No registered users and 3 guests