Skip to content

Code Review #11

@alexger

Description

@alexger

Activity can't really be Serializable - it's not a class that holds some value that can be written (serialized) somewhere and restored back. So you kind of abuse the Serializable interface.

It's fine, but usually a less error prone pattern is to create a class that holds all the relevant stuff for a single item and then have an array of that class. This would be pretty much ViewHolder pattern that android uses in (for example) RecycleView or AdapterView.

beh

beh ** 2

Note how empty_slots doesn't follow your naming pattern for functions (that are all camelCase)

The recurrent pattern here is that everything is serializable (like, here for example, it implies that Server must be serializable too). Generally, it is best to model the classes that hold data and serialize them (for example, the Server doesn't need to be serializable, but the data it holds should be - and it makes sense - you can serialize a state of a game, but how do you serialize a list of open tcp ports? Reading number back from disk won't make them open and in the same state as there were "serialized").

A good rule of thumb is that all custom date / time code has bugs. It works in your case, but change the locale (e.q., switch to Hebrew calendar for example, and everything becomes much more difficult). Java's Data and Calendar classes (or libraries like Yoda-Time) would be much safer to use (but arguably harder to learn at first).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions