Fakultas Ilmu Komputer UI

readme.md 19.6 KB
Newer Older
Ade Azurat's avatar
Ade Azurat committed
1
2
3
# Practical Final Exam - Advanced Programming - 2019 - Fasilkom UI
## This repository is a modified version from the original https://github.com/spring-projects/spring-petclinic

Ade Azurat's avatar
Ade Azurat committed
4
Students are expected to study from any relavant and avalaible resources on this topic as part of their exam preparation.
Ade Azurat's avatar
Ade Azurat committed
5
6
7
8
9
10
11
12

Main changes are:
1) This Practical Final Exam is using gradle build tool instead of maven. You can revert back to maven if you prefer.
2) This repository may contains bugs, altered/missing files, ugly layout or other things which are part of the exam. Study it very well.
3) The readme text below is from the original repository. You need to modified it to suit your work and preferences in your own repository.
4) Exam Problem will be available here in the readme.md in time. Check the scheduled carefully.

-------------------
Ade Azurat's avatar
Ade Azurat committed
13

Ade Azurat's avatar
Ade Azurat committed
14
15
16
17
18
19
20
21
22
23
24
# Problem 0: Preparation
## Duedate: Thursday, 16 May 2019 8:00 
## Point: 15%

1) create gitlab.cs.ui.ac.id account
2) clone the repository to your on project repository. Make sure you set your project as private and give full access to `@ade (Ade Azurat - ade@cs.ui.ac.id)`
3) Modify the title of the clinic to your preferences such as `Fasilkom Pet Clinic`
4) Build and Run the project in your machine. Fix and make other necessary changes if needed. 
5) Create CI/CD to the VPS (Virtual Private Server) of your convenience.
6) Modify the readme, make sure you put the url in your readme to test your software product and make sure it's run and accesible from the internet.
7) Modify the readme, to provide information of how to re-do your project (including to set-up CI/CD and deployment to an VPS)
Ade Azurat's avatar
Ade Azurat committed
25

Andhar1's avatar
Andhar1 committed
26
27
28
29
30
URL for testing the software product: https://fasilkom-pet-clinic.herokuapp.com/
Information of how to re-do my project:
Firstly, I created a gitlab.cs.ui.ac.id account and created a new online gitlab repository to store files for the Advanced Programming Practical Final Exam. Secondly, I clone the Practical Final Exam - Advanced Programming - 2019 - Fasilkom UI repository to my own repository that I just created, set the project as private and give full access to pak Ade (`@ade (Ade Azurat - ade@cs.ui.ac.id)`). Thirdly, I modified the title of the clinic to `Fasilkom Pet Clinic`. Fourth, I tried to build and run the project, and I was able to run the application from localhost:8080. Fifth, I created a new application in heroku named fasilkom-pet-clinic. Six, I set-up CI/CD to heroku by creating a .gitlab-ci.yml file and set the environment variables in gitlab CI/CD settings so that I can deploy the application to heroku. Seven, I generated css files from the Maven build and put the css files in the static.resources folder in src folder as an external css. Lastly, I pushed all of the changes in the project (such as adding the .gitlab-ci.yml file, putting css files in the static.resources folder in src folder) to the gitlab and as a result, the application is deployed.  


Ade Azurat's avatar
Ade Azurat committed
31
32
-------------------

Ade Azurat's avatar
Ade Azurat committed
33
34
35
# Problem 1: Heritage Pet
## Exam Preparation - Simulation
## Thursday 16 May 2019 at 8:10 - 9:50 (100 Minutes)
Ade Azurat's avatar
Ade Azurat committed
36
37
## Point: 20%

38
39
40
41
Type of problems: 
- 1 small code modification, 
- 1 bonus problem

Ade Azurat's avatar
Ade Azurat committed
42
43
44
45
46
47
48
49
Problem Description: Every pet should have father and mother. 
When adding new pet, user can also put the father and mother.
It is possible that some pets don't have information about their
parents. The father and mother of a pet should also be registered in
the system although probably with different owners. 
Otherwise the pet entry should be rejected. 
Modify the pets tabel to show the information of their parents.

50
Apply some possible and relavant topics that you have learned so far
Ade Azurat's avatar
Ade Azurat committed
51
52
53
54
55
56
57
58
but applied it wisely since the time is so limited. 
Make sure you do it iteratively and always commit and push your works
into the repository regularly. Evaluation will be based on your commits in 
your repository before 10:00. 

