# Private and protected attributes in OOP

**URL:** <https://discourse.julialang.org/t/private-and-protected-attributes-in-oop/103104>\
**Category:** New to Julia\
**Created:** [August 23, 2023, 7:16am UTC](https://discourse.julialang.org/t/private-and-protected-attributes-in-oop/103104 "2023-08-23T07:16:46Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![GHTaarn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ghtaarn/32/216007_2.png) [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)\
**Post date:** [August 23, 2023, 1:31pm UTC](https://discourse.julialang.org/t/private-and-protected-attributes-in-oop/103104/6 "2023-08-23T13:31:40Z")

</div>

As others in this thread have said, Julia is not an object oriented language, so to write good Julia code you will eventually need to change the way that you structure your code.

Specifically private/protected fields can often be approximated with closures (but note that nothing is completely private in Julia, as far as I know, internal fields in closures can still be accessed).

This is my comment in a similar thread:

> [@Why there is no OOP (object oriented programming) in Julia?](https://discourse.julialang.org/t/why-there-is-no-oop-object-oriented-programming-in-julia/86723/48):
>
> So far, no-one here has suggested using “closures” which I personally find ideal for having specific data be associated with a specific function. A search for Julia and closures should give you a lot of references, one of them is [Julia Language Tutorial =\> Introduction to Closures](https://riptutorial.com/julia-lang/example/23207/introduction-to-closures) . It is a functional programming technique and if I understand you correctly, then this can provide what you are asking for. I use this technique a lot in places where I would have encapsulated things in an object in …

---

_[View the full topic](https://discourse.julialang.org/t/private-and-protected-attributes-in-oop/103104)._
