• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

OO Techniques & Universal Best Practices

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Matthias,

What techniques for creating pro-quality OO code that can stand the test of time do you use in your book?  I would love to review them and apply the ones I am not aware of ...

What universal best practices for object design do you provide in your book?  I would love to elevate my coding style by mastering the universal best practices described in your book ...

Why are immutable objects more secure and reliable?  Do you use immutable objects in your book?

Thanks,
Gibran
 
Marshal
Posts: 79971
396
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gibran Castillo wrote:. . . Do you use immutable objects in your book? . . .

I would hope they do.

Immutable objects can safely be interned and shared, without any need for copying or using the clone() method. So, it might appear expensive to create multiple objects, but they can be more economical on space because duplicates are not necessary. Similarly, there is no need to take defensive copies.
Another advantage of immutable objects is that they are implicitly t‍hread‑safe.
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:

Gibran Castillo wrote:. . . Do you use immutable objects in your book? . . .

I would hope they do.


It looks like they cover the subject:

https://livebook.manning.com/book/object-design-style-guide/chapter-1/44
 
Campbell Ritchie
Marshal
Posts: 79971
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Follow that to ยง4.4 and you can see how an object can sneakily change its state if it isn't written properly.
 
Author
Posts: 7
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some useful answers have been provided here already. Yes, immutability is a central concept. The underlying design concept is to make objects predictable by making them recognizable; making it very clear what to expect from them. E.g. how you can use them, what they will do when you call them (give you a piece of information, or produce some kind of side-effect), etc.
 
Gibran Castillo
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would love to be awarded a copy of your book to apply your best practices and principles for coding.  I'll become a much better developer.
 
You guys wanna see my fabulous new place? Or do you wanna look at this tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic