« first day (1527 days earlier)      last day (3397 days later) » 

7:00 PM
and getters allow for lazy initialization, of course. i wouldnt say they're all trivial
 
fge
Or factories
 
They are really not if you have trivial setters and getters.
 
Of course you do, do you even code? setters provide encapsulation because you can pass checks and pretty much anything, like Objects.returnNonNull()
 
fge
I hate setters
 
@Unihedro I'm talking about trivial setters and getters.
 
fge
7:00 PM
In fact, I have close to no setters at all in all my code
(no need for them)
 
There are no trivial setters and getters. @Jefffrey
 
And by trivial I mean: T getX() { return x; } and void setX(y) { this.x = y; }.
You can just have x public and it makes no difference whatsoever AFAIK.
 
Wrong!
 
Like JavaBean getter/setters? Thats for a whole different reason
Its to allow frameworks to use the bean without knowing the type of it. Its a convienence, so still not really trivial
 
@Unihedro Why don't you tell me why?
 
7:03 PM
I understand some people abuse them, but thats not what I'm referring to
 
Given public field, you cannot change the encapsulated method. For example, you can't add checks where previously you used a public property.
 
@Unihedro Sure you can, by changing the public field to a method.
But only if you suddenly don't need a trivial access anymore.
 
THEN YOURE BREAKING ENCAPSULATION
 
Why?
 
BY DESTROYING VISIBILITY OF FIELD
OMG
 
7:05 PM
Do you know what encapsulation means?
 
If you change the field to a method, the method would need to return a new instance
i dont understand what you mean there..
 
@VinceEmigh No?
 
Do you know how to code a program that works?
 
I like to think I do.
 
I'm not judging your skill, Jeffrey. I'm looking for answers
 
7:07 PM
@VinceEmigh I'm here to provide them :)
 
What do you mean by changing the field to a method? Then how would the method return a pre-existing instance?
 
We're not professors, we don't define useless concepts, if you change a field to a method, THEN IT DOESN'T WORK ANYMORE!
 
@VinceEmigh If you previously have public T field;, and you need to limit access or limit the number of values it can have by filtering in the setter, you can just have void setField and T getField.
@Unihedro Yup. So?
 
I smell the stench of programming arguments
sup
 
@Jefffrey So?
 
7:09 PM
@Unihedro Where you previous used the public field, you need to change it to use a method call.
 
You want an argument? Well here's your argument:
System.out.println("Got you real good now didn't I!");
 
@Gemtastic That's actually not a bad one
 
guys, here's how programming is done
you write nice code
end of story
full stop
period
.
 
I understand that, but if we had get and set implemented into the JLS, the types could be infered, which was why I find it to be a neat system. I don't see any possible problems, so I'm not sure why Java hasn't done it
 
@Jefffrey ;D
 
7:11 PM
@Jefffrey This (boring and repeated and bad and unmaintainable and makes people laugh) method is exactly why Java is terrible and I can break most classroom programs.
 
@Jefffrey my bad, still prerty new to chats, forgot to tag your name
 
I have to cash in with @AlexM. on this one.
 
@Unihedro You changed the contract of the method. Modifying where it was used is something you would want to do, not avoid.
 
The premise is broken
 
How so?
 
7:13 PM
Woah
 
"it makes no difference whatsoever" <- -50
 
@Unihedro What makes Java bad again? I must have missed that part
 
Because: When you change the contract, the field disappears and code breaks
 
There are some things I dont like, but you havent given true reason
 
@VinceEmigh There's a transcript. Whatever I said was present, read it.
 
7:14 PM
Dont change the contract. In what language could you change a public API and expect it not to break
 
Java
 
It'll break in Java, itll break in C++, and im sure itll break in whatever language you favor
 
No it won't unless you do it wrong.
 
fge
@Unihedro I thought you were going to sleep :p
 
I've said "Wrong!" many times, because the assumptions of "this is bad because X", codeThatProves(X) is Wrong!
 
7:16 PM
if yoy remove a method from a contract, code breaks
 
false
 
@Unihedro You also cannot change encapsulated setters in many cases, because adding checks potentially breaks all existing clients.
 
Oh yeah? What about legacy code that depend on that method?
 
@fge hold my keys, this will be an all nighter
 
