Facebook Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: In-Person
Use MVC where
public class Controller { //User updates will make a call to this class
statusUpdate(String userId, Status status); //makes call to model
postPhoto(String userId, Photo photo);
}
public class Model { //Does db updates and notifies view
statusUpdate(String userId, Status status); //Updates status in DB, finds user and his friends, notifies friends views with new status
postPhoto(String userId, Photo photo);
}
public class View {
String userId;
Wall wall;
updateWall(User user, Status status);
updateWall(User user, Photo photo);
}
Curious, I like your answers's design. However I find the Controller is actually the activity and the view are the XML layout files ( or NIB files). Where you would have a "ViewController" per view which is actually your Activity in the case of android; or a ViewController in the case of iOS. Therefore the design becomes platform agnostic.
I would start by designing this from a top level restfully backed mobile client application.
- android-anon April 15, 2014We would want to break the feature into a common design pattern. This would include Models for the Posts and User. A Network class to manage getting the data for the posts from the facebook API. A Controller (Activity) to NewsfeedActivity. This controller would use the models and views to produce the UI for the newsfeed list view. The Model would interface with the Network Class to get the data and convert it to formats the controller requires. And finally, views for the newsfeed post items, and the list container.
After laying out the general design I would go into implementation details about how the Activity would manage this UI using most likely an ArrayList list adapter.