No other information is given. No question answer. Do your best in the limited time. 
Be creative, critical and innovative related to the possible incomplete information
in the given problem description. Think carefully and be wise in 
59
60
applying your knowledge and calculating the time to do it. You don't have to apply
all of the topics you have learned. Choose wisely. 
Ade Azurat's avatar
Ade Azurat committed
61
62
63
64
65
66

### Bonus Problem: 

If a pet have kids, also show the information about the number of kids it have.

Good luck. 
Ade Azurat's avatar
Ade Azurat committed
67

Andhar1's avatar
Delete    
Andhar1 committed
68

Ade Azurat's avatar
Ade Azurat committed
69
70
-------------------

71
# Problem 2: Pets Traversing 
72
## Take Home, begin on Friday 17 May 2019 16:00 
73
## Expected duration: 90 minutes coding, 10 minutes technical writing
Ade Azurat's avatar
Ade Azurat committed
74
75
76
## Duedate: Monday 20 May 2019, 8:30 
## Point: 15%

77
78
79
80
81
Type of problems: 
* medium code modification, 
* medium readme modification.

Problem description: 
82
The clinic have the information of the pets heritage. The owner of the clinic indicates
83
84
that probably later he would like to know the total number of pets in the clinic,
the eldest pets in the family of pets in the clinic, 
85
or any other data processing that may require traversing the pets data. 
86
87
88
89
90
91
92
93
94
95

As an advanced programmer that has learned design pattern from the Design pattern book, 
you realize that it is a common use case of design pattern. 

*Your task:* 
* Refactoring your code with the appropriate design patterns to ease 
the maintanance process when adding new features related to data traversing. 
(Choose wisely! :) )
* Modified the readme.md, add information about what pattern, why and how you apply the design pattern.
* Put in your readme.md:
96
97
98
  * the badge of pipelines status, 
  * test status, and 
  * test coverage
99
100
101
102
103
104
* Put information about the URL of your running application, put your name and your pet clinic`s name 
* Pay attention of possible incorrect business logic or bugs 

*Warning:* You should complete the previous problem of pets heritage before doing
this problem. 

105
106
107
*Hint:* It is very common on the first try you would need a lot more time. Try to redo the task 
several times, until you reach the expected time. You may need to use different branchs or
repositories to do that. _Practice makes perfect!_
108
109

*Notes:* You may ask others and work together with your friends. 
110
Make sure you re-do it again individually. 
111
Make sure you really understand how it works.
Ade Azurat's avatar
Ade Azurat committed
112

MUHAMAD ANDHAR DEZAN's avatar
MUHAMAD ANDHAR DEZAN committed
113
114
115
116
I am using Composite Pattern and Iterator Pattern. This is because I want to add many features under Pet Heritage and I want to traverse those data.
The badge of pipeline status: Fail
Test Status :
Test Coverage : Unknown
Ade Azurat's avatar
Ade Azurat committed
117
118
119
-------------------

# Problem 3-4: Practical Exam Session (Duration: 100 minutes)
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
## Will be available on Monday 17 May 2019 10:00  
## Point: 50% (both 3 and 4)

Type of problems: 
* 1 small modification, (3b)
* 1 medium modification, (3a)
* small readme modification, (3 all)
* 1 group project modification, (4)
* 1 bonus problem

# Problem 3: Practical Exam Session 
### Begin Monday, 20 May 2019 at 10:00 - 12:30 
### Point Contribution: 30% of the whole practical exam. 

There are two problems, **Problem 3a** and **Problem 3b**.
Students can choose one of the given problem. One is more difficult than 
the other but can give you maximum 100 points (Problem 3a) if you could finish it perfectly. 
The other is easier but can only give you maximum 80 points (Problem 3b). 
If you were having difficulty during the simulation session, you are suggested to
go with **problem 3b**

## Problem 3a: Pet Descendents
### Maximum score: 100 points. (Make sure you have finished and understood the previous problems.)
 
The owner of the clinic would like to have a unique idea for the clinic.
It is the uniqueness of the clinic. 
He would like to show the biggest pet clan in the landing page. 
He defined it as: **the pet that has the biggest number of pet descendants**. 

Your task is to please the owner with your application 
added with some new features related to his idea. 
Make sure you create it the best you can. 
There are no specific requirements. Impress and surprise the owner. 
Be creative, such as show the name of the pets, number of descendants
154
155
or possibly other things such as other clans, or biggest clan of each animal
or possibly picture (if you have times). 
156
157
158
159
160
161
162
163
164

Having continue with your previous works of applying the appropriate 
design pattern for pet heritage traversal, write a brief description 
in your readme of how you implement the feature. 
Explain in your readme if the previous design pattern is suitable
and ease you in implementing the feature or not.
Write the URL of your running application.

Make sure you apply Clean Code, CI/CD and TDD. 
165
To prove the application of TDD. Make sure you have several  
166
167
168
169
170
171
172
173
174
175
176
177
178
commits of unit test in the repository 
before you implement the function. 

**Hint:** you are challenged to work iteratively and efficiently. 
Do one thing at a time. Commit and push regularly. 
It is not possible to complete all your ideas in a very limited time. 
Make sure you can choose the minimum requirements such as identifying
a pet that has the biggest number of pet descendants, but stay aware
of the owner vision of having a unique feature/information of the clinic.

## Problem 3b: Vets Cost
### Maximum score: 80 points (you can solve the problem even if you haven't solved/understood the previous one)

179
Every vets have a fix price for one visit for any type of animals.
180
181
(The cost for any type of animal is the same) 
Modify the model and also the database to add field about price in each vets. 
182
In the list of visit, show the cost of each visit.
183
184
185
186
187
188
189
190

Write a brief explanation in your readme.md of how you solve this problem.
Write the URL of your running application. 
Make sure you apply Clean Code and TDD. 
To prove the application of TDD. Make sure you have several separate 
commits of unit test in the repository 
before you implement the function. 

Andhar1's avatar
Andhar1 committed
191
192
193
I try to solve by modifying the model and the database
URL of running application :https://fasilkom-pet-clinic.herokuapp.com/

194
195
196
**Bonus:** (additional 20 points) If you can calculate information of the total
pets owner have paid for their pets`s visit. 
Show the total cost in the list of pets owner, and list of pets. 
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267

