« first day (1351 days earlier)      last day (3638 days later) » 

3:33 AM
18
Q: Answering questions which ask for effort guidance, not spoon-fed solutions

metacubedI have come across a few questions which were of the "help me get started" variety, but, the poster was not asking for spoon-fed solutions, just directions on how to get started. These questions are in direct contrast to "send me the codez" type questions. I think this behavior should be encoura...

Perhaps a possible solution is to redirect such questions to programmers.stackexchange.com. I've seen some similar questions like this there - newbie programmers asking for starting resources. It also seems that discussion-like questions (on-topic of course) are more tolerated there. In contrast SO requires the question to be problem-centered and reproduceable, and thus quite technical. — Ivaylo Slavov 20 hours ago
@IvayloSlavov I completely disagree with you. Please don't send newbies to programmers.SE, read the help-centre on programmers.SE before re-directing people there. — me how 20 hours ago
@mehow, I see, it is stated explicitly in the help center that this is off-topic there. This does not change the fact that there are such questions in programmers as I have personally seen some of them. Since it is explicitly stated they are off-topic, we should indeed respect the terms. So, I take my words back, do not go to programmers.stackexchange.com for such questions. Yet, I agree with the OP that guidelines like the described in the question need a place under the sun — Ivaylo Slavov 19 hours ago
@gnat, you must have missed my previous comment, where I already took my words back in writing. I never intended to make use programmers or any SE site as a "toilet bowl". I backed up my fist suggestion by questions I have seen in programmers which were of the kind the OP talks about, and were not closed or down-voted by that time (for longer than a day). — Ivaylo Slavov 8 hours ago
thanks to all who are too shy to vote down and close crappy questions polluting front page, they help us bring more of that
 
3:59 AM
If you ask me the site itself is misguided in what it should be; SO was for questions that had specific answers, Programmers was intended to have more opinion-based questions since most things in software development don't have straight answers... — Wayne M 4 hours ago
 
 
7 hours later…
10:52 AM
that was some outage...
 
 
4 hours later…
4:05 PM
27
Q: If I'm floating in space and I turn on a flashlight, will I accelerate?

Hello WorldPhotons have no mass but they can push things, as evidenced by laser propulsion. Can photons push the source which is emitting them? If yes, will a more intense flashlight accelerate me more? Does the wavelength of the light matter? Is this practical for space propulsion? Doesn't it defy the la...

at first I thought that was an Arqade.SE Q title when I saw it on the hot list
 
now now jimmy arcade doesn't have monopoly on odd question titles
 
user15026
@ratchetfreak Nah, not quite, but we do quite well in that department :P
 
4:20 PM
is sum over integers a monoid?
hrmm... I think so... though it might actually be a group
 
user41796
@JimmyHoffa I think all of us would look to you (or jozefg) for that answer
 
without negative numbers it's a group I believe, sum over positive numbers would be a monoid though I believe. 0 is identity, and it's associative (as well as commutative)
 
user41796
I barely understand monad. :-) I don't see the distinction that defines monoid instead of monad.
 
@GlenH7 they're totally different structures
 
user41796
ok, then I'm going to stay in my pseudo-happy place of pretending to understand only one of the terms.
 
4:34 PM
@GlenH7 monoids are actually easy and kind of neat, as are all magmas. Monads are a distinctively more complex structure

Magmas

Oct 24 '13 at 20:57, 16 minutes total – 11 messages, 2 users, 0 stars

Bookmarked Oct 24 '13 at 21:22 by Jimmy Hoffa

Read that, it's not a bunch of messages, it may make no sense but I'd wager if you take 2 minutes to read it, you'd find it does make sense (though you likely won't know what it's particularly useful for)
 
user41796
@JimmyHoffa Does make sense, but I wouldn't feel comfortable trying to classify things with it.
 
@GlenH7 closure -> Can you sum any two positive numbers and get a value outside the set defined as the set of positive numbers ? -> no therefore you have closure and are a magma
@GlenH7 associative -> can you sum 3 numbers the two on the right first or two on the left first and get the same number? -> yes therefore you have associativity: 1 + (2 + 3) = (1 + 2) + 3
@GlenH7 identity -> Do you have an element in the set that can be summed with any number in the set resulting in that number again? -> yes 0 is the identity element, add it to any other element from the set and it will be unchanged
and voila, closure, associative, identity, you have a monoid
 
user41796
ah, okay. Now I see the taxonomy a bit better
 
if you include negative numbers you get inverses -> Do you have one element for every element that when the two are combined get's the identity element? and for each element, it's also the inverse of it's inverse (so the operation is commutative in resulting in the identity element) ? yes -> where 0 is the identity: 1 + -1 = -1 + 1 = 0
when you get inverses it becomes a "group"
but monoids are much more common than groups
and monoids alone are quite useful because the identity means that you can combine things in such a way as to optionally effect them. if you want to not effect the current value of something in a monoidal structure, just apply the identity and you'll maintain the current value
 
user41796
I'm a dirty programmer. Immutability is a tad over-rated in my book. :-)
 
4:44 PM
it allows you to carry values through data pipelines by making the last steps in the pipeline identity if it's decided that they should just skip out. Actual uses: Things like when you have a resolution path that falls back through multiple resolution paths, as soon as you get a value, flip the rest of the resolution paths to identity and you'll carry forward your first succesful result.
 
user41796
Or perhaps I'm too much of an engineer and don't place as high of importance on preserving a particular value or state. The objects exist to be manipulated.
 
user41796
@JimmyHoffa See, that's a practical application I can understand... :-)
 
@GlenH7 there is no spoon object O_O
@GlenH7 aye, there are actually practical applications to monoids. They're surprisingly useful and common, more so than people realize - they rely on identity whenever they're concatenating strings and say in a function it's current state decides "Ahh I don't have anything to add to the string" and returns string.Empty -> that's the identity element for the monoid of concatenation over strings (they've closure, they're associative, and "" is the identity)
people do that all the time concatenating an empty string because some conditional tells them they've nothing to add to whatever value is already there, they just don't realize they're relying on the laws of a monoid when they do it
 
user41796
Can they fix problems like requirements being specified by folk with less business domain knowledge than the developer?
 
user41796
@JimmyHoffa I choose to abstract away that level of concern.... :-)
 
4:50 PM
@GlenH7 absolutely, start explaining monoids to the folks specifying those requirements and you won't have all those terrible requirements anymore, you'll have an identity element's worth of requirements... :)
 
user41796
I wouldn't mind some identity enforcement over the requests they make. "Oh hey, I want feature XYZ" gets buried within a completely different request.
 
user41796
And of course the main request is fairly trivial to describe and complete, but the buried, kinda-related request blows out the estimate.
 
user41796
Ah, today's cooking debate.
 
user41796
Beer can chicken.
 
user41796
What's the best type of beer to use when making beer can chicken?
 
4:53 PM
@GlenH7 for chicken -> anything thirst quenching. Yeungling would work well
red stripe
a lager definitely
 
user41796
I've got some maibock, some wheat, and some ale at home currently
 
wheat if you have to but it's not like sausage where you want to taste the beer, you just want the beer to keep the chicken tender
 
user41796
If I make the guinness cupcakes, I need to pick up some guinness
 
@GlenH7 Side note: guinness can be cooked into any pork dish. Goes perfect with pork for some reason.
 
user41796
Guinness is truly an Irish gift to the world
 
4:55 PM
Also Guinness in Corned Beef + Cabbage = win
but for beer chicken you want a lager
sam adams would be good
 
user41796
I'll probably roast two birds this weekend, so I'm willing to do some A | B testing
 
user41796
So a little bit of body and flavor to the beer, but not too much
 
user41796
I wonder how the pale ale I have would work with that then...
 
@GlenH7 that's my suggestion. With beer chicken again the point is to use the beers ability to tenderize meat and keep it juicy, not for flavor like when you throw it in a stew or sausage
 
user41796
I'm open to that suggestion. I think I used bud when I have previously made it. Which had left me wondering what things would be like if I used a beer that could impart flavor.
 
4:58 PM
@GlenH7 well give it a shot. I can't say I've used a strong beer with it, the idea just sounds a little off to me, but like you said, do some A|B testing. Use a sam adams boston lager on one, and a strong rich ale on the other
 
user41796
In the worst case, I've ruined half of the meal. Not necessarily a tragedy since I'll prepare more than is needed.
 
user41796
The maibock may work well for the strong, rich ale too. It's a pretty bold version that I have
 
user41796
@JimmyHoffa - I think you should tackle that Lisp -> C# question.... Just to play with the concepts involved in moving from functional to OO....
 
@GlenH7 I'd feel more comfortable about it if I knew AutoLISP at all. I suspect he has an extremely complex program if you consider it's used for spatial modelling of roofing trusses. Converting it to C# is frankly a messy and ill-advised idea, it's not the sort of thing C# is good and, LISP is a decidedly better fit because it's going to be a lot about dimensional equations, it doesn't fit an imperative mold well...
But to his immediate question of "should I write a rudimentary converter or manually port the code" I think I can at leas answer that: A converter would likely be quite a mess because the amount of difference between a LISP and C# is going to be pretty wildly large.
 
user41796
I'm of the opinion that programs generally can't survive a change in language form. Yes, in some cases, you can do a straight port. But the code you end up with is ... even more difficult to maintain than it was before.
 
user41796
5:09 PM
@JimmyHoffa That would give a pretty solid answer to the question, I think
 
@GlenH7 yeah but that's not always important, and wasn't specified as having relevance in that guys case. Many times some small tool can be ported automatically, and so long as it continues working it doesn't matter because it get's touched once every 3 years
@GlenH7 @RobertHarvey already wrote a better answer.
 
user41796
He got a stealth edit in there that I hadn't seen
 
user41796
The SO FGITW master at his finest....
 
haha, if his answers sucked instead I'd be more annoyed, but I wouldn't have written as good of an answer. I focus too closely on the technicals of things sometimes, miss the broader details...
 
5:29 PM
1
Q: How to manage a winforms application installed in many PCs connected to a single sql database?

Phoenix_uyI have a winforms application that connects to a single sql server 2012 database and is executed in many PCs of a company. I'm having several problems with some transactions inside the application, deadlocks and timeouts so the refactor idea comes to my head. Actually the app is using DbConnect...

