Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Silas Reinagel
    @SilasReinagel
    No app exists without state
    That's fair
    Yegor Bugayenko
    @yegor256
    So, memory leakage may only happen in global (read “static”) objects, right?
    I’m talking about “leakage”, not overflow
    The example you gave is not leakage
    It’s just overflow
    Leakage means we don’t know where the memory is. It’s occupied by some objects that we are not using any more. Right?
    Kirill
    @g4s8
    @yegor256 right. See this sample without static:
    public class App {
    
        Object leakedObject = new Object();
    
        public void start() {
            new Thread(new Run()).start();
        }
    
        class Run implements Runnable {
    
            @Override
            public void run() {
                System.out.printf("run");
            }
        }
    }
    here leakedObject leaked because class run is not static and this object can be accessed through App.this.leakedObject from Run instance
    Yegor Bugayenko
    @yegor256
    @g4s8 got it, you seem to be right
    every new thread is a new global space
    Stian Soiland-Reyes
    @stain
    yes, thread leakage is common in Java
    typically by doing like above, that you accidentally made a nested class that should have been static, final or separate
    I think in the Java8 lambdas it is actually better because their implied inner classes would automatically be final
    Mihai A.
    @amihaiemil
    @yegor256 > Leakage means we don’t know where the memory is. It’s occupied by some objects that we are not using any more. Right?
    Well, in Java the GC will collect any "islands" -- that is an object or group of objects which had all the references to it/them cut off, by assigning null usually
    so those are objects that "we don't know where the memory is"
    my point is, they should be collected by the GC, not such a big concern :D.. well, unless you create A LOT of such islands
    Justas Bieliauskas
    @justasbieliauskas

    Hi, everybody. I have a question regarding configurable objects.
    So, I have this class:

    public final class Cached<T>
    {
        private final Variable<T> variable;
        private final Origin<T> origin;
        public Cached(Variable<T> variable, Origin<T> origin) {
            this.variable = variable;
            this.origin = origin;
        }
        public T value() {
            if(!this.variable.initialized()) {
                this.variable.initialize(this.origin.value());
            }
            return this.variable.value();
        }
    }

    It's a class that caches a value. It needs to know what to cache and where to cache it. As you can see, I'm trying to simulate a concept of a variable, where I set a value to it, then reuse it when I need it.
    My problem is, I feel this is a configurable object. I'm injecting foreign behaviour in this class through Variable. It is not a black-box-solid object anymore, a lion's share of its logic is now in the hands of another object. I can pass anything in place of Variable<T> in the constructor and basically control how this object behaves.
    Furthermore, Variable interface itself reveals a lot of information about Variable. Since there's a method initialized and initialize, I'm almost certain there is an if sentence which checks if a Variable object holds a value and if it doesn't, sets it. I should not be aware of that.
    I discovered this problem while reading one of Yegor's drafts.
    Does anyone know what am I supposed to do here? Can't find an alternative.

    Fabricio Cabral
    @fabriciofx
    @justasbieliauskas What's the problem with:
    public final class Cached<T> implements Origin<T>
    {
        private final List<T> cache = new ArrayList<T>();
        private final Origin<T> origin;
        public Cached(Origin<T> origin) {
            this.origin = origin;
        }
        public T value() {
            if(this.cache.isEmpty()) {
                this.cache.add(this.origin.value());
            }
            return this.cache.get(0);
        }
    }
    Phantom190
    @Phantom190

    @yegor256 "What do you need a man for than?"
    Tell that to lesbians that can buy sperm and get pregnant, or simply adopt.

    @yegor256 "I got it, but I don't want my daughter to bench someone's desk with one hand and kick someone's ass with the other. I just don't want that :)"
    Who the fuck cares what you want? what you should care and what actually matters is what your daugher wants.

    @yegor256 And you believe that a society where anyone can be at any position is better than the one where certain people have certain limits?
    The only limit there is, is the one you put yourself. None should give a fuck about the limits society puts.

    James "Author is a fucking moron. Does he know that a woman invented the first programming language or"
    @yegor256 "You made it here: http://www.yegor256.com/tes... Thanks :)"
    /Testimonials.html "Author is a fucking moron."

    It's funny that in such a small sentence, you leave the good part. Considering some of your testimonials are made of like 15 lines.

    @yegor256"I don't have kids yet, but when I will have them I will raise them exactly like my parents raised me: in the gender inequality philosophy.
    Translated: In the year 2017, I will raise my kids as kids were raised back in the good old days, where racism, sexism, slavery, all those good things were the norm.

    @Yegor256 "We have to live by the laws of the Nature"
    No, not really. I live by the laws set by smart/dumb people in my country. That's the only one I actually care.

    Sorry for joining the party late !
    I also don't know why YOU living currently in the USA think women need your protection. They have guns bro. People don't need your "biceps".
    Phantom190
    @Phantom190
    By the way I bought your first book and read it for 10 mins. Then realized it was a copy paste from your website and threw it to the trash can. I REGRET IT THO, because I now own a dog and sometimes I need paper for him to shit on.
    Mihai A.
    @amihaiemil
    @Phantom190 why don't you copy the whole blog here while you're at it? Btw, good call on throwing the book after 10min read. It really is just a copy of the blog. Last 65 pages are just the images from each article. Your dog would have read more of it tho, so maybe go fetch it back for him
    Mihai A.
    @amihaiemil
    Second book also includes this sexism article plus a few blank pages just to keep the same page count. There werent enough articles you know... tough job being a writer
    Fabricio Cabral
    @fabriciofx
    By the way I bought your first book and read it for 10 mins. Then realized it was a copy paste from your website and threw it to the trash can. I REGRET IT THO, because I now own a dog and sometimes I need paper for him to shit on.
    @yegor256 A new testimonial to put here... :laughing:
    Silas Reinagel
    @SilasReinagel
    Somebody got their feelings super triggered
    That was pretty funny to watch
    RayoGundead
    @RayoGundead
    It's no laughing matter when the most liberal of tumblrettes get positions of power
    Mihai A.
    @amihaiemil
    What is a tumblerette and you mean liberal as in usa or eu?
    Bc depending on it, liberal means smth good or smth bad :))
    RayoGundead
    @RayoGundead
    a watered-down form of communist in it's media-presented form.
    Mihai A.
    @amihaiemil
    So american
    Well i don't think it's that. Yegor simply puts it bluntly, that's. It doesn't mean that he or you should apply it exaclty like that
    RayoGundead
    @RayoGundead
    all liberals of any country
    Mihai A.
    @amihaiemil
    Im referring to everything not just that sexism article
    Nah I dont imderstand that. By liberal I understand more freedom of action. The least interference with the state.
    I know in America it has an opposite meaning
    RayoGundead
    @RayoGundead
    not exclusive to America
    other countries have the term Liberal distorted
    Mihai A.
    @amihaiemil
    Well, as long as we each know what we mean, it's just semantics. Just pay attention to this word
    RayoGundead
    @RayoGundead
    see Canada and Germany
    Conservatives are practically underground there
    Mihai A.
    @amihaiemil
    Germany maybe, because they are taken as nazis?
    RayoGundead
    @RayoGundead
    the conservaives there, their mere existence gets labeled every derogatory name in the Liberal handboook
    Mihai A.
    @amihaiemil
    I know, it's bad in general to just label things. Everyone has their points and everyone exaggerates in general, making the others' bad headlines
    RayoGundead
    @RayoGundead
    so its either conform or get persecuted for wrongthink