This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!

Winston Gutkowski

+ Follow
since Mar 17, 2011
Winston likes ...
Eclipse IDE Hibernate Ubuntu
35 years of computing, from junior COBOL nerd to sysadmin for Sun...with a lot of DBA and modelling in between. Resistentialist. Beer lover. Fat cyclist. Bridge Player (fanatical, but mediocre). Trivia buff. Collector of oddities. Liberal (in the old-fashioned sense; but still ABC - Anything but Conservative).
Girvan, South Ayrshire, Scotland
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Winston Gutkowski

Juan Bauer wrote:I fixed it. Is there a way to edit or remove post?

No need. And you never know, someone else might find it useful. :-)

1 month ago

Biniman Idugboe wrote:I do not understand the description at all. I will very much appreciate it if somebody can simplify it.  What exactly does the fork( ) method do?

This is not meant as a put-down, but if you don't understand the explanation, you may not be ready for it (yet).

It's also quite rare to want to do this yourself. Coming from C, I understand the basic concept, but I've never used the method myself in Java.

Hope it helps.

1 month ago

Juan Bauer wrote:Can someone point me in the good direction?

Yes. Create a Comparator to sort your objects in whatever way you want, and then use Collections.sort(Comparator).

Hope it helps.

1 month ago

Cristian Gabriel wrote:I have a question about how I should learn, or to be more which order should I learn those concepts.
- Focus on coding, more complex problems in order to familiarize myself with Java and those little tricks from every language?(and then the other choices?)
- Focus on GUI?
- Continue playing with Android Studio(I simply love it) and build more complex apps since this means more Java code?
- all of these?

I'm probably the worst person to be answering this question, since GUI programming bores me to tears.

I'm an application bod. Always have been, always will, which means that problems are what get me up in the morning, not worrying whether I've got the right shade of crimson on my 'Stop' button or where I'm going to put it on a screen.

For me, algorithms and structures, understanding how collections work, or how to best encapsulate database transactions; Dijkstra's (and others) "shortest path" and "shunting-yard" solutions; how solve the "traffic light" (or bigger) network problems that involve real objects interacting in real (or the shortest possible) time.
That's what rattles my cage.

I don't know if it helps, but it made me feel better. :-)

And kudos to you for wanting to learn. +1.

1 month ago

Deja Quavern wrote:The teacher says that is almost expected to have a stackoverflow with a fixed pivot array. What is meant by that and how one is supposed to write performance tests in that case?

Do you understand how a fixed pivot qsort works? ie, what the "fixed" part means.

Many algorithms, but especially "arrangement" ones, can be "defeated" if one takes a smart guess at how they work. Quicksort uses recursion - ie, a method calling itself - as do many sort algorithms, and recursion takes up space for each new recursive call (usually called recursive "depth"). And many languages - Java included - have limits on the "depth" they allow, which will probably be far less be far less than the number of items you could possibly sort.

Therefore, if you know how quicksort chooses its pivot, it's possible to create a Machiavellian set of items that will blow almost any stack limit - although these days I suspect the set size would have to at least a million (I remember when it was 65,000 and, in some older languages, 256).

Pre-shuffling reduces the likelihood of ever getting such a sequence - and also makes it virtually impossible to predict a "defeating" sequence - but it doesn't prevent it completely; so it is still possible for quicksort to be genuinely defeated by an "unlucky" set of items; but the odds against it happening are astronomical.

Hope it helps.

2 months ago

Brett Gross wrote:I'm trying to create an object array bugRacing, from an abstract class, Bug. But it keeps saying the constructor is undefined.

I suspect you have a lot of problems going on here, and this is just the one that has come up first.

1. You appear to have written a fabulous amount of code without (a) compiling it, or (b) testing it.
Swing code is notoriously "fiddly", so that's just asking for trouble.
A good rule of thumb is to compile every 10 lines of code you write AND after every method you complete. I suspect if you'd done that, you wouldn't be having this problem - or if you had, you might be able to work out the cause for yourself.

2. What is a GridPanel? I suspect its a class you've been given that encapsulates a grid of images, but I'm no Swing expert so I could be wrong.

3. You have an incredible amount of repetition in your code. Lines 138-181, for example, do exactly the same thing 9 times with different 'bugs'; same with lines 196-238.
I presume you know how to write methods, so how do you think you might solve that?

Hope it helps

2 months ago

