# Where to define constants?

Define constants inside the module's object class.

For example:

  • Define the property MAX_PARTICIPANTS_ALLOWED in LotteryDomainObject.scala

    object LotteryDomainObject extends com.metastay.lotterydomain.LotteryDomainTrait {
      val MAX_PARTICIPANTS_ALLOWED = 100 //alternately, read it from the conf file
    }
    
  • Sample usage:



     


    import com.metastay.lotterydomain.LotteryDomainObject
    def canAddMoreParticipants(participantCount: Int): Boolean = {
        participantCount <= LotteryDomainObject.MAX_PARTICIPANTS_ALLOWED
    }