@Unihedro XD
 
7:17 PM
@FredOverflow @deprecated
 
fge
Uh, OK :p
 
"I can't go to bed! Someone on the internet is WRONG!"
2
 
fge
Still with Functions here :p
 
^^
 
7:18 PM
Beat me to it :)
 
@Unihedro Well?
 
This is an XKCD classic, I love it.
 
Also immutability for the win.
 
Someone is wrong on the internet. In my room!!
 
deprecating a method isn't removing it, btw.. It's still accessable, still private and unless you remove the implementation, still processes
*not private
 
7:19 PM
@VinceEmigh You can edit posts for up to 2 minutes. Just press cursor-up.
 
@Unihedro What if that one is you?
 
Yes, but it documents "it's time to get this method out of our implementation" without breaking stuff.
 
@FredOverflow on mobile :S
 
@VinceEmigh I know the pain.
 
@VinceEmigh on mobile as well
menu edit last delete type type send
Anyway, if you strap code and not deprecating or to change public fields out of visibility, this breaks code
And it's your fault, not Java's
 
7:22 PM
If you gotta deprecate a method, your API wasn't strong enough to begin with. An API should be scaled, not changed. Deprecated methods build up until your API is messy enough to re-release
 
139
A: Why use getters and setters?

R. Martinho FernandesA public field is not worse than a getter/setter pair that does nothing except returning the field and assigning to it. First, it's clear that (in most languages) there is no functional difference. Any difference must be in other factors, like maintainability or readability. An oft-mentioned adv...

 
Now, Java has deprecation, so what are we even talking about here?
 
@VinceEmigh Then why change the contract to begin with?
 
In C++, if you change a method name, it breaks. Java is just as easy to break as any other language
That's what I'm asking you. You said Java isnt easy to change and breaks easily
I said that goes with just about any language
 
@Jefffrey did. I'm claiming the opposite.
eyes @VinceEmigh; does this user even know what's being discussed, he wonders to self
 
7:25 PM
I asked why Java was bad, you said "cant change contract without breaking"
 
I didn't.
 
> There are reasons to use getters and setters, but if those reasons don't exist, making getter/setter pairs in the name of false encapsulation gods is not a good thing.
 
@Jefffrey Read the entire thing before you steal lines.
 
@uni how to you make a quote?
 
@Jefffrey Sometimes, in order to set a field, you need to do more than just assign a new object to a variable.
 
7:26 PM
As in how Jeff just did
 
12 mins ago, by Unihedro
@VinceEmigh There's a transcript. Whatever I said was present, read it.
 
Unihedro: "Because: When you change the contract, the field disappears and code breaks"
 
@Gemtastic Prepend your message with a ">" character.
 
> Like this?
 
@VinceEmigh That message wasn't even to you.
 
7:27 PM
yaay it works
 
:D
 
thank you ^^
 
And a space after the bracket.
 
@Unihedro I asked you why you thought Java was bad, and that was the reply I got
Miscommunication I guess
 
>not this
13 mins ago, by Unihedro
@VinceEmigh There's a transcript. Whatever I said was present, read it.
^ @VinceEmigh Does the other message come with your name?
 
7:29 PM
@Unihedro I did. Multiple times in the last months.
What makes you think I didn't?
 
"Java is the worst programming language. Except all the others." -Winston Churchill
 
@Michael Then it's not a trivial setter.
 
@Jefffrey Right. But the point of setters is that it gives a setter the ability to become non-trivial if need be, without breaking the API.
 
And look through the entire chat, looking for an opinion somewhere within it? Yeah I'ma just assume your opinion isn't woth it
 
@Jefffrey: Because the reasons exist - there are no trivial setters in Java.
 
7:30 PM
@Unihedro They can be abused
 
@Michael But adding checks is breaking the API, but sadly not in a way that a compiler can detect.
 
^
 
@FredOverflow Breaking = Uncompilable
 
lol no
 
lol welcome to Java
 
7:31 PM
@FredOverflow It is? Whatever a setter does is internal to the class. That's encapsulation.
 
breaking can be misuse of an API
 
30 mins ago, by Jefffrey
And by trivial I mean: T getX() { return x; } and void setX(y) { this.x = y; }.
 
