Advice on splitting source code line

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Advice on splitting source code line

Al Fargnoli
I'm new to Scala, and I've just found this line of source code:

val (newMiniPhis, newMapPhis, newDampedRow) = StateProcessor(StateMini, StateMap).dampen(pingMessageSet, dampenedUow, priorMiniPhis, priorMapPhis)

What would be the correct way to rewrite this so that it's more readable.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Advice on splitting source code line

Christian Kaps
Hi,

you could write:

val (newMiniPhis, newMapPhis, newDampedRow) = 
  StateProcessor(StateMini, StateMap)
   
.dampen(pingMessageSet, dampenedUow, priorMiniPhis, priorMapPhis)

or

val (newMiniPhis, newMapPhis, newDampedRow) = {
  StateProcessor(StateMini, StateMap)
   
.dampen(pingMessageSet, dampenedUow, priorMiniPhis, priorMapPhis)
}

or

val (newMiniPhis, newMapPhis, newDampedRow) = StateProcessor(StateMini, StateMap)
 
.dampen(pingMessageSet, dampenedUow, priorMiniPhis, priorMapPhis)


or

val (newMiniPhis, newMapPhis, newDampedRow) = StateProcessor(StateMini, StateMap)
 
.dampen(
    pingMessageSet,
    dampenedUow
,
    priorMiniPhis
,
    priorMapPhis
 
)


There are so many possibilities!

Best regards,
Christian

Am Freitag, 24. Februar 2017 03:39:24 UTC+1 schrieb Al Fargnoli:
I'm new to Scala, and I've just found this line of source code:

val (newMiniPhis, newMapPhis, newDampedRow) = StateProcessor(StateMini, StateMap).dampen(pingMessageSet, dampenedUow, priorMiniPhis, priorMapPhis)

What would be the correct way to rewrite this so that it's more readable.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Aw: [scala-user] Re: Advice on splitting source code line

Dennis Haupt-2
whatever i do, i always wrap things in {} because that way i can add a line without having to add braces first
 
Gesendet: Freitag, 24. Februar 2017 um 08:23 Uhr
Von: "Christian Kaps" <[hidden email]>
An: scala-user <[hidden email]>
Betreff: [scala-user] Re: Advice on splitting source code line
Hi,
 
you could write:
 
val (newMiniPhis, newMapPhis, newDampedRow) = 
  StateProcessor(StateMini, StateMap)
    .dampen(pingMessageSet, dampenedUow, priorMiniPhis, priorMapPhis)

or
 
val (newMiniPhis, newMapPhis, newDampedRow) = {
  StateProcessor(StateMini, StateMap)
    .dampen(pingMessageSet, dampenedUow, priorMiniPhis, priorMapPhis)
}

or
 
val (newMiniPhis, newMapPhis, newDampedRow) = StateProcessor(StateMini, StateMap)
  .dampen(pingMessageSet, dampenedUow, priorMiniPhis, priorMapPhis)

 
or
 
val (newMiniPhis, newMapPhis, newDampedRow) = StateProcessor(StateMini, StateMap)
  .dampen(
    pingMessageSet, 
    dampenedUow, 
    priorMiniPhis, 
    priorMapPhis
  )


There are so many possibilities!

Best regards,
Christian

Am Freitag, 24. Februar 2017 03:39:24 UTC+1 schrieb Al Fargnoli:
I'm new to Scala, and I've just found this line of source code:
 
val (newMiniPhis, newMapPhis, newDampedRow) = StateProcessor(StateMini, StateMap).dampen(pingMessageSet, dampenedUow, priorMiniPhis, priorMapPhis)

What would be the correct way to rewrite this so that it's more readable.

 

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Advice on splitting source code line

Lanny Ripple
In reply to this post by Al Fargnoli
My pref (YMMV) would be Christian's first example.  If you are passing around the results a lot it might also be useful to create a case class to hand them around as a single unit.  Looking at your inputs I'm guessing repeated iterations so

    case class StepState(miniPhis: MiniPhis, mapPhis: MapPhis, dampedRow: DampedRow)

    val nextStep = StateProcessor(StateMini, StateMap).dampen(pingMessageSet, oldStep)

  -ljr

On Thursday, February 23, 2017 at 8:39:24 PM UTC-6, Al Fargnoli wrote:
I'm new to Scala, and I've just found this line of source code:

val (newMiniPhis, newMapPhis, newDampedRow) = StateProcessor(StateMini, StateMap).dampen(pingMessageSet, dampenedUow, priorMiniPhis, priorMapPhis)

What would be the correct way to rewrite this so that it's more readable.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...