# Design principles

**URL:** <https://users.scala-lang.org/t/design-principles/3062>\
**Category:** Question\
**Created:** [August 1, 2018, 1:54am UTC](https://users.scala-lang.org/t/design-principles/3062 "2018-08-01T01:54:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nareshraju](https://users.scala-lang.org/letter_avatar_proxy/v4/letter/n/439d5e/32.png) [@nareshraju](https://users.scala-lang.org/u/nareshraju)\
**Post date:** [August 1, 2018, 1:54am UTC](https://users.scala-lang.org/t/design-principles/3062/1 "2018-08-01T01:54:45Z")

</div>

What are the design principles have in scala,what use it.

---

<div class="post-metadata">

**Author:** ![Jasper-M](https://users.scala-lang.org/user_avatar/users.scala-lang.org/jasper-m/32/872_2.png) [@Jasper-M](https://users.scala-lang.org/u/Jasper-M)\
**Post date:** [August 1, 2018, 8:05am UTC](https://users.scala-lang.org/t/design-principles/3062/2 "2018-08-01T08:05:08Z")

</div>

Does [this chapter](https://www.artima.com/pins1ed/a-scalable-language.html) from _Programming in Scala, First Edition_ answer your question?

---

<div class="post-metadata">

**Author:** ![nareshraju](https://users.scala-lang.org/letter_avatar_proxy/v4/letter/n/439d5e/32.png) [@nareshraju](https://users.scala-lang.org/u/nareshraju)\
**Post date:** [August 1, 2018, 11:13am UTC](https://users.scala-lang.org/t/design-principles/3062/3 "2018-08-01T11:13:18Z")

</div>

sorry i didn’t get above link.cloud you please anyone give me proper answer?

---

<div class="post-metadata">

**Author:** ![Jasper-M](https://users.scala-lang.org/user_avatar/users.scala-lang.org/jasper-m/32/872_2.png) [@Jasper-M](https://users.scala-lang.org/u/Jasper-M)\
**Post date:** [August 1, 2018, 11:55am UTC](https://users.scala-lang.org/t/design-principles/3062/4 "2018-08-01T11:55:43Z")

</div>

Sorry, I also didn’t get the proper question, so that was really the best I could do…

---

<div class="post-metadata">

**Author:** ![nareshraju](https://users.scala-lang.org/letter_avatar_proxy/v4/letter/n/439d5e/32.png) [@nareshraju](https://users.scala-lang.org/u/nareshraju)\
**Post date:** [August 1, 2018, 12:16pm UTC](https://users.scala-lang.org/t/design-principles/3062/5 "2018-08-01T12:16:50Z")

</div>

Question: what are functional design principles in scala,like Singleton, Factory, Decorator, Dependency Injection …etc

---

<div class="post-metadata">

**Author:** ![jducoeur](https://users.scala-lang.org/user_avatar/users.scala-lang.org/jducoeur/32/462_2.png) [@jducoeur](https://users.scala-lang.org/u/jducoeur)\
**Post date:** [August 1, 2018, 12:29pm UTC](https://users.scala-lang.org/t/design-principles/3062/6 "2018-08-01T12:29:20Z")

</div>

> [@nareshraju](#):
>
> Question: what are functional design principles in scala,like Singleton, Factory, Decorator, Dependency Injection …etc

Now I’m a lot more confused. Are you asking you those design patterns get _implemented_ in Scala? I wouldn’t call those “principles”.

I’m really not sure what you’re asking – you may want to ask in more detail…

---

<div class="post-metadata">

**Author:** ![sidhartha11](https://users.scala-lang.org/user_avatar/users.scala-lang.org/sidhartha11/32/589_2.png) [@sidhartha11](https://users.scala-lang.org/u/sidhartha11)\
**Post date:** [August 2, 2018, 2:37am UTC](https://users.scala-lang.org/t/design-principles/3062/7 "2018-08-02T02:37:40Z")

</div>

I am also a beginner but so far in my study of scala it appears that a lot of the design patterns that you find in Java are actually built into the scala language. Singleton, for instance, appears to take the form of the “object” in scala for the most part. Factory seems to be built in using the apply method in a companion object and appears to come automatically in case classes. All those nifty patterns you find in java seem to be implemented using high-order functions that take and return functions; e.g. visitor, decorator, strategy. I guess you can also directly implement those patterns in scala taking an empirical approach. I mean there probably is nothing stopping you from creating a standard java like singleton. Hey, you can use java directly in Scala if you like. One thing though, in Scala there is no static keyword. In java you usually use a static to implement some of the patterns. I notice that so far the books I have looked at in Scala do not seem to talk much about design patterns in the way they do in the java documentation.

---

<div class="post-metadata">

**Author:** ![mgrand](https://users.scala-lang.org/user_avatar/users.scala-lang.org/mgrand/32/129_2.png) [@mgrand](https://users.scala-lang.org/u/mgrand)\
**Post date:** [August 2, 2018, 3:08am UTC](https://users.scala-lang.org/t/design-principles/3062/8 "2018-08-02T03:08:42Z")

</div>

In scala, instead of declaring a static variable in a class, you declare a field in the companion object.

---

<div class="post-metadata">

**Author:** ![nareshraju](https://users.scala-lang.org/letter_avatar_proxy/v4/letter/n/439d5e/32.png) [@nareshraju](https://users.scala-lang.org/u/nareshraju)\
**Post date:** [August 2, 2018, 3:33am UTC](https://users.scala-lang.org/t/design-principles/3062/9 "2018-08-02T03:33:18Z")

</div>

thank you sidhartha.
