Bank of America Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
1
of 1 vote

I think the main problem with your solution is the lack of a restore method. When using a memento you don't want to replace an existing object with a memento, you want to change the existing object's state back to how it was when the memento was taken. Your originator doesn't allow for that.

I'd stick on a restore method, and probably create a separate class for the memento because it probably doesn't need all of the originator's functionality and in many cases not all of its state. For example, if the originator is a word processor and it's creating a memento of the characters typed, you wouldn't want to clone the whole word processor.

- Anonymous March 21, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I agree with Anonymous above.

You are supposed to store the state of the originator rather than entire originator object. When i say state, it is the data inside originator not the originator itself.

- Sudhindra.A March 22, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Your example is relevant to Memento Pattern.

I think he was expecting few completely-defined, like :
- Memento will be a class, having methods - Save & Restore
- Caretaker will be having a collection of Mementos

- Sudhindra.A March 21, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More