Zach Rode

Rancher
+ Follow
since May 25, 2018
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Zach Rode

Campbell Ritchie wrote:

Zach Rode wrote:. . . Arrays and Arraylists . . . are not ordered because their positioning is not based on a property of the elements

Did you mean to say not sorted?




Woops. Yes I did. Sorry about that.

Alex Niculae wrote:Hello.

I am puzzled by this question, just as the original poster.

The question is:

18. Which of the following are true? (Choose all that apply)
A. ....
B. ....
C. ....
D. An array is ordered.
E. An ArrayList is ordered.
F. ....
G. ....

And both D and E are marked correct, with the following explanation:

[...] Both an array and ArrayList are ordered and have indexes. [...]



from stack overflow:


An ordered collection means that the elements of the collection have a specific order. The order is independent of the value. A List is an example.

A sorted collection means that not only does the collection have order, but the order depends on the value of the element. A SortedSet is an example.

In contrast, a collection without any order can maintain the elements in any order. A Set is an example.



Thus, because Arrays and Arraylists both have indexes, they are in a specific order. They are not ordered because their positioning is not based on a property of the elements
I know you asked about testing but your formatting is all over the place too.



That block has all kinds of weird stuff going on. I know it might seem insignificant but when you are having others review your code, it matters for readability purposes and impressions (it's the same as mixing up they're, their, and there when you're inconsistent like that). CTRL+SHIFT+F is your friend if you're using Eclipse.

Just for instance you have 3 different whitespace formats going on with your class/method names



As far as tests code, You've already made this class, so unless you start from scratch you can't exactly implement TDD. Download a code coverage tool (never used that framework so I'm not sure if it comes with one), write logical tests for edge cases and normal cases for each method, run coverage tool, right tests to test what you haven't covered; logical ones, coverage for coverage's sake is bad. Rinse and repeat.

-Zach
6 years ago

Tim Holloway wrote:Using gc to get a better idea of how much active object memory you are using is a popular thing to do.

In older times, especially in real-time applications, it was sometimes useful to call gc before starting something resource-heavy. Otherwise the user experience could be marred when an automatical gc started in the middle of things and stalled the UI.

A classic example of this was one of the early Amiga Computer demos where it opened 4 windows, each with a moving graphic in them and played music in stereo*. The Amiga was the first home-grade computer with real-time pre-emptive multitasking capabilities straight from the factory. In fact, although Linux has always had pre-emptive multi-tasking, you had to do a custom kernel build if you wanted real-time and that was over a decade later.

But real-time and ore-emptive are no match for a quick-and-dirty port of BASIC that had a blocking garbage collector, so right in the middle of the demo, it would periodically stall - while playing music - to do garbage collection.

This isn't as much of a problem with the smarter and more incremental gc processes in modern Java, but you can see why people got into the habit.

===
The Amiga was probably the only computer whose on-the-box specifications contained not only RAM and CPU speed, but stereo separation in decibels and Total Harmonic Distortion. Even today, many PCs use a separate sound card. And even when it's on the motherboard, the sound chips used depend on the motherboard manufacturer.



So BASIC had automatic garbage collection too? I wonder why they didn't implement it as an option in C++
6 years ago
I figured there was no use for it, but many things in Java appear useless to a novice while being useful in the hands of an expert.

Thank you!
6 years ago
I know it isn't recommended anymore to call System.gc(), but are there situations where it might be beneficial?

-Zach
6 years ago
Because they are different doesn't mean they are incomparable though. We can pro con each language to give OP a better understanding of why you should pick one or the other

we can start with an informative post Tim Holloway wrote a couple months ago

Tim Holloway wrote:I work along the same lines as Joe Ess. Although I also still use Perl if I need something that's heavy on regular expressions.

Python is good for complex quick-and-dirty apps.  It's almost exclusively what I use for Raspberry Pi projects, since there's a good fit between the APIs I use and Python. I also use Python BeautifulSoup when I need to mine HTML for data.

Java is what I use when I need industrial strength. That is:

A) I need to handle heavy loads/many concurrent users and I need a robust and complex infrastructure to support me.

B) I need security

C) I need performance

D) I want the flexibility to swap out different service providers at need. For example, Hibernate versus Apache OpenJPA.




The languages differ in style which may or now be an issue for other. Java being extremely verbose while Python is white space delimited (which I hate personally).

Java is more portable as it is designed to be able to run on any machine, while you might have python run into compatibility errors.

There is the static versus dynamic typing debate which is a conversation of its own.

Java is king of the mobile app space (atleast for Android) as the android runs on a modified version of the JVM.

Java has an absolutely MASSIVE amount of functionality built in. UI, CRUD, time calculation, functional programming plus many more all come standard. I can't really speak for Python on this as I'm not a python dev.

At the end of the day, it does come down to which tool is better though. you can screw a screw with a claw hammer but its not necessarily efficient.  Keep these issues an what everyone else has said when determining what to use

Being a Java dev I am kind of biased though so here's an article from a Python dev's perspective
6 years ago
So this is a bit confusing to me. How does the compiler know youre calling i2's method? Is it because you are implicitly inheriting i1 regardless of if you don't state it? It seems to me that if you declare both interfaces your code would inherit both methods unlike if you only implemented i2, then your class would inherit the overriden version of the method.

-Zach

Knute Snortum wrote:My experience is that people from the UK can do an American accent better than Americans can do any English or Scottish accents.  Take for example Dick van Dyke in Mary Poppins, as they mentioned.  On the other hand, take Hugh Laurie on House, MD.  I never would have suspected that he wasn't born in America, his accent was so good.  



I think for a general american accent yes, but American accents are regonalized just as English accents are. Most Americans can't do a proper Southern accent of any kind, just as a Southerner would struggle a proper New York or Midwest accent.
6 years ago
Couple of questions that might help. Why do you not want any numbers? If you are trying to validate data to make sure its a country "asdfjkansdfjansdfajdfna" is just as bad as "Ireland99".

Second, I feel this might be a really good situation to use an enum for country names as the countries you are looking for are static. Just a thought.

-Zach
6 years ago
yea you could return an object array just make sure you wrap the primitives into objects
6 years ago
So I might be misunderstanding your question but why don't you return a collection or array? Those can contain objects or primitives(collections autoboxes primitives to their object type, just fyi)
6 years ago
*Tumble weed rolls*

Sure been quite in here cowpokes.

So I'll back a game. Possibly code ranch themed against the evil forces of HR/Business team with a moose super unit. This thing writes itself.

-Zach
6 years ago
That's awesome guys! Thank you! Congratulations to the other two!
6 years ago
Sorry I might have phrased what I meant wrong. I was trying to say did you mean an desktop application or web app or something else.

I agree with the game idea as something that could be neat. Video games are my hobby and bring a lot of people into programming. The downside being some people are not interested in games at all and the technology is not always applicable to real world situations outside of game development.

There are many types of turn based games: Strategy, rpg, puzzles, etc. Did you have one in mind? For a while, I've been thinking of a turn based game space game influenced by the card game Star Realms, personally.
6 years ago