That's not trivial.
 
That's what I mean by trivial.
 
@Unihedro If you are not talking about JavaBeans, explain how it's not trivial
 
7:33 PM
I've stated it there, 30 minutes ago, exactly so that there would be no ambiguities.
 
compared to using a public field
i mean for public apis yeah
 
Using a setter method also allows you to add thread synchronization. You can't do that when just setting a public field.
 
it allows you to easily modify the api. but for just programming your own application which isnt an API (rather than an application), then its pretty trivial
 
(Not unless you wrap the call in a synchronized block).
 
@Michael yes, but thats only if you need synchronization, which is a special need and justifies a setter
 
7:34 PM
@Michael It does, but if you add it later, then you are breaking the old contract.
 
Synchronization doesn't break a contract, necessarily.
 
@Jefffrey Then your definition of trivial is wrong and you should learn what it means. I quote myself: It allows for changing the getters and setters without breakingTM code. It adds to the thread stack. It encapsulates the call and lets you reflect it. It allows overriding with a proxy. It has an absolute reference as #, not . A FIELD DOES NONE!
 
All of this ambiguious terminology....
We need better standards. Anyone else agree?
 
switch to scala
 
fge
eyes @Unihedro -- Suppliers, Suppliers!
 
7:36 PM
quit looking for a job in development
ok!
goes to code
 
I use both. I'm talking about the term "breaking" and other ambiguous terms I've noticed
 
JLS
 
fge
Scala happily breaks its ABI on a regular basis; unsuitable for production
 
@fge at least it has abstract stuff that entertains our visitors
 
I use it for hidden implementation. Its quick and less verbose
I only use it on a small scale, as well. not a fan of the IDE (lags quite a bit) so I don't use it
 
7:39 PM
@Unihedro I gave a definition 40 minutes ago. It can't be wrong because it's as explicit as it gets.
BRB
 
@Unihedro You can change the implementation (for example change a linkedlist to an arraylist), but you cannot change the observable behavior. Changing the observable behavior is breaking clients, even if the compiler doesn't notice.
 
@FredOverflow Breaking = Uncompileable
@Jefffrey "it can't be wrong because" reason - sorry, your definition is wrong because it's just not what it means.
 
@Unihedro It also means mis-use of an API
as Josh Bloch referred to it as
 
@VinceEmigh lmgtfy.com/?q=JLS
 
// before
public void foo(int x)
{
    this.x = x;
}
// after
public void foo(int x)
{
    if (x < 0) throw new Exception();   // this breaks old clients, because they didn't know about the exception before
    this.x = x;
}
 
7:42 PM
It compiles.
 
And it still breaks clients.
 
So? It doesn't break code, only clients.
 
@Unihedro Smooth... Too bad the JLS is the specifications for the language, and does not account for API design
 
hello... wassup! belated christmas greetings..
 
@Unihedro Nor the terminology that goes with it
 
7:43 PM
@VinceEmigh Are you kidding? It even comes with recommendations for using the Java API and implementions of the JVM.
Heya @LeeJeong
//closed as off topic: This question appears to be off topic because it shows minimal understanding.
 
fge
@FredOverflow does not compile
 
Its like you linked me to the JLS without reading it youraelf. The JLS and JVMS are different things, and even if it recommends using the Java API, it does not account for API terminology
 
Well, it does.
 
@fge Why?
 
@Unihedro Well it doesn't /: Sorry m8
 
fge
7:45 PM
@FredOverflow you cannot throw a checked exception without declaring it as thrown at the method level
It has to be unchecked, or an Error
 
Fine, replace it with RuntimeException or whatever the correct type is.
 
@VinceEmigh I'm going to circle the part to show you that it does and then you will pay for the trouble you caused.
 
@Unihedro got my wallet ready...
 
fge
yawn this end of year is filled with pointless debates, it seems
 
Nope, chat timeout something more
 
7:48 PM
I wish I could join the conversation but I don't know enough >_>
 
Oh wait, it still doesn't compile, because the Java compiler does not unterstand the //before and //after comments, and you can't have two foo(int) methods! Also, I forgot to put the methods inside a class.
 
it does
 
fge
@FredOverflow you really don't know the language, do you? C++ style comments work just fine
 