^-- he needs some web scale sauce, I think he should get the sharding mongos.
Programming language which only allows imperative statements that are commutative is a very interesting concept. Commutative means that the order is irrelevant, sum is commutative because 1 + 2 = 2 + 1 -> If you wrote imperative code that was all commutative, the statements could be executed in any order and the result would be the same. The language allowing only imperative statements that are commutative means the runtime can execute things whenever
and the result will be the same
makes parallelism ultra simple because there's no race conditions when it doesn't matter which operations happen in which order
In mathematics, a monotonic function (or monotone function) is a function between ordered sets that preserves the given order. This concept first arose in calculus, and was later generalized to the more abstract setting of order theory. Monotonicity in calculus and analysis In calculus, a function f defined on a subset of the real numbers with real values is called monotonic if it is either entirely nonincreasing or nondecreasing. It is called monotonically increasing (also increasing or non-decreasing), if for all x and y such that x \leq y one has f\!\left(x\right) \leq f\!\...
This sounds like a question requesting a list of things, unfortunately with a list no answer is better than another, they're all just lists of options. As such the resulting content is not really helpful to people in the future because they can't know which answer has more relevant information. Voting to close, sorry. Also your question doesn't make sense, you claim to know when to use a decorate but ask when you should use a decorator. Either you know when people should use them or you don't; which is it? — Jimmy Hoffa 33 secs ago
@RobertHarvey --^
I disagree with your comment about it being answerable. His question doesn't make sense as it stands, and it is a list request. You say it's answerable without a list, but I don't believe it.
 
user55340
5:46 PM
I'm still meditating on @gnat 's request for a Real World meta post...
 
I think the questioner will not be pleased until he get's a list of every explanation, and even then won't understand it
 
user55340
0
Q: Looking for real world applications of the Decorator pattern

ProgI understand completely how to implement the Decorator pattern, and I also understand what it's intent is. The Decorator is used in one of two cases: As an alternative to subclassing - when there are multiple characteristics that an object can have, one could use inheritance in order to create ...

 
user55340
7
Q: What are 'real-world' programming projects like? Are they mostly about pulling and putting stuff in a database?

ProgI'm 18, a hobbyist programmer planning to do this as a career. I have read that most 'real-world' professional software projects are all about getting stuff out of a database, and making forms to put stuff inside a database. I have two questions regarding this: Is this true? Are 'real world' ...

 
user55340
I think that "in the real world" is about as meaningful as "as a programmer" here.
 
I've edited out the "List all the things" aspect of the question.
This is one of those cases where animal examples won't work. You know how they teach inheritance using animal taxonomies, but nobody ever uses inheritance that way? Same thing here. This is the kind of "gap in knowledge" that sites like Programmers are uniquely designed to fill.
 
5:56 PM
@RobertHarvey I don't know. I'm still confused by his "I know when to use a decorator pattern as you can see, but I'm not sure when to use a decorator pattern" -> That tells me whatever answer you give he'll say "I know that, but it doesn't help!"
 
It's always bothered me a bit that people say things like "Just use a factory pattern here." But why? Why wouldn't I just use an ordinary method? What are the compelling reasons for me to add this abstraction, and what problems does it solve that other abstractions do not?
 
retracted my close vote though. I'll let the rest of the community decide. I could still put it under "Unclear what you're asking" to be sure.
 
kdgregory gets it right in the comments, but doesn't bother to explain.
 
@RobertHarvey that's because people are just rebuilding the same program over and over and over, and they don't know why they do the things they do like that
 
That's right. I think they should know.
But you have all these people who lack some simple intellectual curiosity, who just want to paste the codez.
 
6:00 PM
@RobertHarvey yeah, but it's better that we accept they don't, and won't know. Attending to and accepting the reality generally gives better results than attending to an ideal that doesn't exist, or trying to achieve one that can't.
 
There are some who want to know, however. Who want a justification before they actually jump off the cliff. I'm one of those folks.
 
@RobertHarvey as am I, but when I work with folks and they say things like that "I just put the X here because that's how you do it" -> I just take it at face value and figure out how to work with their lack of interest in the deeper functionality at play
just pisses people off when you push them about that stuff because they don't realize there's any way to program other than by way of what they've read of what others do, and it's no fun working with people who are pissed at you
 
I think there's still some room on programmers for questions like "But why? Why would you want to do this? Don't just say 'because that's how it's done,' because you're addition additional complexity, so the benefit has to outweight the complexity."
 
@RobertHarvey I wouldn't disagree with you, but I don't think that's the question that dude is asking. He appears to be asking for us to implant knowledge in his brain because he's already got it but can't find it
 
You don't think it's an "animal gap?"
 
