Elaine Byrne

Ranch Hand
+ Follow
since Jul 07, 2017
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
9
Received in last 30 days
0
Total given
67
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Elaine Byrne

Greetings Rishal. Does the book encourage use of a particular coding language (e.g. Python) for putting the algorithms into action, or is it language-agnostic?
Thanks Tim. I had checked that all 7 are needed, and for some reason that actually does include 'scratchpad' (though not 'examples'). I do want to read docx, so need the ooxml's. Good to know that what I'm doing and the end size does not sound outlandish, though
1 year ago
Hi - my interpretation/paraphrasing:

First case: The compiler sees the argument 56 as a primitive literal, and I think the default is int (rather than e.g. long or short). Therefore it looks for an overloaded version of the method that has primitive int as parameter type, i.e. signature public void fly (int x), where "x" can be replaced with any variable name. Since there is none, it tries autoboxing the 56 to an Integer object with value 56, then looks for an overload of the method that has Object subclass Integer as parameter type, i.e. public void fly (Integer x)...and since no joy there either, uses the overload with the superclass type parameter, i.e. public void fly (Object o).

Second case: The first call has 123 as argument, which is interpreted as an int, as discussed above, so the int-paarameter method is used and prints "int". The arg in the second call, 123L, which means a 'long' version of the number 123 (a primitive number type that allows for larger numbers, though 123 is not itself large), so the overload with the long parameter is used, printing "long", and since the print(...) method, cf println(...) does not include a line-break, you see "int long"
1 year ago
Not sure if this is the best forum to post the query below - if not, mods please feel free to move, thanks.

I'm using a non-JDK library for the first time. It's Apache POI, which I downloaded in JAR form. In NetBeans, I add the JARs I need to 'libraries', and everything works fine. The only thing is that when I 'build' to make a distributable entity, the resulting folder (executable JAR from my source code plus the 'lib' folder containing the required Apache JARs) is very large - over 18 MB - due to the size of the latter.

Zipping it for upload to my website only reduces the size by a couple of MB (not surprising I suppose as the component JARs are themselves a type of zipped entity from what I understand). This is actually just above the allowed size for the free-hosted facility I use, so I have to use Google Drive instead and post a link to the upload there for anyone who wants to download it. In addition, my internet connection can be slow, which adds to the mild misery.

As I'm only using a small number of Apache classes/methods, I'd imagine I would actualy need only a small proportion of the files that are contained in the many subpackages that constitute each of the 7 Apache POI JARs involved. Is there a way to streamline this? I suppose I could download the Apache source code and try to pick that apart to work with only the files I need (and in that case I assume NetBeans would include the Apache code in a single program JAR, which would be nice), but I'd imagine there would be a big network of cross-dependencies among the classes(?) Apologies for the cluelessness of some of the descriptions here - I've led a rather sheltered codewriting life so far!  
1 year ago

Campbell Ritchie wrote:... Let's imagine you are trying to read a text file containing numbers ....


Thanks, Campbell
1 year ago

Campbell Ritchie wrote:Have you seen Joel Spolsky's ideas about teaching programming? He says you should make things difficult so as to weed out the “can't”s from the “can”s. . . . it is just as difficult to get one's head round OO (=object‑orientation) . . .


Although I think I get the object-oriented idea, I suspect I'd be a bit clueless about making solutions object-oriented, as such (unless there seems to be a need) - can you give a correct-incorrect example for a simple problem or two?
1 year ago

Campbell Ritchie wrote:If the difference is that small, I think maybe you should ignore it.


Agreed
2 years ago

Campbell Ritchie wrote:How much of a difference did you find in the timings?


To be honest I don't know if there was anything significant - before ~~140 milliseconds average, afterwards average might have been ~10-20 less, 'by eye', but I didn't bother making a looped run and generating stats.
2 years ago
Thanks Piet. In this implementation I'm streaming the file records as Strings and then extracting fields (3 others in addition to the date) via String's parse(), and processing those in addition. And in the block where I wrote "do other stuff" I'm also keeping track of the ID (a String) associated with the earliestTime. But you're right - using min() on a Sream of dates would not present the problem of initial value, and in fact I did that in a previous implementation where I decided to put data for each field in a seperate List and process from there, e.g. where joinDates is the dates list
2 years ago
Of course another way to do it is do an initial read of just the first entry in the file and initialise to the date from that before the main stream. Tried that now and might make it a tiny bit faster (crude measurements via System.nanoTime() on a few runs, without doing any statistics)
2 years ago
Thanks Tim - good to know, so probably best to leave as-is, then.
(I'm not sure wrapping earliestJoinDate's ZonedDateTome value in an optional would help, as I think would still have to supply a default fantastic-future value when unwrapping in the isBefore check via an orElse(defaultValue) call(?))
2 years ago
I have a program where I use streams API to process data from a CSV file. One of the operations requires keeping track of the earliest ZonedDateTime encountered, which I'm doing by updating
declared before the stream (so it begins null) in a forEach(...) call in the stream that includes the statement where ZonedDateTime.parse(userDataAsStrings[1]) is the ZonedDateTime for the current entry.
This works fine, but I'd like to avoid having to do the null check every time. Ideally, I'd prefer to initialise earliestJoinDate on declaration to a notional maximum ZonedDateTime value (infinity/the-end-of-time!) before the stream, but can't see anything like "ZonedDateTime.Max" available. Anyone know if there is something equivalent that could be used?
2 years ago
Hi - When I browse the forums from time-to-time I'd like to avoid clicking into threads I'm already 'watching', as otherwise I might end up re-reading posts I've seen before. Instead, use the watch emails to bring me to a view from the first post that's new to me. If I switch to "With Bookmarks and Watches", I can see a list of my watched threads seperately to the left, but there doesn't seem to be an difference in appearance in the folder icon and surrounding area for my watched threads in the main list, so if I can't remember status I would have to look through the left list. Is there a trick I've missed?
2 years ago