David Cone

Ranch Foreman
+ Follow
since May 26, 2021
David likes ...
Eclipse IDE MySQL Database Windows
I was born in September, 1967. I', 6'4". I'm married.  She rocks! I've had all the toes on my right foot amputated. I'm working on being better fit physically and mentally.  The last job I had (outside helping my dad sell ukuleles online, before he died) was Network Engineer for Excel Agent Services (which went belly-up). I've been working with computers since the TRS-80 Model 1, level 1 with a whopping 4K of memory and 150 baud cassette tape for storage. Due to a number of reasons, I got out of computers around 1999. (Windows 2000 just came out, and the new Active Directory model over primary/backup domain controler servers) I'm back.
SoCal
Cows and Likes
Cows
Total received
2
In last 30 days
2
Total given
0
Likes
Total received
10
Received in last 30 days
0
Total given
5
Given in last 30 days
2
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by David Cone

Matthew Bendford wrote:To add on what's already mentioned: A possible name for your calculator be RpmCalculator.
Note: It does omit the phrase "parameters" altogether. Why? Cause you want to calculate a RPM object by whatever input.

Side-note to RPM vs Rpm: There's no fixed rule and inconsistant within the SE API itself: URL is a good example: URL.openConnection returns an URLConnection. But its implementations are HttpURLConnection and JarURLConnection - although both HTTP and JAR are abreviations as URL - but only URL is kept all-capital.
There're a few others throughout the SE API all since early on 1.0 or 1.1 - so around late 80s / early 90s. We wont change them today even if someone would come up with a ruleset how to handle them.

On the other site ... well - if you call it RpmCalculator why not call it Rpm instead of all-capital RPM?
You see: This gets philosophical right away ... it comes down to personal preference. So, you maybe come up with yozr own style, you may copy someone else, but whatever way you go: stick to it! Hence: choose wisely.



Well, to answer your question, I was originally going to calculate the RPM in the MoterizedVehicle class which uses the calculation.  I guess it does make more since to do the calculation in the class that holds the data.
3 weeks ago
If I want to pass all the parameters for calculating RPM in a single object, would the name, CalcRPMParameters, be a good class name?
3 weeks ago

Junilu Lacar wrote:...
You'll do yourself and others a huge favor if you write this kind of code instead:

A guy named John Woods once wrote "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” Keep that in mind when you start writing code that others may have to read or maintain.



I understand and will do as you say.  One thing that greatly frustrates me about the Udemy.com Java training course is that you can only use as many methods as they request.  Another thing that... concerns me is I wonder if working for NASA contractors when I was young and my first college programming teacher (who taught me beginning Visual Basic) got me in a mindset of using the least CPU cycles vs using the simplest code.  I read some of the solutions other people have submitted and I have no idea how their mind is thinking to come up with the short solutions that they do.

For example, one homework problem was to find the largest prime factor of a number.  Now it's been way to long ago for me to remember who taught me this, but I know if you want to factor a number, you don't have to test all the way from 2 to the number you can test up to the square root of the number and for every factor i, you will also have a factor number/i. (Less CPU cycles)  It further goes to reason if you start searching for factors starting with 2 and working your way up to the square root, that the first number/i factor that is prime will be the largest prime factor.  If however, none of the factors above the square root are prime, you have to keep checking the lower factors until you reach the square root of the number.  Now if I had my way I would have had an additional method, isPrime, to do that check, but it had to be done in one method.  Here is my code:



Here is the recommended code in the Q&A fourm:



Wow that is simple.  Miles simpler than my method.  And I will further add, I don't know if I ever would have thought of this.  Are there books or courses just on programming techniques that can teach me how to think like that?  I choose not to take the time to test, but I half wonder if the other person's code isn't faster than mine.  I think mine would be faster on largeer numbers as you appoach Integer.MAX_VALUE, but still.  Any thoughts?