user55340
6:06 PM
(I'm leaving my close vote on it until I see that its actually being answered in a good P.SE style (with good explanations) rather than people doing code dumps with a sentence or two...)
 
@RobertHarvey Nope. I think it's going to turn into an argument because the guy has an idea in his head that he can tell isn't right, but he won't let go of it to fit the right one in
 
In other news, I need to do what kdgregory says in her comments, because I'm now curious what the Decorator pattern has to do with Java I/O streams.
And why it might be useful there.
 
@RobertHarvey I suspect it uses inheritance as data-interception to commit data transformations (binary data -> unicode string, and vice versa)
each layer of inheritance commits another layer of transformation on the data as it goes into or comes out of the underlying stream being decorated
(I am speaking completely out of my ass; that would just be my guess. I know zero about Java's IO)
 
So it's faux inheritance that could not otherwise be used there?
 
@RobertHarvey oh yeah decorators don't use inheritance that's right. Yeah basically
 
6:09 PM
I always thought of the Decorator Pattern as metadata for methods or objects. Like Attributes are in C#.
 
@RobertHarvey I always just think of it like a mock object, pretends to be another object which it has as a member, and it only pretends for the purpose of intercepting the data before it hits the member which it's pretending to be
Like a proxy
 
That sounds like AOP.
 
user55340
AOP tends to be a bit more runtime than compile time.
 
public class UnicodeStreamReader { private BinaryStreamReader _streamBeingDecorated; public string ReadToEndOfLine() { ...} }
 
user55340
I look at the Decorator as a Wrapper... it wraps a class that you can't extend directly through inheritance (for whatever reason) and makes a new one with the additional methods that you want.
 
6:12 PM
it has a binary stream reader member, and it decorates it with conversion from binary to unicode
 
user55340
Some discussion on it at C2: c2.com/cgi/wiki?DecoratorPattern
 
that is I suspect what Java's IO system is like if it's very decorator based. .NET's is very much inheritance based but again doing decoration basically by inheritance instead of composition
 
@MichaelT That sounds like composition.
 
user55340
> The difference that I see between a DecoratorPattern and subclassing is that you can decorate any class that implements an interface with a single class. Say I wanted to give myself a java.util.Map that printed a message whenever I added or removed a key. If I only ever actually used java.util.HashMap I could just create PrintingMap? as a subclass of HashMap and override put & remove. But if I want to create a printing version of TreeMap then I either create PrintingTreeMap? (which has almost identical code to PrintingMap? (which should itself become PrintingHashMap?)), or I create a Map
 
@RobertHarvey it is
decorators use composition because inheritance isn't possible (for whatever reason; usually because the methods you want to intercept are not virtual)
 
6:14 PM
Then why call it Decorator, if it's simply composition?
 
user55340
Because it has to have a Name.
 
It does have a name. Composition.
 
@RobertHarvey because a decorator is composition for a specific purpose: To specifically behave like a particular class for the purpose of interception/proxy/extension of that class
 
user55340
Thats a verb... not a noun.
 
Composer, then. :)
 
6:15 PM
you can do all kinds of things with composition other than decorate types
decorating them is just one of the things composition can be used for
 
If it's what you guys say it is, Decorator is a terrible name.
 
user55340
-1
A: How is the Decorator Pattern actually used in practice?

Silviu BurceaI have used this pattern to decorate some global state of my application. It was actually changing some (default) configuration at runtime.

 
user55340
See? thats what I was worried about.
 
@RobertHarvey it makes sense to me, a decorated christmas tree isn't altogether different from a christmas tree, it's just got extra shit, so it is with a decorator class. A UnicodeStreamReader isn't altogether different from a BinaryStreamReader, it's just got extra shit in front of the stream
 
Ehm, you can decorate a class with attributes too (you can even make them look a lot like Christmas ornaments), but I doubt that's what you're talking about here.
 
6:18 PM
@RobertHarvey attributes aren't functionality, decorators add functionality not just metadata (which is all attributes are)
UnicodeStreamReader adds the functionality of going from byte[] to string over the basic functionality of going from stream to byte[] that a BinaryStreamReader would have
 
user55340
0
Q: Decorating a String in Java

Mark LuttonSuppose I want to use the Decorator pattern to add functionality to the java.lang.String class. (Just for example, to add a toRussian() method.) String is a final class. Is the following the only way to do it? class DecoratedString implements Serializable, CharSequence, Comparable<Decora...

 
user55340
You can only use a Decorator on a class that you can't extend.
 
C# Attributes could add genuine functionality if they weren't so limited. You can place an attribute on an ASP.NET MVC method that changes it's behavior if the person is not logged in. So for all intents and purposes, it's a decorator. The only problem with them is that you can't pass them runtime parameters.
 
@RobertHarvey no they couldn't.
:)
 
Nyah nyah.
 
6:22 PM
attributes are literally data, you can create functionality based on them, but they truly can't implement functionality anymore than an integer can implement functionality
 
You can execute code in an attribute.
 
"1" is not a function, it's a value, so it is with attributes
@RobertHarvey Nope.
 
Really.
 
They're compile time metadata, you can execute code based on an attribute
code that uses the data in an attribute, but attributes are literally data
You can add methods to an attributes class, but calling one of those methods is executing a function with the attributes data manually. The attributes don't have any kind of automatic function application
 
Yeah, I guess you're right about that.
So Decorator is a specific application of composition.
 
6:26 PM
@RobertHarvey Right.
 
And all of these Stream objects in .NET are just decorators?
 
@RobertHarvey they use inheritance in .NET
I suspect the guy is saying in Java's IO they use composition instead
 
Then Decorator is just one of those 64 cent words that does mean something but... PFFT.
I'm with the guy asking the question.... What's the big deal?
 
@RobertHarvey There's not a big deal. It's one of the simplest most common patterns and of very little interest
I suppose it would be confusing if you thought it was a big deal, but it's not.
 
Let me see if I got this right... Decorator is a special case of Composition. It wraps a class to change its behavior. You use it when Inheritance is unavailable to you. That's all, thanks for playing.
 
