Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8495127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:29:05+00:00 2026-06-10T23:29:05+00:00

This is an OO design Q. Im using typesafe Config in my App. The

  • 0

This is an OO design Q. Im using typesafe Config in my App. The Config interface is very useful, however there are a couple of fields in my applications; config file that are mandatory. What I wanted to do was create a subInterface of Config and add these 2 top-level methods . Something like this

trait AppConfig extends Config{
    def param1:String 
    def param2:String 
}

However creating a real instance of AppConfig given an instance of Config doesnt seem feasible.( I dont want to create wrapper object and duplicate all the methods on the Config interface) . Ideally , Im looking for something that would achieve something close to this

val conf:Config = //get config object from somewhere
return conf with AppConfig { overrider def param1 = {"blah"} }

I do understand the last line is not valid . But Im looking for a pattern/construct with an equivalent functionality.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:29:07+00:00Added an answer on June 10, 2026 at 11:29 pm

    What you are looking for is basically what some call a “dynamic mixin”. This is not supported out of the box by scala.
    Someone developed a compiler plugin to support this: http://www.artima.com/weblogs/viewpost.jsp?thread=275588

    However it’s a bit old and the project does not seem active anymore.

    A better alternative would be to implement this feature using scala macros (requires scala 2.10, which has no stable release yet).

    All of this is probably overkill in your case though. Until some well tested library is available, I would advise to just create the proxy by hand (however dull that may look):

    trait ConfigProxy extends Config {
      def impl: Config
      // Forward to the inner config
      def root: ConfigObject = impl.root
      def origin: ConfigOrigin = impl.origin
      //... and so on
    }
    
    val conf:Config = //get config object from somewhere
    val myConf: AppConfig = new AppConfig with ConfigProxy { 
      val impl = conf
      val param1:String = "foo"
      val param2:String = "bar"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To my knowledge, there can be two possible ways to design this: Using a
Would you consider using an interface and polymorphism to extend this design to be
I'm using this php class ( http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php ) for creating the different sized images
I'm using this jquery plugin ajaxFileupload in our project. My design is I have
I'm using Glade-3 for my GUI design, but I keep hitting this problem. I
How to add a FunctionImportMapping programmatically using classes from the System.Data.Entity.Design namespace? This blog
I'm new to DDD and am thinking about using this design technique in my
I have this design: public interface IFactory<T> { T Create(); T CreateWithSensibleDefaults(); } public
I am using Wordpress for this design portfolio website: http://onomadesign.com/wordpress/identity-design/shleppers-moving-storage/ Now, on this single.php
I got this design: http://img526.imageshack.us/img526/1363/desginer.jpg I'm trying to get the best result using: div.image

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.