## Problem 4: Group Project Contribution.
### Begin Monday, 20 May 2019 at 10:00 - 12:30 
### Point Contribution: 20% of the whole practical exam. 

You have been working hard for your group project.
However due to limited time, some of the best practice
cannot be applied.
There are several features has not been implemented as well.

During this practical session. You have additional time 
to add another contribution of at least **10 lines of code**.

Your contribution can be in the form of bug fixing, 
fixing code smells, continuing previous unfinished work,
add new function/features, unit testing, refactoring or other coding
related activities. 
Make sure you do **commit** and **push** your new contribution before 12:30.

Inform your latest contribution (the link of the commits) in this URL. 


[https://forms.gle/AmkzqDa7TGdMqPJJ7]

-------------------

## Problem Bonus: Advanced Pet Clinic 
### Begin Monday, 20 May 2019 at 10:00 - 12:30 
### Point: up to maximum 20 points added to your final practical session exam.

Your Pet Clinic application is awesome. 
They received so many visit request per day, many vets are happy to join 
your clinic. The number of registered pets, grows rapidly. Visit of all pets 
are scheduled well. The pets are healthy and happy. 
The customers (pets owner) are very happy. 
They visit your application regularly. 
The happiest of all is the owner. 
He extends the contract and give you significant bonus.

While you are on vacation, enjoying your bonus, 
your mailbox is full of email request of your application. 
Other pet clinic owners are considering to buy your software. 
They also would like to be able to be registered in your system. 

What do you have in mind for such a promising and profitable opportunity?
As an advanced programmer, you have learned the issue about scalability, 
micro-services, design pattern and other advanced topics related to software 
scalability and maintenance.

Given a very limited time that you still have, try to:
- Write in your ``readme.md``, what is your plan related to advanced programming. (make it brief.)
- Create a new branch. The branch name is ``bonus``
- Work on your plan, the best you can in that branch. 
- Make sure you **commit** and **push** before the deadline (**12:30 today!**). 
- If your plan is not involving coding, try to give 
some related artifacts that can be used to evaluate 
the quality and quantity of your works. 
You can send it by email to ``ade@cs.ui.ac.id``


-------------------

_End of Exam Problems. Good luck and happy coding!_

-------------------
_Add your notes here:_
-------------------


-------------------

Ade Azurat's avatar
Ade Azurat committed
268

Ade Azurat's avatar
Ade Azurat committed
269
270
271
272
273
274
275


-------------------

# Spring Petclinic
## Original readme - need to be modified!

Ade Azurat's avatar
Ade Azurat committed
276
-------------------
277

278
279
280
## Understanding the Spring Petclinic application with a few diagrams
<a href="https://speakerdeck.com/michaelisvy/spring-petclinic-sample-application">See the presentation here</a>

281
## Running petclinic locally
figueroaRicardo's avatar
figueroaRicardo committed
282
Petclinic is a [Spring Boot](https://spring.io/guides/gs/spring-boot) application built using [Maven](https://spring.io/guides/gs/maven/). You can build a jar file and run it from the command line:
Dave Syer's avatar
Dave Syer committed
283
284


Mic's avatar
Mic committed
285
```
Olivier Truong's avatar
Olivier Truong committed
286
287
288
289
git clone https://github.com/spring-projects/spring-petclinic.git
cd spring-petclinic
./mvnw package
java -jar target/*.jar
Mic's avatar
Mic committed
290
```
Mic's avatar
Mic committed
291

292
You can then access petclinic here: http://localhost:8080/
293

Antoine Rey's avatar
Antoine Rey committed
294
295
<img width="1042" alt="petclinic-screenshot" src="https://cloud.githubusercontent.com/assets/838318/19727082/2aee6d6c-9b8e-11e6-81fe-e889a5ddfded.png">

Dave Syer's avatar
Dave Syer committed
296
297
298
Or you can run it from Maven directly using the Spring Boot Maven plugin. If you do this it will pick up changes that you make in the project immediately (changes to Java source files require a compile as well - most people use an IDE for this):

```
Olivier Truong's avatar
Olivier Truong committed
299
./mvnw spring-boot:run
Dave Syer's avatar
Dave Syer committed
300
301
```

Mic's avatar
Mic committed
302
## In case you find a bug/suggested improvement for Spring Petclinic
michaelisvy's avatar
michaelisvy committed
303
Our issue tracker is available here: https://github.com/spring-projects/spring-petclinic/issues
Mic's avatar
Mic committed
304

305
306
307
308
309

## Database configuration

In its default configuration, Petclinic uses an in-memory database (HSQLDB) which
gets populated at startup with data. A similar setup is provided for MySql in case a persistent database configuration is needed.
Dave Syer's avatar
Dave Syer committed
310
Note that whenever the database type is changed, the app needs to be run with a different profile: `spring.profiles.active=mysql` for MySql.
311

Dave Syer's avatar
Dave Syer committed
312
You could start MySql locally with whatever installer works for your OS, or with docker:
313
314
315
316
317

```
docker run -e MYSQL_ROOT_PASSWORD=petclinic -e MYSQL_DATABASE=petclinic -p 3306:3306 mysql:5.7.8
```

318
## Working with Petclinic in your IDE
319

figueroaRicardo's avatar
figueroaRicardo committed
320
### Prerequisites
321
The following items should be installed in your system:
Dave Syer's avatar
Dave Syer committed
322
* Java 8 or newer.
Mic's avatar
Mic committed
323
* git command line tool (https://help.github.com/articles/set-up-git)
324
* Your prefered IDE 
Stephane Nicoll's avatar
Polish    
Stephane Nicoll committed
325
326
  * Eclipse with the m2e plugin. Note: when m2e is available, there is an m2 icon in `Help -> About` dialog. If m2e is
  not there, just follow the install process here: https://www.eclipse.org/m2e/
327
328
  * [Spring Tools Suite](https://spring.io/tools) (STS)
  * IntelliJ IDEA
329

Mic's avatar
Mic committed
330
### Steps:
331

332
1) On the command line
Mic's avatar
Mic committed
333
```
michaelisvy's avatar
michaelisvy committed
334
git clone https://github.com/spring-projects/spring-petclinic.git
Mic's avatar
Mic committed
335
```
336
2) Inside Eclipse or STS
Mic's avatar
Mic committed
337
338
339
340
```
File -> Import -> Maven -> Existing Maven project
```

341
Then either build on the command line `./mvnw generate-resources` or using the Eclipse launcher (right click on project and `Run As -> Maven install`) to generate the css. Run the application main method by right clicking on it and choosing `Run As -> Java Application`.
342

343
3) Inside IntelliJ IDEA
344

345
346
347
348
349
350
351
352
In the main menu, choose `File -> Open` and select the Petclinic [pom.xml](pom.xml). Click on the `Open` button.

CSS files are generated from the Maven build. You can either build them on the command line `./mvnw generate-resources`
or right click on the `spring-petclinic` project then `Maven -> Generates sources and Update Folders`.

A run configuration named `PetClinicApplication` should have been created for you if you're using a recent Ultimate
version. Otherwise, run the application by right clicking on the `PetClinicApplication` main class and choosing
`Run 'PetClinicApplication'`.
353
354
355
356

4) Navigate to Petclinic

