Java Reference
In-Depth Information
Here, we will start small and simple, with a view to extending and growing the application later.
Initially, we have only two types of post appearing in our news feed: text posts (which we call
messages ) and photo posts consisting of a photo and a caption.
The part of the application that we are prototyping here is the engine that stores and displays
these posts. The functionality that we want to provide with this prototype should at least include
the following:
It should allow us to create text and photo posts.
Text posts consist of a message of arbitrary length, possibly spanning multiple lines. Photo
posts consist of an image and a caption. Some additional details are stored with each post.
It should store this information permanently so that it can be used later.
It should provide a search function that allows us to find, for example, all posts by a certain
user or all photos within a given date range.
It should allow us to display lists of posts, such as a list of the most recent posts or a list of all
posts by a given user.
It should allow us to remove information.
The details we want to store for each message post are:
the username of the author
the text of the message
a time stamp (time of posting)
how many people like this post
a list of comments on this post by other users
The details we want to store for each photo post are:
the username of the author
the filename of the image to display
the caption for the photo (one line of text)
a time stamp (time of posting)
how many people like this post
a list of comments on this post by other users
8.1.1 The network project: classes and objects
To implement the application, we first have to decide what classes to use to model this problem. In this
case, some of the classes are easy to identify. It is quite straightforward to decide that we should have
a class MessagePost to represent message posts and a class PhotoPost to represent photo posts.
Objects of these classes should then encapsulate all the data we want to store about these
objects (Figure 8.1).
 
Search WWH ::




Custom Search