Gayathri Gayu wrote:Sorry its my mistake. I haven't posted the entire code.

Well, it seems to me that, even if you were using it correctly, you don't need join(), because your loop - at least up to line 18 - appears to be replacing every third ',' correctly.

And that means that when it's finished, you will have an array with the correct characters already in it, so you can create a new String with:
new String(ch);

No need for join() at all - which, to be honest, is probably not what you wanted anyway.

2 months ago

Tim Holloway wrote:Now THERE'S one I haven't heard of in a long time! Actually, I don't know about reading as such, but they're good for implementing FIFO caches. Push one in, the one before it (the oldest one in the ring) pops out. And around they go!

It was suggested as a list implementation in the 2nd book I ever read about C, back in the late 80's.

As a fun exercise I wrote a forward linked list in Java based on an "anchored" Ring, that requires almost no effort to synchronise.

2 months ago

Tim Holloway wrote:You can make any of the Collections classes thread-safe, if I'm not mistaken by adding a qualification to your definition.

Hmmm. AIR, the 'synchronised' methods in Collections are a bit brutal; but if that's what you need, they certainly work without any extra "design".

@M Burke: however, if that's what you want there are two SkipList implementations that might be better, since skiplists tend to be very "concurrency-friendly": ConcurrentSkipListMap and ConcurrentSkipListSet.

I'd also add one other Collection type, familiar to fans of Wagner: A Ring or Cycle - ie, a collection that starts recycling elements after you read the "last" one. While they're usually associated with Lists, it's not a requirement.

2 months ago

Junilu Lacar wrote:What really matters when you're refactoring is that software is easy to work with.

True. And I was weaned on the "principle of least surprise".

At the end of the day, the difference between a boolean wrapper and a binary enum wrapper is, as you say, probably down to taste.

But I still like Liutauras's idea of an "inquirable value".

2 months ago

Junilu Lacar wrote:You just say "Is the lamp on or is it off?" That should be what informs your API design to make it more natural and intuitive.

I suspect that part of the problem is the limits of language. A "State" could be almost any of the things we've been talking about, and therefore only works in context, which is why Lamp.State works better for me.
I also take your point about intuitive. A Lamp "feels" like an object, yet we've been dealing with it as a value since the only thing that concerns us is whether it's on or off. We haven't been counting "lamps" as such, but the number of ON's.
That said, if we have two lamp variables, 'downstairs' and 'upstairs', it would seem odd them to be '==' simply because they're in the same state.

About the only thing I've worked out so far is that I prefer an enum to a boolean. :-)

2 months ago

Junilu Lacar wrote:

salvin francis wrote:Hmm... I still think it should not be called Lamp

I agree, an enum with ON/OFF values should not be called Lamp.

Why not? Your Lamp class is essentially a boolean with methods that convert its "state" into English.

And if (and for as long as) that's ALL it is, I prefer Liutauras's Lamp enum; although admittedly, I might call it Light or Bulb.

I admit it's unusual, but as long as a Lamp is essentially a value, I think it's the cleanest and most minimal way of defining it.

The only question then is then whether you might ever want to
(a) Add more fields.
(b) Subclass it.
And if you do, I'd say you're changing its definition to something that isn't a value any more.

2 months ago

Junilu Lacar wrote:Absolutely. Those other examples you gave don't translate naturally to true/false. However, ON/OFF, YES/NO, CHECKED/UNCHECKED, SELECTED/UNSELECTED, these translate naturally to true/false...

OK, I see your point. I'm not sure I agree because in three of those cases the name of the value supplies a contextual meaning for which you would otherwise have to provide a method.

However, I will definitely have to mull it over. :-)

2 months ago

Junilu Lacar wrote:My final vote would still go to a boolean lit variable in a Lamp class.

Question: If, instead of ON/OFF this was some object that could be LEFT/RIGHT, or UP/DOWN, or DEMOCRAT/REPUBLICAN, would you feel any differently?

I guess what I'm trying to find out is if there's any scenario in which you'd choose a two-element enum over a boolean? And if so, why?

Fun discussion. :-)

2 months ago

Junilu Lacar wrote:I would argue that in this case, there is no need for that kind of flexibility. Again, that makes me think that we're on the edge of falling into the speculative design trap.

Well on that basis, Liutauras's Lamp enum is the best of all.
It's certainly the most compact, deals only with values, and only requires one method.

It doesn't "feel" right though. But maybe it's just me.

2 months ago