Visit [http://localhost:8080](http://localhost:8080) in your browser.
Dave Syer's avatar
Dave Syer committed
357

Mic's avatar
Mic committed
358
359
360

## Looking for something in particular?

Antoine Rey's avatar
Antoine Rey committed
361
362
|Spring Boot Configuration | Class or Java property files  |
|--------------------------|---|
363
364
|The Main Class | [PetClinicApplication](https://github.com/spring-projects/spring-petclinic/blob/master/src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java) |
|Properties Files | [application.properties](https://github.com/spring-projects/spring-petclinic/blob/master/src/main/resources) |
365
|Caching | [CacheConfiguration](https://github.com/spring-projects/spring-petclinic/blob/master/src/main/java/org/springframework/samples/petclinic/system/CacheConfiguration.java) |
Mic's avatar
Mic committed
366

367
368
## Interesting Spring Petclinic branches and forks

369
370
371
372
373
The Spring Petclinic master branch in the main [spring-projects](https://github.com/spring-projects/spring-petclinic)
GitHub org is the "canonical" implementation, currently based on Spring Boot and Thymeleaf. There are
[quite a few forks](https://spring-petclinic.github.io/docs/forks.html) in a special GitHub org
[spring-petclinic](https://github.com/spring-petclinic). If you have a special interest in a different technology stack
that could be used to implement the Pet Clinic then please join the community there.
374
375


Mic's avatar
Mic committed
376
377
## Interaction with other open source projects

Mic's avatar
ref doc    
Mic committed
378
One of the best parts about working on the Spring Petclinic application is that we have the opportunity to work in direct contact with many Open Source projects. We found some bugs/suggested improvements on various topics such as Spring, Spring Data, Bean Validation and even Eclipse! In many cases, they've been fixed/implemented in just a few days.
Mic's avatar
Mic committed
379
380
Here is a list of them:

381
382
383
384
385
| Name | Issue |
|------|-------|
| Spring JDBC: simplify usage of NamedParameterJdbcTemplate | [SPR-10256](https://jira.springsource.org/browse/SPR-10256) and [SPR-10257](https://jira.springsource.org/browse/SPR-10257) |
| Bean Validation / Hibernate Validator: simplify Maven dependencies and backward compatibility |[HV-790](https://hibernate.atlassian.net/browse/HV-790) and [HV-792](https://hibernate.atlassian.net/browse/HV-792) |
| Spring Data: provide more flexibility when working with JPQL queries | [DATAJPA-292](https://jira.springsource.org/browse/DATAJPA-292) |
Mic's avatar
Mic committed
386
387


Antoine Rey's avatar
Antoine Rey committed
388
389
390
391
# Contributing

The [issue tracker](https://github.com/spring-projects/spring-petclinic/issues) is the preferred channel for bug reports, features requests and submitting pull requests.

Stephane Nicoll's avatar
Polish    
Stephane Nicoll committed
392
For pull requests, editor preferences are available in the [editor config](.editorconfig) for easy use in common text editors. Read more and download plugins at <https://editorconfig.org>. If you have not previously done so, please fill out and submit the [Contributor License Agreement](https://cla.pivotal.io/sign/spring).
Antoine Rey's avatar
Antoine Rey committed
393

Antoine Rey's avatar
Antoine Rey committed
394
# License
Antoine Rey's avatar
Antoine Rey committed
395

Stephane Nicoll's avatar
Stephane Nicoll committed
396
The Spring PetClinic sample application is released under version 2.0 of the [Apache License](https://www.apache.org/licenses/LICENSE-2.0).
397
398
399
400
401
402
403
404
405
406

[spring-petclinic]: https://github.com/spring-projects/spring-petclinic
[spring-framework-petclinic]: https://github.com/spring-petclinic/spring-framework-petclinic
[spring-petclinic-angularjs]: https://github.com/spring-petclinic/spring-petclinic-angularjs 
[javaconfig branch]: https://github.com/spring-petclinic/spring-framework-petclinic/tree/javaconfig
[spring-petclinic-angular]: https://github.com/spring-petclinic/spring-petclinic-angular
[spring-petclinic-microservices]: https://github.com/spring-petclinic/spring-petclinic-microservices
[spring-petclinic-reactjs]: https://github.com/spring-petclinic/spring-petclinic-reactjs
[spring-petclinic-graphql]: https://github.com/spring-petclinic/spring-petclinic-graphql
[spring-petclinic-kotlin]: https://github.com/spring-petclinic/spring-petclinic-kotlin
Antoine Rey's avatar
Antoine Rey committed
407
[spring-petclinic-rest]: https://github.com/spring-petclinic/spring-petclinic-rest