6:29 PM
@RobertHarvey bingo.
 
[sigh]
Think I'll go learn functional programming, and get a new job.
 
@RobertHarvey please do, then hire me when you get it. I could so go for working somewhere with FP...
@RobertHarvey I guarantee you've done exactly that before. Decided "Well I need this functionality, but I need a little more, but I can't inherit from the class, shit what do I do... I'll just wrap the class in another class and add the functionality on top of it that I want."
 
Many times.
 
@RobertHarvey and now you have a name for doing it. That's all. Like I said, it's a common pattern and not something worth a bunch of hoopla.
 
user55340
@RobertHarvey I hear rumors of clojure / scala shops on occasion.
 
psr
6:31 PM
I just answered the question. It's not by any means a brilliant answer but it took less time than the discussion.
 
@psr haha fair point
 
I put an upvote on it.
 
@RobertHarvey +1 to you for removing the part saying "PLEASE DON'T GIVE ME EXAMPLES FROM JAVA'S IO" and +1 to @psr for giving exactly the answer the dude explicitly asked not to get. That's awesome.
"PLEASE DON'T EXPLAIN WHAT I'M ASKING FOR AN EXPLANATION OF - I ALREADY GET IT, JUST EXPLAIN IT. THANKS" -> "The thing you don't want explained works like X"
dude's probably fuming reading your answer now @psr
@RobertHarvey now I'm just waiting for him to roll back your edits heh
 
psr
@JimmyHoffa I didn't read the original. That's pretty funny. I thought of examples that were more specific to an application, but then you have to explain the application, and that's a pain.
 
> Dammit. I'm trying to make the case that the question is a productive one, and you post an answer like this?
heh very nice
 
psr
6:37 PM
@JimmyHoffa In light of all those edits I think you're probably right.
 
Yeah, this was one of those "odd sundays during a full moon" questions. Ultimately, his frustration is probably the same as mine: Decorator is not all that interesting.
 
user55340
The decorator falls into one of those "I've been doing it all along, and thats what its name is... its just the right solution in some spots and rather boring in most."
 
And he thinks it must be profoundly important because it's... well, a pattern. With a name, a class diagram, and evahthang.
 
user55340
The Java Number classes (Double, Integer, Float, etc...) are Decorators too... because you can't extend a primitive.
 
Gawd.
 
psr
6:39 PM
@RobertHarvey It kind of is - it's just so basic that almost everyone would use it even if they never heard of it.
 
I can't tell you how many times I've wrestled with something having some highfalutin name, only to realize... "Shit. That's all this is?"
I worry that's what will happen to me when I finally learn Scheme.
 
psr
Which is not to say that nobody ever does LineBreakFixingEncryptingZippingStream classes - they do.
 
@RobertHarvey yeah I suspect someone spoke about the decorator with fanboy glamour to him and he grew confused of it. At one point I had somebody speak to me of the fantastic repository pattern and how amazing it is doing it right, you just gotta brush that shit aside - many mundane things are a religious experience to people the first time they grok them
 
psr
@JimmyHoffa Compared to doing these things badly it usually is a big difference.
 
@psr true heh, the things people do instead of decorators are probably very creative
 
6:44 PM
ffs, why didn't they just call it "Wrapper Class Composition?"
 
@RobertHarvey Interestingly I would wager that people know what a decorator is far more commonly than they know what "composition" is
 
Even though you need to know what composition is to understand decorator.
 
@RobertHarvey yes, but as a term it's uncommon and people rarely use it. People almost always use "encapsulation" instead - which doesn't mean the same thing but they refer to it because it's the mechanism with which they do composition without realizing it's purpose is composition
People think about encapsulation for controlling scope and access, they don't realize they're using it to compose functionality between separate classes
...I need to wrap my maybe monad in a writer monad. Shazbot. I take that back, I don't need to, but I would like to...
 
psr
@JimmyHoffa A Decorator! Answer the question - he'll love it.
 
Maybe it's a Writer monad.
 
user41796
6:53 PM
17 mins ago, by Jimmy Hoffa
> Dammit. I'm trying to make the case that the question is a productive one, and you post an answer like this?
 
user55340
I'm waiting for prog to ask a question about monads...
 
@RobertHarvey That's actually correct. It'll be a MaybeT Writer -> maybe it's a writer, but it also might be nothing.
 
user41796
@MichaelT Isn't he working hard enough as it is?
 
psr
I'm pretty sure it's a writer of borderline talent trapped in a monad
 
Is Maybe the strongly-typed, functional equivalent of Nullable?
 
6:55 PM
@psr nah, it's going to be a writer of a transaction log kind of. Maybe your transactions are successful, if so the writer will have written a log of them for you to send to others to execute, maybe your transactions are not succesful, at which point no writer, no anything just empty failure.
 
psr
My version makes a better screenplay though
 
@RobertHarvey It's like that, yes.
 
Ah, I see. Another lofty concept slayed.
 
@RobertHarvey almost. That's the maybe type but the maybe monad has explicit purpose and behaviour you don't see from nullable
 
[snickers that Haskell actually has something even remotely resembling null]
 
6:57 PM
The difference between nullable and maybe is that nullable has a null value which can be dereferenced and throw an exception, maybe has a null value which is a value and as such will never give error from dereferencing.
 