~d
1 month ago
I can't find where on here I read it...  I thought it was a post from CR...  I thought someone said never to close a console scanner.  Am I remembering wrong?  I only ask, because the teacher on Udemy is doing it and for some reason red flags went up in my head and I don't know why.
1 month ago
What I mean by reference ID:  In the code as is now, I have an object roomy and an object exRoomy.  From those object names I can keep a clear mental reference to which object refers to the object when he lived here and which object refers to when he went to fire-school.  If I moved to the model, that easy reference disappears.  While I have the code.... [scrolls back to look lup the spelling of the word] immutable, if I accidentally try and assign a new person to "exRoomy" Java will sound the buzzer.  So as the code is now, 1. I have meaningful names (to me) for my objects, and 2. I can't accidentally reuse an object name.  Both of those seem like features not bugs, particularly when I start writing larger programs. So even though adding new user objects (which I don't see happening in real life, but is serving as an example) is currently a two step process the advantages of doing it that way seems to out-weigh the disadvantages.  I do look forward to learning about these HashSets Paul (or you or maybe both) talked about.  For now, I'm trudging on through the course sequentially and doing all the code exercises, even if they are easy.  If nothing else, the repetition is helping me have less buggy code because "the Java way/syntax" is becoming a habit.

Campbell Richie wrote:This (old style guide link) is what you should write:-

 Yes between my last msg and reading yours I figured out that most boolean methods can just be the word return followed by boolean math.  I wrote some beauties last night or the night before.... both I guess.  My favorite was the leap year problem.  Mostly because it made me think.... I cut down my code several times...  I'd be working on a completely different problem and something about writing  the current solution would prompt me to realize I had redundant checks in my previous code.  I'm enjoying the course so far.  I did send in a query to the teacher  to see if it's OK to use things we haven't  officially been taught in our solutions (like the ternary operator, which is still a valid construct for non-boolean methods that return strings.)  

Thank you all for being awesome and have a way-cool rest of your weekend!
Peace out,
~d
1 month ago
So I'd loose a reference ID (in this case, the variable name) by doing it in one step.....  and if I add a reference ID to the class, I have no way to ensure it's not duplicated (well I guess it's not impossible, just a bit over my head at the moment...  I was reading up on this at stackoverflow.com and I guess a new class could be made that extends ArrayList, override the .add method to include duplicate checking on the first property and if no duplicate is found, do a "super.add"...  That's all off the top of my head from what I read last night,  Let me see if I can find the reference...  brb.... [time passes] ... Solution Entry by G H...  I'm pleased to say I've read enough about Java that I understand what he's saying....  just not enough to program it.) I think I'll be satasfied with the code as it is for now.  Later I'll add the ability to read the data from a file.  For now I'm having fun doing code exercises on Udemy.com.  I had fun doing the "Barking Dog" exercise with a single if statement.  If we were allowed to do it using the ternary operator (which we haven't learned yet) the solution could be done in a single statement:   Off to code... Have a great evening!  ~d
1 month ago

Estel Lopez wrote:


So if your feeding 1 person, and rice, shrimp and squids each cost 1 €/kg, to feed that one person would cost 3 €?  

Before  you tackle the code part, I want to agree and support Mr. Campbell's assertion that before  you work on code, you need to know the process.  How would you solve this problem using a #2 pencil and a Big Cheif tablet paper.  In the end, if you don't know how to solve the problem without a computer, you'll never be able write the program to solve the problem with a computer.  On the contrary, the better you understand what method you would use to solve the problem "by hand," the easier it will be to write the program.

Are you taking this Java course online or in classroom?   How is the material taught:  lecture, videos, or some other form?  What resources are avalable to you in this course?  Is there a book?  What was the last topic of discussion before this assignment?
~d
1 month ago
You have an awesome teacher,  I love the problem.  I particularly like the calculating costs part of the exercise.  
1 month ago

Campbell Ritchie wrote:Something like?



I didn't look this up, but it's time to get more sleep (and I'm not sure what search terms to use).  Can I do something like ?

Thanks,
~d
1 month ago
@Campbell - brilliant as always!  Thank you good sir.  BTW, I noticed I got your advise indirectly.  If I offended you, I deeply apologize!   Oh, I did get some more sleep this afternoon.  Thank you for your concern.

@all -  With a cool post on stackoverflow.com (referenced in code comments) and Campbell's streamline, I got a new version of this program that uses ArrayList to print out the users.  I'm happy to say I got it working! (woot!)  Before I work on 2.0 which will be getting the list from a file,  I feel like there is probably some more streamlining to be done.  Which is to say I know your brilliant minds can do it more efficiently.... perhaps there's a way to create a new user and add them to UserSet in one shot.  For now I'm off to play some Bloons TD 6, and then I'll dive back into Udemy.com's program.  I'm happy to say I found the bug in the  teachers code (which he points oout in the next video) before watching the next video that told me about it.  I also found a streamline that he didn't mention.  I feel like I've made good progress today.   Oh yeah, before I go... the new code.

Address.java:


User.java:


Main.java:


Have a way cool evening/night,
~d
1 month ago
Version 1.2

Main.java;
1 month ago
@Junilu - fair enough.

@all - Is this up to standards?


Address.java:


User.java


Main.java:


thank you for your time,
~d




1 month ago
@Ritchie...  It's not as much "nightowl" as it is "Insomnia".  I did get a couple of hours sleep before I woke up again at ~11:30.pm.  I'm a huge fan of sleep.  I fully believe in it and seek a rested state every day.

@Fred I totally understand your house example, thank you good sir.

@anyone - I still don't get what an immutable program looks like.  Can anyone give me a side by side... a short program or snippet in mutable form and then the same thing in immutable form.  That would help me greatly.  If it makes it easier, what would an immutable version of a program I have already written looks like.  If you have homework fear, one of your own.  To quote my sister, this is all great in Theory, but I don't live anywhere near, Theory.

@Junitu. - No, I said it the way I meant it.  I felt like I was bringing mole-hill problems and getting mountain answers which don't cast well back into mole-hill.  Not angry, overwhelmed.  A dadism:  How do  you eat an elephant sandwich?  One bite at a time.  I keep trying to take a bite out of learning Java and people keep handing me back new sandwiches.  So instead of feeling like I'm making progress, I feel like I'm falling further behind.  In this case, I was trying to learn about objects stored in other objects.  Responses: "you need to understand immutability and formal programming"...  something you can write an entire book about...  something I wasn't aware that I wasn't aware of it.  Now it's in queue to learn.  A queue that feels like it's about to overflow.  And I get that people are sincere in there efforts to help and I 'm sure that in some cases bring up what they do will keep me from learning a wrong way and having to unlearn it, so I am appreciative. but that doesn't make it any easier for my head to wrap around the micro-topic that I'm working on at a given moment.  I do not choose to proclaim ADD or ADHD or any of those labels over myself.  However, I will admit sometimes it's hard to focus on one specific subject, so that adds to the dilemma as well.

Have an AWESOME day,
~d
1 month ago
@Ritchie  I've read that a couple times now. It's 3:48am and I need sleep.  I can't promise that tomorrow I'll try again, but I will someday soon.

@Paul I'm guess I got this figured out to a point that I'm satisfied... Here's my more realistic test code.

Address.java:


User.Java:


Main.java:


Output:

Dave Cone
1 Hard Dr
Santa Ana, CA 92707
And now for someone... completely different.

______

I'm Real
1 Hard Dr
Santa Ana, CA 92707
unreal!


===============


Dave Cone
1 Hard Dr
Santa Ana, CA 92707
And now for someone... completely different.

______

I'm Real
1 USB St
Riverside, CA 92505
unreal!

Process finished with exit code 0


Is that reasonable code for day 27 of learning Java?
1 month ago
Hi Paul,  (on a side note, I'm less cry-baby now)

My artistic aptitude is way low.  I don't even do stick figures well.  Someday I'll post some of my "artwork" for everyone's amusement.

Thank you ever so much for your explanation.  Let me try a few things using my new understanding and perhaps it is now a non-issue.

Thank you for being awesome,
~d


1 month ago