# How to save extension preferences -- question about write\_default & read\_default

**URL:** <https://forums.sketchup.com/t/how-to-save-extension-preferences-question-about-write-default-read-default/172517>\
**Category:** Ruby API\
**Created:** [August 12, 2021, 1:47pm UTC](https://forums.sketchup.com/t/how-to-save-extension-preferences-question-about-write-default-read-default/172517 "2021-08-12T13:47:30Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [August 12, 2021, 2:40pm UTC](https://forums.sketchup.com/t/how-to-save-extension-preferences-question-about-write-default-read-default/172517/3 "2021-08-12T14:40:18Z")

</div>

**Firstly** , please learn how to properly post code in the forum …

- [[How to] Post correctly formatted and colorized code on the forum?](https://forums.sketchup.com/t/how-to-post-correctly-formatted-and-colorized-code-on-the-forum/46189)

* * *

**Secondly** , (and yes I realize you were just testing,) but the preferences JSON files are a **shared filespace**.

This means that everyone cannot be using plain descriptive names for their settings keys. Ie “HelloWorld” is too generic and could clash if someone else uses the same identifier.

Just as extensions need to have uniquely named registrar files and folders, they also need to use the same unique names for settings keys and attribute dictionary names. (All 3: files, dictionaries and settings are in **shared spaces**.)

So Tom, let us say that you choose to use “ **DrawFun** ” as your unique namespace identifier. (This is equivalent to an author or company name. Ie, a “fictitious name” if you will.)

So, your “HelloWorld” extension registrar file in the “Plugins” folder would be named **`"DrawFun_HelloWorld.rb"`**. The extension subfolder must use the same name (but without the `.rb` file type.) Ie, **`"Plugins/DrawFun_HelloWorld"`** would be the extension subfolder.

Then you must use the same identifier ( **`"DrawFun_HelloWorld"`** ) for this extension’s preferences key and any [attribute dictionaries](https://ruby.sketchup.com/Sketchup/AttributeDictionary.html) that your extension attaches to model objects.

**All** of the code in **all** of your extension’s files must be module wrapped using the same identifiers like so …

```ruby
module DrawFun
  module HelloWorld

    # This extension's code ...

  end # extension submodule
end # top level namespace module

```

The fully qualified identifer to your extension is: **`DrawFun::HelloWorld`**.  
(Basically the underscore is replaced with Ruby’s **`::`** scope operator.)

* * *

**Thirdly** … lets get back to the preamble of your topic’ title … “_How to save extension preferences_” …

There are quite a few topics covering this more generally including what is the best way.

I feel that using “write\_default” and “read\_default” has not really been “_the recommended way_” **by developers**. Let us say that it is an old way that has long been available by the API.

But it has quirks… `read_default` evaluates the stored values in Ruby which can lead to weirdness.

Many developers have instead switched to using their own JSON files that are separate from SketchUp’s. I posted example of methods only 3 weeks ago …

- [Storing Plugin Data Revisited (Wall Presets) - #19 by DanRathbun](https://forums.sketchup.com/t/storing-plugin-data-revisited-wall-presets/170813/19)

---

_[View the full topic](https://forums.sketchup.com/t/how-to-save-extension-preferences-question-about-write-default-read-default/172517)._