Cool.
 
user41796
@RobertHarvey Null is the identity function for the complete set of Haskell.
 
[not sure if serious]
 
@RobertHarvey Sure it does, it's called bottom or "undefined"
from ghci:
Prelude> undefined
*** Exception: Prelude.undefined
that is your actual null value
the maybe type has Nothing which is a value that is not null, but has no value.
 
Shades of VB6.
 
psr
7:00 PM
Under the covers Haskell stole everything from VB6
2
 
user41796
@psr that's just slander
 
@psr Haskell's much older than VB6, clearly VB6 stole everything from Haskell.
 
Except that in VB6, it's merely a way to have multiple kinds of null. Makes for interesting conversations like
if (not myObject is nothing and myObject.someProperty <> null)
Or something like that.
 
user41796
Foolish language designers. They should have known that there is only Null.
 
VB6 had nothing, null and empty string. .NET had mercy on us and gave us String.IsNullOrEmpty.
(if you can legitimately call that mercy).
 
user41796
7:08 PM
"You get two checks for the price of one!"
 
user55340
As an after thought, this might have been duped to Newbie question about Decorator design pattern. Please remember to search first when asking a question - one component of the down vote mouse over reads "This question does not show any research." — MichaelT 10 mins ago
 
user55340
7:34 PM
Mods, I'm going to intentionally fail (maybe) this review audit so that I can actually get a review link. Please don't think I've gone off my rocker.
 
user55340
0
Q: Bug in close vote review

MichaelTSo I was doing some reviews and got this one. I clicked the 'close' button and was shown this: Note that its May 16th, not April 30th and its a review based on this question I was more expecting to see the happy review message rather than the close screen. Closing the panel and reopening it...

 
user55340
@GlenH7 should have gone for the "core rope memory..."
 
user55340
Core rope memory is a form of read-only memory (ROM) for computers, first used in the 1960s by early NASA Mars probes and then in the Apollo Guidance Computer (AGC) designed and programmed by the MIT Instrumentation Lab and built by Raytheon. Contrary to ordinary coincident-current magnetic core memory, which was used for RAM at the time, the ferrite cores in a core rope are just used as transformers. The signal from a word line wire passing through a given core is coupled to the bit line wire and interpreted as a binary "one" while a word line wire that bypasses the core is not coupled t...
 
user55340
 
user41796
@MichaelT I'll take my advancements as I can get them... :-)
 
7:43 PM
@MichaelT I don't think that's a review audit. It has a score of -2. Review audits usually hide the score, setting it at zero.
 
user55340
It was an audit.
 
user55340
There are a number of bugs there... something went glitchy.
 
So you're saying that it's a bug because it didn't fail you immediately or pass you immediately?
 
user55340
Its a bug because I couldn't click close, that it was showing '?' for the close reason.
 
7:51 PM
Ah, I see.
 
8:02 PM
The fastest way for you, personally? Let someone else do the conversion. Then you don't need to put much effort in at all, and that's very quick in terms of your personal time. (The Java community is much keener on being explicit than the Ruby-on-Rails community; what you're looking for may not exist in a way that you'd want to touch with a barge pole for production code.) — Donal Fellows 5 mins ago
@DonalFellows I think you underestimate the quality of a good barge pole. — Jimmy Hoffa 48 secs ago
 
user41796
@JimmyHoffa My afternoon is being fueled by the Rap & Hip Hop Pre-Game channel. My commentary would have been a little stronger... :-)
 
@GlenH7 heh. It is 2 on a Friday isn't it... I forgot. Doesn't matter though, tomorrow is another Suck It Saturday which I have to be in the office for...
 
user41796
Sorry to hear it
 
user41796
I can recommend several pandora channels to help the time pass more quickly
 
user41796
today has definitely been a full enclosure headphones day
 
8:06 PM
@GlenH7 eh, it's just a big event so everyone's in the office to monitor the systems (4 saturdays a year we have these events) - being that it's just monitoring people don't do actual work. Last one I watched Men In Black on Hulu on one monitor with perfmon and one of our instrumentation service monitors up on the other monitor...
so long as nothing breaks it's just a boring way to spend a saturday
 
user41796
could be worse then
 
yeah
I'll probably bring in my laptop and write some more Haskell. See if I can't get my modular-object-definition to fit into a monoid O_O
 
user41796
Just keep it disconnected from the mains lest it create a space time continuum wormhole
 
@GlenH7 what operation could you combine with JSON to create a monoid? There's a thought.
 
user41796
See, I'm silly. I like my systems to stay up and stable. I don't like concepts that create rifts in space-time.
 
8:12 PM
@GlenH7 just because someone says don't cross the streams doesn't mean you actually shouldn't cross the streams. It's really more of a guideline than a rule.
 
psr
@MichaelT Oh no you didn't. Suggesting a dupe of a question with "Newbie question" in the title. That's a step away losing it and making all your future close votes as dupes of "how to explain programming to an idiot".
@JimmyHoffa concatenation
 
user55340
> So what I'm asking for is a concrete real world example of Decorator, in a practical, real-world scenario, with a brief explanation of the benefits of using a Decorator pattern there over other techniques.
 
