Re: Type-safe Prevayler, using generics
Klaus Wuestefeld <[email protected]>
| Newsgroups | gmane.comp.java.prevayler |
|---|---|
| Message-ID | <CAMAooZF46evrePuezEFBp+4ojBgc-j6RUuCZ0aq2QFZXkNSCGg@mail.gmail.com> |
+1 On Fri, Oct 28, 2011 at 9:17 PM, Justin T. Sampson <[email protected]> wrote: > Nice. :) I'd done this on a branch a while ago but I think I took it too far > and it ended up getting really complicated. Trying again with the bare > minimum generics in the high-level API is a good idea. > By the way, generics do not eliminate any run-time casting, so there's no > performance benefit. The compiler generates all the same casts that you > would have written by hand without generics. > On Fri, Oct 28, 2011 at 3:54 PM, Naveen Chawla <[email protected]> > wrote: >> >> Small point, but by using generics, Prevayler has complete type-safety >> minus casting. Took me longer than expected, but I've attempted this on >> Prevayler source. I submitted a "fork" on the prevayler git - >> https://github.com/Navigateur/prevayler - I'm not very good at git, but I >> think that's how you want contributions submitted. Needs run time testing. >> Demo and test code modified to match. Summary usage: >> >> instead of >> Prevayler prevayler >> use >> Prevayler<MyTypeToPrevail> prevayler >> >> and instead of >> PrevaylerFactory prevaylerFactory >> use >> PrevaylerFactory<MyTypeToPrevail> prevaylerFactory >> >> For your custom transactions/queries: >> replace >> implements Transaction{ >> with >> implements Transaction<MyTypeToPrevail>{ >> >> and >> implements TransactionWithQuery{ >> with >> implements TransactionWithQuery<MyTypeToPrevail, MyTypeToReturn>{ >> same for Query, SureTransactionWithQuery >> >> Then, you don't do any casting from Object to prevalent type, nor from >> ".execute" to return type, as these arrive in native form. >> ("MyTypeToPrevail" is compiler-checked as implementing Serializable in all >> the above cases) >> >> i.e. instead of >> (MyTypeToPrevail)prevalentSystem >> you just use >> prevalentSystem >> and instead of >> (MyTypeToReturn)prevayler.execute(... >> you just use >> prevayler.execute(... >> >> It might even run faster due to lack of run time casting on each >> transaction/query, who knows (not me). Hopefully you can test, and as soon >> as it works immediately release it as an update, or at least an immediate >> parallel choice as I really want this version now but with your genuine >> backing. >> >> >> ------------------------------------------------------------------------------ >> The demand for IT networking professionals continues to grow, and the >> demand for specialized networking skills is growing even more rapidly. >> Take a complimentary Learning@Cisco Self-Assessment and learn >> about Cisco certifications, training, and career opportunities. >> http://p.sf.net/sfu/cisco-dev2dev >> _______________________________________________ >> To unsubscribe go to the end of this page: >> http://lists.sourceforge.net/lists/listinfo/prevayler-discussion >> _______________________________________________ >> "Databases in Memoriam" -- http://www.prevayler.org >> > > > ------------------------------------------------------------------------------ > Get your Android app more play: Bring it to the BlackBerry PlayBook > in minutes. BlackBerry App World™ now supports Android™ Apps > for the BlackBerry® PlayBook™. Discover just how easy and simple > it is! http://p.sf.net/sfu/android-dev2dev > > _______________________________________________ > To unsubscribe go to the end of this page: > http://lists.sourceforge.net/lists/listinfo/prevayler-discussion > _______________________________________________ > "Databases in Memoriam" -- http://www.prevayler.org > > ------------------------------------------------------------------------------ Get your Android app more play: Bring it to the BlackBerry PlayBook in minutes. BlackBerry App World™ now supports Android™ Apps for the BlackBerry® PlayBook™. Discover just how easy and simple it is! http://p.sf.net/sfu/android-dev2dev _______________________________________________ To unsubscribe go to the end of this page: http://lists.sourceforge.net/lists/listinfo/prevayler-discussion _______________________________________________ "Databases in Memoriam" -- http://www.prevayler.org