Ryan McGuire

Ranch Hand
+ Follow
since Feb 18, 2005
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 Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ryan McGuire

In the case of arguments 2, 2 and 4.  Should you get both 2+2=4 and 2*2=4 or just the addition equation?
2 weeks ago

Stephan van Hulst wrote:If your method call can succeed or fail, there are two acceptable options:

  • Return a boolean value indicating success. This is appropriate if failure of the method call is a normal occurrence and can happen regularly.
  • Throw an exception. This is almost always the more appropriate option, because failure is usually an exceptional situation.

  • Why would an SQL query fail, unless something exceptional happened? So throwing an exception is probably the way to go. Now, you have two ways of throwing the exception:

    I know that in C# throwing an exception is a LOT more expensive than returning a primitive value.  Is it the same in Java?  If so and you're inserting 500 DB rows of data in a loop, i'd change the return type to a boolean (success/failure) or an int (either zero or one row inserted).

    3 weeks ago

    Paul Clapham wrote:Can you burp the alphabet?

    One of the achievements of which I'm most proud is burping the entire alphabet and getting to 'L' the second time through.  All it took was a can of warm Pepsi.

    I remember some movie or maybe a TV show had an allusion to "burping the Greek", when you try to say the entire Greek alphabet in one burp.  I wish I could remember where I saw that.
    1 month ago
    "I have some feedback for the end of our sprint," Tom said in retrospect.
    4 months ago
    Just watch out for the employee that gets microchip 666.
    6 months ago

    Fairies.  Genies.  Naiads. Kodama, which we could modify slightly for software to Codama (Code-ama?)
    7 months ago

    Michael Angstadt wrote:As a software developer, it's important to make your code readable so that other developers (as well as your future self) can understand what you've written.  However, complex regular expressions are notoriously difficult to read.  Do you have any tips for improving the readability of regular expressions?  Thank you!

    7 months ago

    Henry Wong wrote:

    Ryan McGuire wrote:
    'nuff said.

    Hee Hee. Only a fellow trainer would understand the significant of those numbers....

    Too bad there are very little reasons to friend a trainer that you will never battle, raid, or trade with... or I would send an invite.


    It depends on where you live.  Different regions have different pokemon, so a trading with someone half-way around the globe would be worthwhile.  
    8 months ago

    Greg Floer wrote:I still play Pokemon go

    5215 0574 4402
    'nuff said.
    8 months ago

    Tim Holloway wrote:But English - like every language - has its imprecisions. ...

    As always, there's an XKCD for that.  https://xkcd.com/169/
    9 months ago

    Paul Clapham wrote:Like Rob said, use a PreparedStatement. Start with this:

    Let's just hope dbName doesn't have a value like... "Students; DROP TABLE Students; --"

    10 months ago
    Before anyone else points it out, I had a bit of a transcription error in the initial math above.

    (1/14 + 2/3) * 5/32 = 0.738095238095

    I reported the sum of the first two fractions as the final result.

    (1/14 + 2/3) = 0.738095238095

    (1/14 + 2/3) * 5/32 = 0.11532738095

    All of my original comments still hold, even though the math needs to be updated:

    0.11532738095 = 11532738095 / 100000000000

    Cancelling out a factor of 5 gives us 2306547619/20000000000  final answer.

    Ok, I feel better now.
    10 months ago
    Randall, are you saying that you don't need to be exact and a good approximation is reasaonble.

    e.g. (1/14 + 2/3) * 5/32 = 0.738095238095 to some level of precision.  You'd accept any fraction that divides out to 0.738095238095 even if it's not 155/1344.  Is that right?

    Getting the exact fraction for any terminating decimal (which is what you have to assume your result is) is easy.  Just put the digits as the numerator and 10^N (where N is the number of decimal places) in the denominator.

    0.738095238095 = 738095238095/1000000000000

    There... done.  Of course you could factor out any powers of 2 and/or 5 (up to N).  

    0.738095238095 = 738095238095/1000000000000 = 147619047619/200000000000  Final answer.

    That unwieldy fraction is closer to the decimal version of your calculation result than the real answer of 155/1344.

    Ryan McGuire wrote:
    If you need to report out a fraction at the end of a calculation, could you just do the whole calculation in fractions instead of using doubles at all?

    I just noticed that S Fox made the same suggestion before I did.  Well played.
    10 months ago

    Randall Twede wrote:going from fraction to decimal is easy, you just divide. to go from decimal to fraction is a bit harder.
    the algorithm i came up with for that is you multiply and if the result is an integer, that is the numerator and what you were dividing by is the denominator.
    you loop through integers to find the denominator.
    for example 1/4 = .25
    you multiply .25 X 2 = .5 = no
    .25 X 3 = .75 = no
    .25 X 4 = 1 = yes
    so .25 = 1/4
    this works except for repeating numbers like .333333333333333333333
    is there a way to make my algorithm work?

    If you need to report out a fraction at the end of a calculation, could you just do the whole calculation in fractions instead of using doubles at all?  There are a few "Fraction" classes available that you could download.  Or it could be a fun way to spend a few hours some evening writing your own class, as an exercise.
    10 months ago

    Tim Cooke wrote:Saying 'buzzwords' in an interview is only useful if it comes across that you clearly know what they mean. Consider putting together some programming scenarios and examples that make use of these constructs and concepts so that you can have a good discussion with your interviewer and show that you understand them in the right context.

    For example, what is an immutable object? How might you construct one in Java? Why might you want an immutable object?

    For me a good interview is a discussion, rather than a pop quiz.

    Along those lines...
    In addition to just definitions of single terms, you should also be able to compare and contrast related terms.
    - What is the relation/difference between a Parameter (which isn't on your list) and an Argument? *
    - What is the relation/difference between Composition (which isn't on your list) and Inheritance and when would you choose each?
    - Why would you use an Accessor Method?
    - What is the relation between the throw and throws keywords?
    - How do you deal with Deadlocks?
    - What are the alternatives to a Binary Search?  When would you use a Binary Search and when would you use an alternative?

    * On a side note: I got almost two decades into a programming career, including a number of year in Java without remembering which one is an Argument and which is a Parameter.  I initially thought they were essentially synonymous and used them interchangeably.  BUT... if you have Argument as a glossary term flashcard, you might as well have Parameter.

    Also, you shouldn't memorize these terms, you should learn them.  You know there's a difference, right?
    1 year ago