25.Sept, implementing RelationData
Today i have worked on implementing the fundament for the type of data that will flow in my system. And after some thinking, i wanted to use the Factory Method to do this. So i made a Interface called RelationData, that will be the type that is being sent around in the system. A concrete Implementation like a message will implement this. I have a class called RelationDataCreator that the abstract factory metode lives in. And last the RelationDataFactory that will inherit RelationDataCreator and the have the concrete implementation of the factory method.
The thought about the RelationData, is that all the concrete types have to have the knowledge of how to make a “network package” of himself. In addition they will be connected to a Relation object, that will hold the data of the “Relationship” you are in. The Relation object will again have the knowledge of how to make a “network package” of itself.
So the thought is that i can just use the same method in my server service to send RelationData over the network. At the moment its working for my Message object, that inherit RelationData and have all the knowledge it needs about itself.
I have also started implementing my model on the client and some services as singletons, with synchronization handling. This since there is different threads accessing this objects at different times, both the basic UI thread and different network threads. So the business layer on my client side is starting to take shape.
First week of programming
The goal of this week was to have a client and server project ready in eclipse, and be connected up to GCM(Google Could messaging). And if this were to go smooth, i would start looking at some design around my project. This would then be the foundation of my project before i could start building it up
So, how did i do? Well, my start point was that i knew nothing about java servers, and a decent amount about programming for Android. So after a little work, i had my client project up running, and was ready to start on my server. But where to start? I know that the easiest way of communicating, was to use the HTTP protocol, and that i had to communicat with the GCM by some simple JSON. So after some fighting with my computer, i got a sample project from Android up running. Everything was working great, but had no clue what i had just done. So i was basically stuck
On day 3, that will say wednesday, i contacted my sister that has worked with java for 10 years now, and she said yes to try to help me out. So to present my problem in a constructive manner, i made some basic drawings on how my system where to communicate, and where i was stuck. From that i got a basic introduction to Servlets, which is javas ways to communicate with the HTTP protocol. She helped me set up a web project, and setting up a server environment in my Eclipse, running Tomcat. And with a little help i made my first servlet, and had a successful connection between my phone and the server. Hurrraaaay !!!! :)
The rest of the week i used on getting all communication up running. I got the network jobs to run in it's own thread. And in the end i was able to do all the communication i needed for my project. A final lifeline looked like this:
Register with GCM -> Registration respons from GCM -> Register with Server ->Sucess Respons Register with Server-> Send Message To Server -> Send Message From Server To GCM -> Receiving Message From GCM
Hurrraaay again !! :)
So now i got my project ready in Eclipse, and got all the communication needed. And then im looking forward to my real project: Design Patterns in a Smartphone Environment.