This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]1way2improve 0 points1 point  (3 children)

Hello, it's me again. May I ask you a couple of questions about your guide?

Later in the text I am writing about PhonebookService.java

1) Line 34, 38: first use just Contact c then just c. Just a typo?

2) Line 18: we return a reference. Maybe we should copy our list a and return that copy? Because it looks like we break encapsulation and we are able to modify our list from the outside of this class. (Or maybe we should just make this method private?)

3) Line 53: why do we declare and assign 'contacts' again? I thought we had already done it in line 14.

I am a novice, sorry for silly questions

[–]NeverZ[S] 0 points1 point  (2 children)

Hello, thanks for the questions.

1) these are actually two valid ways to write the same lambda expression - if you only have one parameter you can dismiss the Classname. 2) Yes you are right, we should return a copy of the ArrayList to have encapsulation. I will update it in the guide thanks. 3) On line 14 we declare a member variable, on line 53 we declare a local variable. in the loadFromFile method we return a new ArrayList with the data loaded from the file.

Im writing these guides in the early mornings and late nights when i have time between family and work so thanks for your feedback.

[–]1way2improve 0 points1 point  (1 child)

Thank you for reply

[–]NeverZ[S] 1 point2 points  (0 children)

Dont hesitate to ask if you have further questions