I just changed how the Java compiler runs, so now repeated methods are allowed.
 
fge
So, pray tell, why are you discussing the language at all?
 
7:48 PM
@Gemtastic Feel free to start a topic you understand (or don't, your choice)
 
@fge Yes, but they are ignored by the compiler, so the compiler sees two foo methods.
 
fge
Stop procrastinating and just go do stuff -- like @Unihedro and I do
 
@VinceEmigh I will when I'm done with the site design for the webshop. When the time comes to begin the backending
 
@fge It was never my intention to discuss Java. Breaking APIs is possible in any language. I just posted Java-ish pseudocode which clearly does not compile.
 
@fge will do sir ;P
 
fge
7:51 PM
Well, is there any contest in the fact that breaking APIs is bad? No. So why discuss it at all?
 
@fge Are you pro or con checked exceptions?
 
fge
Pro
 
Do you miss them in other languages?
 
fge
Yes, I do
Except in C, but well, C is special
 
Why do you think other languages don't have them (yet)?
 
7:51 PM
@VinceEmigh Directly implying that she has the time to, especially with you visitors here, whose points bring no educational value point of interest
 
fge
No idea
 
I think Anders H. once said that their costs outweigh their benefits or something.
 
fge
I just happen to like them because they are a clear indication of when a situation can be recovered, and you choose how to recover them
 
@Unihedro What's your problem? You still haven't proven me wrong, and I have yet to hear one profitable thing from you. Get over yourself
 
presses the "I quit this conversation" button; pushes chair back in place and walks to IDE
 
fge
7:53 PM
Well, Anders H. has his opinions, I have mine
Also, I hate it how languages which do not have them generally blissfully forget to document what exceptions can be thrown, damnit
 
@Unihedro breaking CAN mean misusing an API, so if you ask me, you're hurting this chat
 
fge
If they did, actually I could act on them
But no
 
except... I didn't ask you @Vince
 
@Unihedro does that mean you'll finally catch some Z?
 
No, code
 
7:54 PM
XD
 
fge
@Unihedro pull --rebase
 
fetched and rebased
 
fge
And there is one thing I appreciate in Java: its ecosystem
It's very mature, and very solid
Nobody can deny that
There are turds, like in any other language ecosystems; but there are a lot of gems
 
I'll come back when hospitality shows. Nice talking to most of you
 
@fge My feeling is that a lot of developers don't understand the conceptual difference between checked exceptions (recoverable runtime errors) and unchecked exceptions (mostly program bugs).
 
fge
7:58 PM
@FredOverflow I agree; and I admit it did take me some time to fully grasp the difference
 
This line warpping thing is back after I turn on vim emulation mode of the plugin.
 
@fge Like, it doesn't really make sense to catch an InvalidArgumentException.
 
fge
No it doesn't
And when I see catch (Exception e) I cringe
Unfortunately, RuntimeException extends Exception -- for me that's a design mistake of Java
 
In C++ you can even literally say catch (...) to catch anything, including integers :)
@fge agreed
 
fge
But it's far too late to fix that
 
7:59 PM
js as well
catch (t) {}
 
fge
    return value -> {
        try {
            return doApply(value);
        } catch (Error | RuntimeException e) {
            throw e;
        } catch (Throwable tooBad) {
            throw ThrowablesFactory.INSTANCE.get(exceptionClass, tooBad);
        }
    };
