This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Re: Scala Ladybug

1 reply
Seth Tisue
Joined: 2008-12-16,
User offline. Last seen 34 weeks 3 days ago.

>>>>> "Samuel" == Samuel Robert Reid writes:

Samuel> I was hoping someone would give constructive criticism about
Samuel> how to improve my Scala style; some of my code feels like it's
Samuel> a bit like Java in Scala syntax. Also, I'm not sure I'm taking
Samuel> advantage of all of Scala's abilities to help me produce
Samuel> concise, robust, legible code (or whether I'm abusing any of
Samuel> the language features). I posted my code here with a syntax
Samuel> highlighter:
Samuel> http://www.colorado.edu/physics/phet/dev/moving-man/1.20.17/source/

This is a very cool little app! It's a little too much source code in
too many little files for me to sort through all of it... are there any
particular places in the code that you suspect could be improved?

I did look through LadybugModel.scala and I notice a lot of methods
like:

def setUpdateModePosition = updateMode = positionMode
def setUpdateModeVelocity = updateMode = velocityMode
def isPlayback() = !record
def isRecord() = record

and so on. Maybe you could just get rid of all that? It doesn't seem
to really add anything.

If you need getters and setters in order to interact with some Java
code, you can put a @BeanProperty annotation on a val or var and the
Scala compiler will generate them for you.

Samuel Robert Reid
Joined: 2008-12-17,
User offline. Last seen 1 year 22 weeks ago.
Re: Scala Ladybug
Thanks very much for looking at my project and for your constructive criticism; I agree isRecord() should be replaced; I will probably stick with setUpdateModePosition and Velocity to reduce the amount of information the clients need to know about the LadybugModel.

If I have any other more specific questions, I'll let you know.

Thanks again,
Sam Reid

Seth Tisue wrote:
2672 [dot] 1233096198 [at] monk [dot] ccl [dot] northwestern [dot] edu" type="cite">
"Samuel" == Samuel Robert Reid  writes:
            
 Samuel> I was hoping someone would give constructive criticism about
 Samuel> how to improve my Scala style; some of my code feels like it's
 Samuel> a bit like Java in Scala syntax.  Also, I'm not sure I'm taking
 Samuel> advantage of all of Scala's abilities to help me produce
 Samuel> concise, robust, legible code (or whether I'm abusing any of
 Samuel> the language features).  I posted my code here with a syntax
 Samuel> highlighter:
 Samuel> http://www.colorado.edu/physics/phet/dev/moving-man/1.20.17/source/

This is a very cool little app!  It's a little too much source code in
too many little files for me to sort through all of it... are there any
particular places in the code that you suspect could be improved?

I did look through LadybugModel.scala and I notice a lot of methods
like:

  def setUpdateModePosition = updateMode = positionMode  
  def setUpdateModeVelocity = updateMode = velocityMode  
  def isPlayback() = !record  
  def isRecord() = record  

and so on.  Maybe you could just get rid of all that?  It doesn't seem
to really add anything.

If you need getters and setters in order to interact with some Java
code, you can put a @BeanProperty annotation on a val or var and the
Scala compiler will generate them for you.

  

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland