שוב אני נעדר ומשאיר את רן לבד - הפעם כדי להתמודד עם יתיר בן שלמה ו... Java References
- יתיר קצת סיפר על מעגל חייו של אובייקט ג'אוואי.
- מה קורה כשמחזיקים חזק קישורים קשיחים (Strong reference)
- את "רודף העפיפונים" כבר קראתם?
- Soft Reference - קישור אבל... יותר "חננה". יכול להיות שכבר מישהו היה צריך את הזיכרון הזה.
- איך עובדים עם זה? איך מקבלים, איך מחזירים.
- Weak Reference - קישור "בלי אופי" - אם רק קישורים כאלה מחזיקים את האובייקט - "שחרר אחי!".
- מה זה Weak Hashmap ?
- Phantom Reference - האפשרות להגיע ל... "רשימת הנספים".
- למה? כי - Finalize Sucks!!!
הקובץ נמצא כאן
האזנה נעימה
What do you think about container managed Singletons ?
השבמחקI.e. Singletons that are not referenced by a static member of a class but are injected by Guice or Spring for example using the @Singleton annotation of Guice.
Would you consider them as singletons? If so, are they still evil?
These are very easy to test and unless the developers tries to be smart, they are singletons in the system.
I think Guice or Spring singletons are definitely much better than programmatic singletons
השבמחקI don't know if they have downsides, but I personally use them. Sorry I did not mention them in my answer to the listener question
זה בדיוק ההבדל בין Singleton ל singleton
השבמחקhttp://java.dzone.com/articles/benefits-testable-code
First lets get our terminology straight: (1) There are Singletons (capital S) as in the name given to the design pattern, which has as a private constructor and a global internal variable usually called instance. We get a hold of a Singleton by calling a static method as in Singleton.getInstane(). (2) There are also singletons (lower s) which simply means that we have a normal class (public constructor no global state), and inside our application we only have a single instance of it. We get hold of singleton by asking for it in the constructor. There are a lot of reasons to have singletons, as in a single instance of something shared among many other objects, such as a cache, and I use singletons all the time. The problem is not with having singletons (one of something), but rather with having Singletons (one of something and it is global). Asking for a singleton through dependency injection (no global state) is good practice, but getting hold of a Singleton through global state is recipe for disaster.
Hi אנונימי
השבמחקLooks like Eishay and I sort of are in agreement with you. I wasn't aware of the s/S game but in general I think that being able to say "I have one instance of this object" is good and accessing objects globally is bad. Container provided singletons let us enjoy both worlds
אני נהנה מאד מהאזנה לרברסים עם פלטפורמה ובמיוחד לפרק הזה.
השבמחקתודה!
סבבה :)
השבמחק