Liutauras Vilda

Marshal
+ Follow
since Nov 12, 2014
Liutauras likes ...
BSD
software developer, moderator at coderanch, a father, husband and nintendo switch owner
London, United Kingdom
Cows and Likes
Cows
Total received
387
In last 30 days
4
Total given
1142
Likes
Total received
1159
Received in last 30 days
13
Total given
1043
Given in last 30 days
2
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Liutauras Vilda

Junilu Lacar wrote:If instead I just simply convert the null reference into some default value, the mistake will be masked.



About this thing I was thinking yesterday in a bed. Actually it was mentioned here almost exactly what I wanted to write this morning (time zones may differ).

As an addition I came up in my mind with word "metadata". null does not carry any metadata, so indeed, one can't figure out whether it was intentionally passed or in fact was a programming mistake passing a null as argument. I'd say it applies same passing to constructors or methods. Probably at most what you can give is 50/50 if you need to define some odds whether program "works" correctly or not. Didn't use word "behaves", because it does exactly what the programmer tells program to do, so it does behave correctly - and that is the most unfortunate thing in my opinion, you no longer can be certain about the correctness of your program.
3 days ago

original code wrote:


I won't tell anything useful, but want to point out, what is mostly confusing about this code is to me as a user.

If project is null, it takes the parameter variable (copy of originally passed argument reference which appear to be null), initializes it, and later assigns it to member field project and right after, itself goes out of scope.

So, what we end up with is, that originally passed, as argument project, still remains as null at the caller level... oh, will stop right here.

If I'd need to stick with these semantics code, much clearer for my brains to parse it would be such version:


Subtle difference, but leaves less questions in my head which would have been, such as: what is the project passed as argument is referring to now? (it would be still null as Java is "pass by value", but might be confusing to some readers).
4 days ago

Enissay Dave wrote:Does grade matter ?  Since it's not included in your certificate, I guess the one shouldn't spend a lot of time in preparation... What do you think ?


Sounds like you need a paper, not the knowledge. Unfortunately, but many students think the same way also about the university degrees. I prefer knowledge if you ask me - so it does matter!
Hi Nexas, a warm welcome!
1 week ago

Jeanne Boyarsky wrote:When you get the book, you'll see it recommends this site .


So you say at the end of the day Nik had no other available options as just to end up here?
1 week ago
Welcome to the Ranch, Nik! Nice to see you around

1 week ago
Welcome to the Ranch, Mary Yu - nice to see you around, enjoy the stay
1 week ago
Welcome to the Ranch, authors!
1 week ago
CodeRanch recruited a new member of staff, from now on - Bartender Pete Letkeman.

Pete has been helpful for the community in various ways, so we are glad he agreed to join us!
Thank you Pete, and we're looking forward to your continued exemplary contribution.

Please join me in congratulating him on his new title!
And probably let us begin this coming weekend earlier go back to work.
3 weeks ago
Forgot to mention important part.

Any code you post, it supposed to compile, meaning, it supposed to comply with syntax rules.

1 month ago
@OP

I've seen few of your topics already, and in all of them problems follow similar patterns such as: [1] poor code indentation, [2] crammed code to a singular method.

Original requirements wrote:Your task is to complete the program. Program should ask for two integers and then add them together and print the result. Your task is to write the code which asks for the numbers and uses exception handling to check if the given numbers are integers. If the user inputs something else than an integer, You did not type an integer! is printed on screen. Program also includes the variable inputCorrect which value needs to be set to false if the given numbers are not integers.



Requirements with slightly changed wording aimed to gain more clarity, plus shown as a bullet list to get a better idea of the complexity of the project.

First list of requirements:
  • Program should ask for two integers
  • Add two integers together
  • Print the result


  • Second list of requirements:
  • Uses exception handling to check if the given numbers are integers
  • If the user inputs something else than an integer,  "You did not type an integer!" is printed on screen.


  • Additional list of requirements:
  • Program also includes the variable inputCorrect which value needs to be set to false if the given numbers are not integers.


  • If to go to some extent of extremes, you could create as many methods as list items are. And I think you should do that, mainly for the purpose of getting sense how to decompose task into many small tasks.

    Don't worry at the moment about the second and additional lists of requirements, concentrate on very first one. Can you try to create 3 methods from the first list? (with high quality indentation of course).

    Looking to the very first item in the list, you might have a question, so please ask. There are apparently at least two approaches which naturally supposed to come to head, and might cause some thoughts how to achieve that, so that is the part of thinking process if such thoughts kick in.
    1 month ago

    Campbell Ritchie wrote:Wonder what difference that will make.


    None.

    I have bought shorts the other day, and the guy asked me an email so could send a receipt as apparently they don't or they don't want to, but they don't give print receipts by default.
    I refused and said I don't need spam, he said no no no, just for receipt - I thought ok, never mind, weren't sure if the shorts would fit well, so thought I might need receipt after all in case for refund.

    Already got 2-3 emails from them with advertisements.
    1 month ago

    Keit Koppel wrote:My part is line 33 till to the end .


    1. I must say it is getting annoying gradually.

    2. OwnException - you don't need that one, because there is created ownException by the instructor (who also needs to revise Java naming conventions).

    3. Small and Big exceptions shouldn't be inner classes of ownException class which is written by the instructor.
    3.1 There shouldn't be no-arg constructors in them - mainly because it isn't specified in requirements.

    4. You need to implement methods printErrorReport(), testValue() from/within the ownException class. That is why they are there and that is why instructions are saying so to implement them, basically that is the point of exercise.
    1 month ago
    Welcome to the ranch, Ronnie, Kevin,

    On line 27 and line 30 you declare userName and passWord once again as local variables, hence not assigning values to instance variables of the same names. Just remove String data type declaration from line 27 and 30 and supposed to be "ok" on this matter.

    There might be more mistakes, so report to us in case of that. However, there are more things to improve, but since this program reminds me one of mine first programs, I think it isn't that bad
    1 month ago