Bummer, really appreciate the link Derek but most of the code looks to 
render as blank space in my browser (Chrome).

On Sunday, December 15, 2013 10:01:04 AM UTC-8, Derek Wyatt wrote:
>
> You might find 
> http://blog.primal.com/using-scala-implicits-to-implement-a-messaging-protocol/helpful.
>
> On Saturday, December 14, 2013 1:51:51 PM UTC-5, Shawn wrote:
>>
>> Hacking around a bit I created something like:
>>
>> abstract class IdMsg(val id:Long = System.nanoTime)
>>
>> case class AMsg(a:Int, b:String) extends IdMsg {
>>   override def toString = s"(a = $a, b= $b, id = $id)"
>> }
>>
>> val a = AMsg(1,"foo")
>> val b = AMsg(2,"foo")
>>
>>
>> which results in :
>>
>> > defined class IdMsg
>>
>> > defined class AMsg
>>
>> > a: AMsg = (a = 1, b= foo, id = 230607343776394)
>> > b: AMsg = (a = 2, b= foo, id = 230607421074922)
>>
>>
>> However this requires me to provide me own implementation of toString 
>> (without it *a* is printed as just *AMsg(1,foo) *) and it uses up the 
>> inheritance slot. Maybe that's not so bad since I don't think the default 
>> case case toString() is descriptive enough?
>>
>> Is there anything else horrific about this?
>>
>>
>> On Saturday, December 14, 2013 10:04:14 AM UTC-8, Shawn wrote:
>>>
>>>
>>> To give realistic(?) example, I've read that it's a good practice to 
>>> have messages carry a unique identifier so you can track them (e.g. via 
>>> logging).
>>> Assuming it's also a good practice to use case classes for defining 
>>> messages.
>>>
>>> Given definitions like:
>>>
>>> case class Msg1(id:Int,a:String)
>>> case class Msg2(id:Int, b:String)
>>> case class Msg3(id:Int,c:String)
>>>
>>> Is there some way I could factor out the common "id" property and 
>>> possibly it's implementation?
>>>
>>> More generally, how does one define messages with shared structure (and 
>>> perhaps even light behavior) without repeating myself?
>>>
>>> How does one tackle declaring an akka hierachy of related messages 
>>> without repeating yourself?
>>>
>>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: http://akka.io/faq/
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to