This is how I deal with exceptions :p
(doApply throws Throwable; that's by design)
 
We should static import get() so it looks better.
 
fge
Erm
You can't
ThrowablesFactory is an enum
You can static import INSTANCE though
But why bothe?
 
Interestingly, C++ distinguishes logical errors from runtime errors, but not via language support.
> std::logical_error: Defines a type of object to be thrown as exception. It reports errors that are a consequence of faulty logic within the program such as violating logical preconditions or class invariants and may be preventable.
> std::runtime_error: Defines a type of object to be thrown as exception. It reports errors that are due to events beyond the scope of the program and can not be easily predicted.
 
no static import domain.ThrowablesFactory.INSTANCE.get?
 
fge
8:03 PM
@Unihedro no, you can't do that
And a lonely get() in there would not really be legible :p
 
Can we have a static method in ThrowablesFactory as get() which calls instance.get and static import that?
 
fge
Yes but if you submit a PR for that I'll reject it :p
 
please?
Actually, I changed my mind, let us not
 
fge
really wishes the JDK had adopted JSR 305
 
Should I be using return Type1.mock() or should I keep Type1 t = Type1.mock() and then return that, to assertEquals?
 
fge
8:13 PM
Use a variable; Type1.mock() generates a new, different mock each time
THis is why I put arguments/return values as final class instance members
 
Great!
 
Please suggest libs that re-implement Java serialization (with full support of final field assignment, transients, readObject(), etc.) with exception it serializes to human readable format (JSON, XML, etc.)
 
fge
@leventov Jackson, for instance (JSON)
 
@fge performance is not an issue, it would be better if the library is tiny
 
fge
Well, tiny libraries exist, but they won't be able to handle more complicated {de,}serialization scenarios
 
8:26 PM
use Externalizeable, no dependency needed
 
fge
@Unihedro you still need to code the {de},serialization process by hand with this, though
 
Wait, there's free lunch ever?
 
fge
I guess one should really try a JSON deserialization using MethodHandles
Meh
Not me
 
I will try! After I clear my stack (no pun intended) of tasks
 
It's a miss in JDK that there is no option to serialize like that. at least for debugging.
 
fge
8:56 PM
Dum dedum... wishes there weren't so many derivatives of Function
 
falls asleep writing tests
 
fge
Writing them is one thing -- do you run them? :p
If only that generics problem were solved, most of the tests would be final :( I really hate that
 
9:16 PM
What problem?
 
But... How to do in IntelliJ?
 
AFAIK generics are like an handicapped version of templates in C++. Is that correct?
 
I could use an Eclipse plugin, but this...
 
fge
9:30 PM
Argh
Major IDEA crash
It is the firts time it has ever crashed like this :(
 
;(
 
Hi everyone, I'm wondering if anyone an help me out. I'm trying to get a text animation to be responsive, the text is in my index.js file, like this,

MESSAGES.push({
delay: 0,
text: "The text will appear here."
});
 
@ChrisWeigen Java is not JavaScript.
 
o ok
sorry
 
Java is terribad.
 
9:41 PM
@Nooble I don't understand. Can you reformulate that as a Design Pattern?
2
 
lol
 
The one about Haskell was so correct and heart breaking.
The one that goes down on Monads, then goes up and then goes down again on Category theory.
 
@Jefffrey Aren't Monads just one Category?
Like, you could have done the same in Java with "Observer" and "Design Patterns".
 
@FredOverflow I'm the category theory pit right now, so I wouldn't know.
 
user1804599
9:51 PM
@FredOverflow No.
 
user1804599
It's a functor with some extra properties.
 
@rightføld Functor is a Category, right?
At least it appears in here:
Category theory is used to formalize mathematics and its concepts as a collection of objects and arrows (also called morphisms). Category theory can be used to formalize concepts of other high-level abstractions such as set theory, ring theory, and group theory. Several terms used in category theory, including the term "morphism", differ from their uses within mathematics itself. In category theory, a "morphism" obeys a set of conditions specific to category theory itself. Thus, care must be taken to understand the context in which statements are made. == An abstraction of other mathematical... ==
 
user1804599
@FredOverflow No.
 
user1804599
It's a mapping between categories.
 
> Functors are represented by arrows between categories, subject to specific defining commutativity conditions.
ah
> In fact, what we have done is define a category of categories and functors – the objects are categories, and the morphisms (between categories) are functors.
 
user1804599
9:54 PM
Higher-order categories!
 
Honestly, most of that sounds like gibberish to me.
I should probably read "Head First Category Theory" or something :)
 
Yeah, I have no idea how that would be useful for Haskell.
 
Well, functors are things with fmap defined. Quite useful for a lot of things.
 
AFAIKS the haskell category is functions==morphisms objects==objects
 
(just for completeness)
I even like the zig-zag at the beginning :)
 
9:59 PM
I like how the productivity sky rockets compared to Java.
 
Productivity writing monad tutorials?
 
Well, at least you produce Monad tutorials at that stage ;)
 

« first day (1527 days earlier)      last day (3397 days later) »