user55340
> Without having read about this pattern, if I needed to change behavior at run-time for individual objects, I would have probably built some methods into the super- or subclass to enable/disable said behavior. Please help me really understand the usefulness of the Decorator, and why my newbie thinking is flawed?
 
@psr usually a safe bet and yes I think that would work... sum like operations usually fit monoids well
 
psr
What operations would make JSON a vector space? Time to get real.
 
8:15 PM
@psr what's a vector space? O_o
 
psr
(from Wikipedia): Associativity of addition 	u + (v + w) = (u + v) + w
Commutativity of addition 	u + v = v + u
Identity element of addition 	There exists an element 0 ∈ V, called the zero vector, such that v + 0 = v for all v ∈ V.
Inverse elements of addition 	For every v ∈ V, there exists an element −v ∈ V, called the additive inverse of v, such that v + (−v) = 0
Compatibility of scalar multiplication with field multiplication 	a(bv) = (ab)v [nb 2]
Identity element of scalar multiplication 	1v = v, where 1 denotes the multiplicative identity in F.
 
@psr so for starters it's a group...
 
psr
It's got enough axioms that a lot of things are covered, yes.
 
well under addition it is
Functions from any fixed set Ω to a field F also form vector spaces, by performing addition and scalar multiplication pointwise. That is, the sum of two functions f and g is the function (f + g) given by

(f + g)(w) = f(w) + g(w),
so there's a distributive operation and an associative operation which may not be the same ones
yeah there's way too many axioms there and I don't even know what use half of them give... I'll stick with Monoids. Monoids are easy.
how about member selection over JSON, is that a monoid? hrmm no where member selection is *: a * (b * c) = (a * b) * c can't hold because the hierarchy context...
actually... I think I do know of a way to make member access monoidal if it returns a member accessing function instead of the actual member... it would be function composition over the set of all JSON member accessing functions
but then function composition over the set of functions is a well known monoid
a . (b . c) = (a . b) . c
 
psr
8:33 PM
@JimmyHoffa super well known. The grocery clerk wouldn't shut up about it. a,b,c yeah yeah, there's a song about it.
BY the way, debugging 2 systems trying to encrypt the same string the same way and not getting the same result - not that fun.
 
@psr You jest, that is clearly the funnest. Sounds like an encryption algorithm bug: Encryption algorithms must be context-free, guessing you've got one that includes CPUID or some shit in the algo
alternatively - they're pulling their encryption key from a store and the machines are pointed to different stores or versions of the key. (cert store on the machine, key in a database and they're pointed to different ones, key in the registry...)
 
psr
@JimmyHoffa Two separate implementations in different languages. Not totally sure how each one handles all the choices of, as you like to say, bits and bobbles.
In the guts of a lot of the algorithms you can vary a lot of little things.
 
@psr yeah, order of operations errors are really easy in algos like that...
@MichaelT @GlenH7 what are some quick claculations that show broken precision in float/double/decimal/etc
 
9:06 PM
Fee Fye Foe Fum, I smell the blood of a type systum.... PHP doesn't have one, hand implementing your own over top of typeless languages ends up with a type system that is only validated at runtime (aka you only find out the type errors when they happen) is a well worn path to insanity. — Jimmy Hoffa 7 secs ago
 
@JimmyHoffa ((0.1 + 0.1) + 1.0) == (0.1 + (0.1 + 1.0)) is false in many languages. So much for associativity.
 
@amon hrmm, it works in .NET...
 
that "Decorator" guy really puzzles me. I've seen probably thousands dupes - here, at SO, MSO, TWP but they all felt different. They felt genuine. It could be as close to dupe target as it gets, but I always felt that asker just didn't know dupe exist. This time it's other way round...
..as if guy finds a question, repackages it to obscure similarity and reposts. I've never seen anyone doing so, at least not as a serious, long term, focused effort (I recall isolated cases of conscious deriving, like that toilet flush dupe at TWP, but these all were more like a game). This guy makes me feel paranoid!
 
@gnat It's ok! You are paranoid, so the feeling is appropriate!
I'd be more scared if you didn't feel paranoid, would make me wonder how paranoid you could get before noticing it :D
 
user55340
9:24 PM
@JimmyHoffa You're seeing some rounding there... ideone.com/hDUeMU
 
is an interesting comment, a perspective people coming from the standard OO/imperative worlds would never see
 
user55340
Though the assocativity thing is not a problem.
 
user41796
> float a = 0.15 + 0.15
float b = 0.1 + 0.2
if(a == b) // can be false!
if(a >= b) // can also be false!
 
user41796
That ought to do it
 
@GlenH7 nope. @MichaelT's does though
 
9:30 PM
I have a quick question about Singletons.
 
it's odd though, Console.WriteLine(0.1f + 0.1f + 0.1f) prints 0.3, but Console.WriteLine(0.1f + 0.1f + 0.1f == 0.3f) prints false
 
Jon Skeet goes over 4 different ways to make them here: csharpindepth.com/articles/general/singleton.aspx
 
user41796
@JimmyHoffa I think you are benefiting from some hidden truncation there
 
@GlenH7 yes, likely.
 
user55340
2
A: Is this a good way to compare two numbers?

