TU-Charts Project - First Spring
-
Upload
didac-montero -
Category
Technology
-
view
125 -
download
2
description
Transcript of TU-Charts Project - First Spring
![Page 1: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/1.jpg)
Tab
le o
f C
on
ten
ts
1
Introduction and Goals
General Diagrams
Tasks
1.1. Concept
1.2. App Goals
1.3. General Goals
2.1. Communication Android-Server
2.2. Entity-Relationship
3.1. Tasks done: Scaling
3.2. Tasks done: Optimization
3.3. Tasks done: Cache
3.4. Tasks done: Non-Interactive Zoom
3.4. Remaining tasks: Interactive Zoom
4.1. Technologies used: REST Imp.
4.2. Technologies used: ORM Imp.
5. Questions
Technologies used
![Page 2: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/2.jpg)
2
Introduction and Goals 1
![Page 3: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/3.jpg)
» Android App for graphical display of statistical data.
» Diagrams should have zoom and scroll capabilities.
» Different months, different series and different qualities
can be selected.
» Each user can enrich the application adding comments
to the diagrams.
Concept 3
![Page 4: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/4.jpg)
» In any Mobile App, some factors to take into account,
» Computational process is limited Heavier tasks must take place on the server.
» Memory is limited Avoid heavy objects, or keep them in cache and instantiate them only when is strictly necessary.
» Don’t waste bandwidth Avoid unnecessary, heavy or repetitive requests to the server.
» Save battery Don’t make an intense use of the computational processor and of the internet connection.
App Goals 4
![Page 5: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/5.jpg)
» Scale the charts to the Mobile screen resolution.
» Optimize the transmission and the display of the charts.
» Create an optimal mechanism to interact with the server in the zoom-in process.
» Create a cache mechanism for retrieve previous graphs
» Have different users with different access levels (chars, categories).
General Goals 5
![Page 6: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/6.jpg)
6
General Diagrams
![Page 7: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/7.jpg)
Communication Android-Server 7
Web Server: Handle the request; transform it in a SQL query; process it and creates the JSON representation for the response.
Database: Basic DB behavior, response to the SQL queries.
Client: Performs an HTTP Request; converts the JSON response to Java Object and display the results and/or performs some data processing.
Database W
eb
Se
rve
r
Mo
bile
Ap
p
HTTP/JSON
TCP/IP
REST
![Page 8: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/8.jpg)
Entity-Relationship Diagram 8
![Page 9: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/9.jpg)
9
Tasks
![Page 10: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/10.jpg)
10 Tasks done: Scaling
» Scaling (average algorithm) Fix Output = Screen resolution
![Page 11: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/11.jpg)
11 Tasks done: Optimization
» Optimization (deleting, or nulling the duplications) Variable output
![Page 12: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/12.jpg)
12 Tasks done: Cache
» Why cache?
» Two level cache implemented: Disk & Memory Cache.
» MemoryCache Offers fast access at the cost of taking up valuable application memory.
» DiskCache Persist valuable data retrieved from the Server. Fetching and writing process is slower than in MemoryCache.
» Both Caches are HashMap, and the key will be the HASH of the URL Request.
» Both caches implements the algorithm LRU.
Persistence == Requests == Battery consumption
![Page 13: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/13.jpg)
13 Tasks done: Cache
1. Create HASH of the URL Request.
2. Try to obtain the key from the
Memory Cache. If works, go to 5.
3. Try to obtain the key from the
DiskCache. If works, go to 5.
4. Retrieve the Chart from the
Server.
5.
Save the chart in MemoryCache (Object) and DiskCache (JSON)
![Page 14: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/14.jpg)
14 Tasks done: Zoom
» Choosing between the following procedures,
» Requests on demand Request to the server every time we zoom (slow and intense use of Internet).
» Request when higher resolution needed Request more than you need (higher resolution), but not in each zoom.
» Requests in advance Request in background other resolutions, that can be loaded directly when the user requires them (requires cache implementation).
» For the zoom, last procedure has been chosen
![Page 15: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/15.jpg)
15 Tasks done: Non-interactive zoom
» Request in advance for non-interactive Zoom
» Non-interactive Zoom Zoom using the contextual menu on Android. Used for moving among Years/Months/Weeks/Days.
![Page 16: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/16.jpg)
16 Remaining Task: Interactive zoom
» Request in advance for non-interactive Zoom
» Interactive Zoom Two fingers and scroll zoom.
» Whenever the zoom match the menu selection (Year/Month/Week/Day) the view is automatically changed to the match, and the corresponding action is performed (previous slide)
![Page 17: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/17.jpg)
17
Technologies used 4
![Page 18: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/18.jpg)
18
» Server Side
» Use of Apache Tomcat as a Java Servlet Container
» Use of Jersey Framework for implementing REST.
» Use of Hibernate Framework for implementing ORM.
» Use of MySQL as a Relational Database Management System.
Communication Android-Server
![Page 19: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/19.jpg)
19
REST: The predominant Web Service Model Software system designed to support machine-to-machine interaction over a network.
Clients requests to servers; servers process requests and return responses in a well known format.
» Transport layer is HTTP/MIME.
» The URI defines the resource.
» The operations are defined by the HTTP methods (GET, POST,
PUT, DELETE)
» The response is presented in JSON format (indicated thought
Media-Type).
REST Implementation
![Page 20: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/20.jpg)
REST Implementation 20
Advantages
» Simplifying the communication among independent and foreign systems.
» Organize an application into simple resources .
» No problem with firewalls and proxies (port 80, usually open)
» JSON is a lightweight text-based open standard and the Android parser offers
good performance.
» Possibility of HTTP cache and proxy server to handle high load.
Examples
» GET http://example.com/charts Obtain List of Charts.
» GET http://example.com/charts/1?month=1 Obtain Chart info for January
» PUT http://example.com/charts/1 Modify Chart with id=1
![Page 21: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/21.jpg)
21 ORM Implementation
ORM: Mapping technique for converting DB structure Object structure
Advantages
» Simplify the development of a service.
» Overcomes vendor specific SQL differences - the ORM knows how to write vendor specific SQL so you don't have to.
Disadvantages
» Developers loose understanding of what the code is actually doing the developer is more in control using SQL.
» ORM has a tendency to be slow, if is not used carefully.
![Page 22: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/22.jpg)
22 ORM Implementation
Hibernate
@Entity @Table(name = "categories")
public class Category{
private int id;
private String name;
private String description;
private Set<Chart> charts;
@Id @GeneratedValue @Column(name = "category_id")
public int getId() { return id; }
public void setId(int id) { this.id = id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
@OneToMany(mappedBy="category", fetch=FetchType.EAGER)
@LazyCollection(LazyCollectionOption.FALSE)
public Set<Chart> getCharts() { return charts;}
public void setCharts(Set<Chart> charts) { this.charts = charts; }
}
![Page 23: TU-Charts Project - First Spring](https://reader033.fdocuments.us/reader033/viewer/2022060118/558c7322d8b42a65098b46fe/html5/thumbnails/23.jpg)
? Questions?
23