salvin francis wrote:Next, this has been discussed a lot of times in coderanch: Do not using floats for currency.
Unfortunately lots of other people don't know that either.Eric Flynn wrote:ok didn't know that . . .
You won't notice the problem but you might as well learn the correct way to calculate money from the word “go”.It is possible to reuse the two objects in lines 3‑4 because big decimal is immutable (at least in theory). Also have a look at this old post of mine.use Big Decimal . . . for these mickey mouse newb exercises i'm sure it isn't going to be a problem. . . .
Eric Flynn wrote:here is my "script" for my program. I have expanded it a little. Cause I thought it might be worth doing it.
...
Eric Flynn wrote:I will keep that in mind, though for these mickey mouse newb exercises i'm sure it isn't going to be a problem.
here is my "script" for my program.
As a general rule of thumb, the more thinking and planning you do before you write any code the better.Eric Flynn wrote:I'm guessing that I shouldn't even be looking at code...yet
Careful about the word “members”, which has a specific meaning in Java®: methods, fields, and nested types.Is this now the time to identify classes members and methods? Or is there something else that needs to be done first?
Carefully study different ways to calculate the discount, then, in the absence of any instructions to the contrary, choosd whichever you think will be easiest to implementA few minutes ago, I wrote:. . . how are you going to calculate the 10% discount? . . .
Campbell Ritchie wrote:As a general rule of thumb, the more thinking and planning you do before you write any code the better.
Eric Flynn wrote:I'm guessing that I shouldn't even be looking at code...yet
Is this now the time to identify classes members and methods? Or is there something else that needs to be done first?
Sorry, I thought I had replied to you earlier, Liutauras, but the message seems to have disappeared.Liutauras Vilda wrote:. . . Is it still applicable in nowadays? . . . if one practice TDD . . .
I was taught you have to use UML etc., but I think it is more accurate to say that UML doesn't assist coding at all. Anyway, as you hint, after a lot of coding (5 minutes), you will realise that the planned class design isn't working and will have to be changed.the actual design of the system is better experimented with code, rather than planned upfront with charts/diagrams/etc..
Liutauras Vilda wrote:
Is it still applicable in nowadays?Campbell Ritchie wrote:As a general rule of thumb, the more thinking and planning you do before you write any code the better.
Liu wrote:Or I should say, if one practice TDD (=Test Driven Development), or even if not. As Junilu often says: "experiment your ideas in code", because code really tells the truth.
Liu wrote:Am I correct in saying, that logical exercises and algorithms are better solved on paper first, while the actual design of the system is better experimented with code, rather than planned upfront with charts/diagrams/etc..
Campbell Ritchie wrote:Another thing I would do is try out little code blocks on JShell. It's much quicker than writing a whole class to test three lines of code.
Campbell Ritchie wrote:I was taught you have to use UML etc., but I think it is more accurate to say that UML doesn't assist coding at all. Anyway, as you hint, after a lot of coding (5 minutes), you will realise that the planned class design isn't working and will have to be changed.
Is that the same as my having to change the UML after 5 minutes? When I had to write UML for assignments, I got the code working and later let an Eclipse plug‑in produce the UML diagrams.Junilu Lacar wrote:. . . non-testable form of documentation . . . tend to be wrong anyway when done too early. . . .
Campbell Ritchie wrote:
Is that the same as my having to change the UML after 5 minutes? When I had to write UML for assignments, I got the code working and later let an Eclipse plug‑in produce the UML diagrams.Junilu Lacar wrote:. . . non-testable form of documentation . . . tend to be wrong anyway when done too early. . . .
It got me a grade A, tooJunilu Lacar wrote:. . . Automated generation of UML . . .
Eric Flynn wrote:This?
...
Then I write some test code to document what this idea might look like in code.?
How? im sorry, im just not with you, i seem lost here
Please don't make drastic edits to your post so as to change the complete thought and render any replies to it nonsensical. I have reverted to your previous version because it will help others who share the same kind of doubts.
That sentence suggests a few things to me:-Eric Flynn wrote:. . . I dont think the main menu can be in the donut class, but if its in the main class I have to instantiate an object to use it, i could make it static but i know this is not the way.
Eric Flynn wrote:but i still think i am missing a lot regarding the actual workings of oop as i still dont know where the menu should be placed
it cant be in donut, because every object will then have a menu, which is obviously what i dont want
This is a step in the right direction but individual Donut variables will not facilitate looping, which is what you'll want for the menu display. If we assume that for now that the available list of Donuts for sale is not going to change, then it can be implemented as a DonutShop constant.Eric Flynn wrote:
Don't get me started about those stupid light bulbs. |