MichaelTUnderstanding the decimal format and working with a properly crafted number, it is not difficult to find two values that have differing values. using System; public class Example { public static void Main() { double[] values = { //12345678901234567 0.100000000000000...

 
9:31 PM
But what prevents someone from just using a static class with some public static variables to store their global state?
Why do you have to instantiate a class to get it done?
 
user55340
I've got some code in there that I found that shows some of the internals of the float.
 
@RobertHarvey That's how I do it. In C# singletons are generally not needed so long as you write your code right
 
user55340
@RobertHarvey Its difficult to pass a Static class around.
 
@MichaelT yeah but if you make an instance class with static state in it, tada....
 
user55340
And you also can't extend a static class...
 
9:32 PM
The singleton stuff is more about people not understanding thread safety than anything to do with the value in the pattern
@MichaelT but you can extend an instance class with static state in it. java can have static state in an instance class, right?
 
user55340
or a class that is just statics. Well, you can, but you can't override the static methods in some languages.
 
user55340
Singletons are horribly misunderstood and misapplied - often by people who want to stash a global variable in there.
 
@MichaelT yeah, you may not be able to override the static methods, that's true... but you wouldn't write a static method that would have any value in being overriden in a sub-class, you should make that an instance method then (it can be stateless, and use the static members in the class, but an instance method all the same)
 
user55340
I've written stateless 'singletons' so that I could pass something around, provide an interface to the methods, and be able to extend an abstract base class.
 
Frankly I've lost all sight of the purpose of a singleton, it's been a very long time since I created one, I'm just aware of the threading situation anytime I touch something static... Beyond that I haven't in years felt like "O I should create a singleton here"
I just make shit static and put appropriate threading-access-control over it...
 
9:38 PM
SE Unplugged, LP record, released May 16, 2014 — gnat 1 min ago
 
@RobertHarvey Do you feel you understand singletons better or worse now? :) I know I feel I understand them worst than I did years ago... I used to have a sense of what they were used for, I don't anymore...
 
Global variables... It's yet another workaround for a language deficiency (in Java).
 
user55340
@gnat about the Decorators guy... he's young. He's trying to understand all of modern software development in one pass, without working from the fundamentals... trying to skip ahead to the "build big software" and "neat games". He reads something, doesn't understand it, repeats it and asks for it to be explained in concepts he understands. Thus the nature of the dups.
2
 
user55340
The questions are often in the form of "I don't understand this thing I read over here, explain it to me"
 
9:42 PM
@MichaelT well that's what I thought at their first dups. Until these started piling and I noticed the difference (or imagined it)
 
user55340
I feel sorry for the TAs and professors when he gets to college... "Why didn't you use a Decorator pattern there instead of just wrapping it in another class?" - or "But I read you shouldn't do multiple inheritance and instead use scala" (when the assignment is on multiple inheritance in C++)
 
@gnat That's Tim Post still recovering from the residual effects of mercury poisoning.
 
@RobertHarvey oh yeah and instantiation -> I use static constructors for that shit because the .NET runtime automatically runs that once and only once and with a lock. It is dangerous though if you aren't totally aware of how it works, static constructors can actually put you into a deadlock oddly.
public class A {
    static B _myB;
    static A() { _myB = new B(); }
    public string GetString() { return "string!"; }
}

public class B {
    static string _myString;
    static B() { _myString = new A().GetString(); }
}
^-- C# static constructor dead lock
(if memory serves)
 
Ouch.
 
@RobertHarvey looking at his article, the fourth version he does is what I always do for static state (more or less).
 
9:51 PM
public sealed class Singleton
{
    private static readonly Lazy<Singleton> lazy =
        new Lazy<Singleton>(() => new Singleton());

    public static Singleton Instance { get { return lazy.Value; } }

    private Singleton()
    {
    }
}
How is this not an infinite loop?
 
@RobertHarvey the member is static. First time you touch .Value the static member gets a value populated. Being static the second time you touch .Value, it's already been populated so it doesn't execute that construction again but rather gives you the populated value.
@RobertHarvey I don't really care for that approach, it uses an implicit condition in the Lazy<> objects logic for instantiation as the exit condition for it's recursive loop
 
Yeah, it seems to assume a lot of hidden knowledge.
Of course, you could treat it as write-only code.
 
Heh at the bottom he says he prefers #4 which is how I do it. Got the skeet seal of approval
 
10:16 PM
the free "look inside" has a ton of content, even goes over Haskell and Monads and then shows how to translate them to C#. Interesting
Was just curious if such a book existed, sure enough...
 
10:34 PM
There's a library that accompanies the book, available for download on the Wrox site.
 
10:45 PM
@RobertHarvey yeah, and it's probably just as nasty as the crazy code I hack'n'slash together
makes perfect sense if you're a haskeller, but to anybody else reading it you'd think it should be namespaced We.Come.From.Planet.Quux
 
user55340
Ohh! I'm gonna get ars'ed.
 
user55340
@ampt you might get some too...
 
@MichaelT so never going to happen to me
@MichaelT what's the Q?
 
user55340
 
@MichaelT holy crap the number of answers O_O
 
user55340
10:59 PM
@JimmyHoffa Part of that is from a merge...
 
user55340
 
psr
I downvoted the current question when it was asked, on the basis that you could nothing at all about programming and you should still be able to figure out the answer. I think 20 answers should cover it pretty thoroughly.
 

« first day (1351 days earlier)      last day (3638 days later) »