Fakultas Ilmu Komputer UI

README.md 6.59 KB
Newer Older
agni.wira's avatar
agni.wira committed
1
MyUI
Hafiyyan's avatar
Hafiyyan committed
2
3
=====

agni.wira's avatar
agni.wira committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
### Build Status and Code Coverage

Make sure that Build Status are Success and Code Coverage is High

Here's the summary of build status and code coverage from important branch :

1. **Master**

    [![build status](https://gitlab.com/hafiyyan94/MyUI/badges/master/build.svg)](https://gitlab.cs.ui.ac.id/mihp26/MyUI-Dev/commits/master)
    [![coverage report](https://gitlab.com/hafiyyan94/MyUI/badges/master/coverage.svg)](https://gitlab.cs.ui.ac.id/mihp26/MyUI-Dev/commits/master)

2. **Development**

    [![build status](https://gitlab.com/hafiyyan94/MyUI/badges/master/build.svg)](https://gitlab.cs.ui.ac.id/mihp26/MyUI-Dev/commits/develop)
    [![coverage report](https://gitlab.com/hafiyyan94/MyUI/badges/master/coverage.svg)](https://gitlab.cs.ui.ac.id/mihp26/MyUI-Dev/commits/develop)

Hafiyyan's avatar
Hafiyyan committed
20
### Specification
21
22
23
24


- Target SDK : Marshmallow (25)
- Minimum SDK : Ice Cream Sandwich (15)
Hafiyyan's avatar
Hafiyyan committed
25
- Installed Library :
Hafiyyan's avatar
Hafiyyan committed
26
27
28
29
    1. [Roughike Bottombar](https://github.com/roughike/BottomBar) 
        Defining footer tab with much easier way.    
    2. [Retrofit](square.github.io/retrofit/) 
        Tool for getting Http Request.
Hafiyyan's avatar
Hafiyyan committed
30
    3. [GSON](https://github.com/google/gson)
Hafiyyan's avatar
Hafiyyan committed
31
        Convert a Response from Retrofit into Gson, and can be converted into JSON Format.
Hafiyyan's avatar
Hafiyyan committed
32
    4. [JUnit](http://junit.org/junit4/)
Hafiyyan's avatar
Hafiyyan committed
33
        Simple framework to write repeatable tests.
Hafiyyan's avatar
Hafiyyan committed
34
    5. [Espresso](https://google.github.io/android-testing-support-library/docs/espresso/)
Hafiyyan's avatar
Hafiyyan committed
35
36
37
38
39
        Tool for creating Instrumental tests.
    6. [JaCoCo](https://github.com/jacoco/jacoco)
        Tool for creating Code Coverage Report.
    7. [Gradle Console Reporter](https://github.com/ksoichiro/gradle-console-reporter)
        Print all Gradle Report into Console.
Agni's avatar
Agni committed
40
    8. [Firebase](https://firebase.google.com/docs/cloud-messaging/android/client)
Agni's avatar
Agni committed
41
	    Push Notification
agni.wira's avatar
agni.wira committed
42
    9. [Swipe Reveal Layout](https://github.com/chthai64/SwipeRevealLayout)
Agni's avatar
Agni committed
43
44
45
46
47
	    Tool for make a layout that you can swipe/slide to show another layout.
    10. [MPAndroidChart](https://github.com/PhilJay/MPAndroidChart)
        Tool for creating Chart
    11. [Crashlytics](https://fabric.io/kits/android/crashlytics)
        Tool for report crash
Hafiyyan's avatar
Hafiyyan committed
48
49
50
51
    
### Development Guideline

1. Test Driven Development
Hafiyyan's avatar
Hafiyyan committed
52
53
54
55
56
57
2. To maintain high **Code Coverage** (which is important), make sure to:
    - Write **Unit Test** that cover all lines in function
    - Separate code that doesn't involved in **Unit Testing** (Read more about Unit Testing to understand it)
    into another package, and then exclude those package from **Code Coverage Report**
    - To exclude the package that doesn't need to be reported, please see file **jacoco.gradle** and see **classDirectories**, part **excludes** 
3. Clean Code (I'll only write some main points that I think it's important to remember, for further information, please read Books about Clean Code)
Hafiyyan's avatar
Hafiyyan committed
58
59
60
61
62
63
64
65
    
    1. Create a **Meaningfull Names** when you create a function, class, or variable
    2. Create a **Function that handle 1 specific task** instead of 1 function for many task
    3. Create a **Comments** for every important parts of code, to make an easier understanding of code
    4. Create a **Code that Self Explained** to make the code easier to read
    5. Create many **Small Function** when solving some problem is easier to do rather than creating 
    1 large function. It's also easier to maintain if you have this kind of function

Hafiyyan's avatar
Hafiyyan committed
66
4. Coding Guideline (For further information please visit this [link](https://source.android.com/source/code-style))
Hafiyyan's avatar
Hafiyyan committed
67
68

   - Never write a code that doesn't handle an exception, always make sure that you catch every exception and give some feedback to user when that happen (Exception handling)
Hafiyyan's avatar
Hafiyyan committed
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
   
   ```java
   /** Set port. If value is not a valid number, 80 is substituted. */
   
   void setServerPort(String value) {
       try {
           serverPort = Integer.parseInt(value);
       } catch (NumberFormatException e) {
           serverPort = 80;  // default port for server
       }
   }
   ```
   
   - When handling exception, make sure that you doesn't use Generic Exception as a way to catch those exception,
   unless you doesn't sure what kind of error will be raised on the code
   
   ```java
   try {
       gettingDatafromAPI();        // may throw HttpException
       convertDataToJSON();   // may throw ParsingException
       calculateItAndReturn();  // may throw NumberFormatException
       // phew, made it all the way
   } catch (Exception e) {                 // I'll just catch all exceptions
       handleError();                      // with one generic handler!
   }   
   ```
   
   - When you importing some module or package, use full path import so we can make sure what package are imported,
   unless it's come from Java Standard Library
Hafiyyan's avatar
Hafiyyan committed
98
    
Hafiyyan's avatar
Hafiyyan committed
99
    ```java
Hafiyyan's avatar
Hafiyyan committed
100
101
      import android.support.v4.app.*; //Doesn't know which pacakage is needed, so it's bad
      import android.support.v4.app.Fragment //Fragment with compat support is imported
Hafiyyan's avatar
Hafiyyan committed
102
    ```
Hafiyyan's avatar
Hafiyyan committed
103
104

   - Use proper Naming Convention
Hafiyyan's avatar
Hafiyyan committed
105
106
107
108
109
110
111
112
113
114
   
   ```java
      public static final int SOME_CONSTANT = 42; //For Final variable, use all Uppercase Letter
      private static MyClass sSingleton; //When using staticm use s at the beginning of name
      private int mPrivate; // When using non-public/non-static, use m at the beginning of name
      public int publicField; //Others, use lowercase at first word
   ```
   - Use TODO Comments when you're creating a temporary solution (line of code, or function) to make
   an understanding to next developer that this function needs some fixing

Agni's avatar
Agni committed
115
116
117
118
119
### Hierarchy Android file
1. **activity**	: activity class
2. **adapter**	: adapter class for ListView / RecyclerView
3. **database** : initiate database and model handler
4. **fragment** : fragment class
agni.wira's avatar
agni.wira committed
120
5. **helper**   : utility (ie Firebase notification, NotificationID generator)
Agni's avatar
Agni committed
121
122
123
124
6. **model**	: model class
7. **schema**	: schema database
8. **service**	: service (Retrofit and Alarm) 
9. **task**     : Asynctask for calling API
125

Agni's avatar
Agni committed
126
### API Access 
127

Agni's avatar
Agni committed
128
You can edit Configuration File for API access in build.gradle (Module:app) foreach build types [Click Here](app/build.gradle)
129

Hafiyyan's avatar
Hafiyyan committed
130
### Virtual Machine (Server)
Agni's avatar
Agni committed
131
132
link : https://myui-dev.cs.ui.ac.id/backend/

133
134
135
136
137
    - server built using Django
    - database using sql
    - push notification using firebase
    - more requirement can be seen on requirement.txt (use : **pip update -r requirement.txt** )
    
Agni's avatar
Agni committed
138
139
140
141
Server's job :
   - get token for access siak
   - push notification news scele
   - save log tombol darurat
142
143
144
145
146
147
148
149


### Hierarchy on backend-project :

1. **myui_backend**          : contain all backend function for myui
2. **myui_backend_project**  : project on django


agni.wira's avatar
agni.wira committed
150
All Right Reserved to Team Fasilkom UI