Chapter 05: System Implementation
5.2 Extending the base class to DatePickerlnputs
5.2.1 Define properties of the sub-classes
1. Create widgets.py file to contain all the sub-classes.
2.
All classes will extend the BaseDatePickerlnput class.3.
Classes will override the default values to render different date-picker widgets.5.2.1 Exporting the DatePickerlnput Classes
lmporting
into init
.py makes selected CIasses, functions, etc accessible to the package levelso
theycan
be conveniently imported fromthe
package. Sowe will
importthe
DatePickerlnput classes to_init
.py file to make it accessible outside of the package.38
5.3 Publish to a Github repository
GitHub
lnc. is a
web-based hosting servicefor
version control usingGit. lt is
mostly used for computer code. !t offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features.5.3.1 Objectives
1. Create a fresh repository [1]
2.
Short, memorable but self-explanatory name for the repository3.
Add a description to the repository that best describes the package4.
Make the repository public for community suggestions and feedbacks5.
lnitialize this repository with a README which best represents the package.I
T
l
*=
.
I
5.4 Publishing to PyPl
The Python Package lndex (PyPl) is a
repositoryof
softvyarefor the python
programming 'language- PyPl helps find and installsoftware developed and shared by the python communig.Package authors use PyPl to distribute their software.
.z
:
*
t;
t I=t.
t:
I=t1 E_
I
f:E
c
Fi'j
=j.
5.4.1 Objectives
!
Retease lristory*
Downtoad files1.
Host the package on PyPl for easy instaltation via pip [2].2.
Give the package a unique name that is self-explanatory and search friendly3-
Upload and maintain different versions of the package with proper dependencies.8ootstrop3,,'Boofsfrrp4 oafePirlrerfnp&L tri,?iePrrkerfnput, Octelirn eqickertnput^&tronr&picirerlnpuf.. -yeorFickerinpr.,tr r,ffilh d at*-ra n Ee- p i cker fu nct onclr4. fcr {'tlngo uers;on Z 0.5. i. t i, l. I 0 s n d l.
I
Project description
This django widEet containE Bootstrap3y'Boor:trap4 BateFickerinput, Timepickerlnput, DateTirneFickertnput. l.{onthPickerfnput, yearpickerlnpLrt r,'r'ith date-range-picker functiona[ity for django version 2.0,s, 1.11, 1"J.0 *nd i..g. The r,vidget implernents bootstrap- datetinrepicker r.,4 to shor,r' beotstrap-datepicker in django model forms and cuslom forms and can b= configured easily for date-rnnge selection.
Figure 5.2: The PYPI page of the package
Navig*tion
4A
5.5 Publishing to Django Packages
Django Packages is a directory of reusable apps, sites, tools, and more for your Django projects.
This is the
plaeeto list
python packagesthat are
specificto
django framework.This
directory contains a huge collection of django reusable resources for the passionate developers to find and implement in their own projects. [3]1.
List the package to a place specific to Django development2.
Make the package more available to Django developers.Repo Activity -r3t'tttfed I +;etl
5.5.1 Objectives
Releases
j:_
:::
Documentation
FyFi
Repo
Comparison Grids
$ite*
using this Figure 5.3: The Django Packages page of the PackageI
5.6 Publish Demo pages
5.6.1 Demo with Bootstrap 3
C? *!jae rgo-hootsirap-datet:icker-pius Gfi Giihilb Demo vi'ith Esetstrap 3 ilit?.ir ?r,ith gr-,iltrstrs$ q
dja
ngo-bootstra p-datepicker-p
Ius wid get co
mpon ents
glart clal€:
2018-05-21
End.tab:
05J232018 stsrt tine:
0e.31 End tnr*:
0s 3t SErtdatetim.:
05i16,2018 12.3.1 EITI .taEtrilE:
05J16i2018 12.31 Stan m6nth:
2018-85-01 End rEofifr:
2018-06-30 Start yBil:
2i,174 1-01 Enal year
2!1 8-1 2-31
a
Figure 5.4: The demo page with bootstrap 3
l
* [- li
l
E
:.- 't
Jr
:
5.6.2 Demo with Bootstrap 4
O d: a-:g* - bcot:i ia!-r- d a ier; irk* r-p i u: o n fi itnub
dj
a n g o -bootstrap -d atep
ic [<er-plu s wid
get ca m pon entg
'::1
LJ
n
t
jr t*
t
:f
*
=
?:
#
ffi
ET
5.7 Publish package documentation (README)
No matter how the quality
of a
product is,a
bookis
always judged by it's cover. The coverof
arepository
is the
READMEof a
Github repository.The
README should containthe
following informations to reflect the important aspects of the package.1. A small introduction to what the repository is all about.
2.
Some repository badges to reflect some insights of the quality of code inside.3.
An image to to display the end result of the package.4.
Some demo links to see the package in action.5.
Prerequisites of the package.6.
Detailed usage guide of the package.7.
Licence and Acknowledgements5.7.1 The lntroduction
dja ngo
-bootstra p-datepi cker- plus
Su I\.Io
Hay 3016
Tu l.!e Th Fr
5u
Ir4 otu5ay 201
I
Tu lAle Th',.j"
Fr 5a
l_l
08 31 5a
x +
_+_I
+
44
i
=
!
t
*
= +
5.7.2 Demo, Getting Started
Demo
a :',:..i1:".:':,, . ':-:::l:l:':.1 +,
Getting
Started Frerequisites. P.,i-ra-r :- = :.3 . [:_;.-:i;* -i:1.I1 r !;1151-1;,>= li
r lXl.ir; r= l.l -t
Installing i-:-:: r.: r'.t,>-,.
:._. _-_:___r_:
i
':.;;iii :i ;:;;::l:r:- :,j,.:',
)
jii!li'',' , '.*:l:t: ':r iala::i{a- :a: ':r'ii:i. '";1a i.Ltr+ -,;-, i"!r.,':_r:;ir., i r.jlif :+i::i;:i ;r..tr:,-) aar ;;i j+-r!.:. i:,: ;;1:j
'. -.h E:::;:.i: r:. i:::-:: '--:-.-:; ):.,2- :a-.:1.--: ---i -: . ti j+:-.:-;!.: 'i : ' ;-. t:.---; ;
=,)i'i-r::a ' i:'!;-5-i,;:j :i''i rlt Liii'r: .r.ii. "r,.,: ii {i?1t? -1't-
: :
t
e
5.7.3 Usage
Usage
(Llstorn Forrn usage
t,ie er
:::=,':'i ;,'-' r';:a-:
46
=
t
F
=
5,7.4 Customising the Options
Testing & Quality Management
=
6.1 Unit-Testing
ln
computer programming, unit testingis a
software testing method by which individual units of source code, setsof
oneor
more computer program modules togetherwith
associated control data, usage procedures, and operating procedures, are tested to determine whether they are fit for use.6.1 .1 Unit-Testing tools
There are many tools for creating tests in Python. Some of these tools, such as pytest, replace the built-in unittest framework. Other tools, such as nose, are extensions that ease test case creation.
Note
that
manyof
these toolsare
also usedfor
integration testing by writingthe test
cases to exercise multiple parts of code at once.unittest
is the built-in standard library tool for testing Python code.pytest
isa
complete testing tool that emphasizes backwards-compatibility and minimizing boilerplate code.nose is an extension to unittest that makes it easier to create and execute test cases.
Hypothesis is a unit
test-generationtool that
assists developersin
creatingtests
that exercise edge casesin
code blocks. The best wayto
get started using Hypothesisis
by going through the well-written quickstart.testify
was a testing framework meant to replace the common unittest+nose combination.However, the team behind testify is transitioning
to
pytest so it's recommended you do not use testify for new projects.a a
a a
6.1 .2 Code for Testing
=
t
E
49
6.1.3 Unit-Testing with pytest
pytest is a mature full-featured Python testing tool that helps you write better programs. The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries.
Test Results:
Figure 6.'t: pytest unit-test results
6.1.4 Unit-Testing with Travis-Cl
Travis
Cl is a
hosted, distributed continuous integration service usedto
build andtest
software projects hosted at GitHub. Open source projects may be tested at no charge via travis-ci.org.6.1.4.1 Travis-Cl build flow
6.1 .4.2 Travis-Cl Result
F
{3 .+€
*""#
E
Figure 6.2: travic-Cl build result
51
6.1.4.3 Travis-Cl build history
!i*Fr€
i*d*
=
,,,=*{13
6.2 Code-Coverage
ln computer science, test coverage is a measure used to describe the degree to which the source code of a program is executed when a particular test suite runs. A program with high test coverage, measured
as a
percentage,has had more of its
source code executed during testing, which suggestsit
hasa
lower chanceof
containing undetected sofiware bugs comparedto a
programwith low test coverage.
6.2.1 Coveralls. io stats
s#ersffeg&s
?.!&
{F
tf ct*
+
tr#tr$ffi sr #Js$€##"###r$rffiss :#gflgtr$#trfftr "f*#$
*ir{q,"rf
:+1:r':.J+rii;
ffi#
q,.-".s
t&1T
$t"i[* *ii
*R&i{{t{ r",.t*:?$*sffiffiffin
M
ffi
E
53
6.2.2 Coveralls.io details and builds
f0vEFsrs,s
=4
fiefE?{T
frlj't*s
ffi
r--i::;.:jffiSE
ffi
j--.:::Figure 6.4: coveralls.io report
6.3 Maintainability
Maintainability
is an
estimateof
technicaldebt in the repo
basedon a
standardized 1O-point assessment of Duplication, Cyclomatic Complexity, Cognitive Complexity, and structural issues.6.3.1 Code-Climate Report
The 10 checks outlined below are enabled by default in Code Climate.
.
,Argumentcount
- Methods or functions defined with a high number of arguments.
Gomplex Iogic - Boolean logic that may be hard to understand.
File length - Excessive lines of code within a single filer ldentical blocks of code -
Duplicate codewhich is
syntactically identical(but may
be formatted differently)o Method complexity -
Functionsor
methodsthat
maybe
hardto
understand (Cognitive Complexity)o
Methodcount
- Classes defined with a high number of functions or methods.
Method length - Excessive lines of code within a single function or methodo
Nestedcontrol flow
- Deeply nested control structures like if or case.
Return statements - Functions or methods with a high number of return statements. Similar blocks
of code - Duplicate code which is not identical but shares the same structure (e.9. variable names may differ)ai
coar crtraalg",..-:i-'
il'r37
(-.)i.i''i:,i.)-:.-ji-r,:t--::,1i:'-t ;
,:-.-:',j
._ i,,.:i'-i_rl.j::,
, .:
, '. al:
,.',, li55
Project Success
.
7.1 Project Stats on Github
a a a
1,11:..r::*::
7.1.1 Watchers
watching
a
Repository registersthe
userto
receive notificationson
new discussions, as well as events in the user's activity feed. See Repository Starring for simple repository bookmarks.These are the developers cunently watching this repository for instant notification of any updates published to this repository.
O r.lt:,r1:ir - ; * i..:rii a.
Watchers
Watchers:7 Stars: 39 Forks: 5
iir-,iai : :, ":i.11
;ii.ti nit ;1
{!
L ,8 'slt
? )i. .a L -tj i; 11;;:;,
iti.:
5
*
r:1 *, t',, :;t 1:;-: :.: ii.:* li'.':..3 -: t:i. t 7: lj: :. t I j..-; I i_
i::: : '
t i'__))'-.\
i:i:.
O ij.i.:t:ir -
56
7 .1
.2 Stars
Repository Starring
is a
featurethat lets
users bookmark repositories. Stars are shown next to repositories to show an approximate level of interest. Stars have no effecton
notifications or the activity feed. For that, see Repository Watching.The project has received 39 stars and this number is still growing as more and more developers find out this package. The usefulness and quality of a project is reflected by these stars provided by the developers who are using it.
Starred by
Stargazers
:L;l'
A.*&*
I -. ._. r .._
i :: :
^
::;r - -,.--,:.
r . -'-'r -- I
t
&u{
7 .1
.3 Forks
A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project. Most commonly, forks are used to either propose changes to someone else's project or to use someone else's project as a starting point for your own idea.
&
7 .1
.4 Msitor Graph
The visitor count keeps on rising as days pass by proving the project is reaching more and more developers making this project a success.
r:'- *
a-
-\,=
=5q- "L €-
-'C----
:,2r, ;ts;- ii::. :i:-r :.-z1 l- :i'
.-\
t -l "t.,, \ ',i
.'\ ',\
".i \ aF_-_r___-**
:- :-i i- ;i l- :,- )-::a
728 ,I2B
€
t
E*ferrng r:tel
.:
-il
(},
$ ::
' ' i- ,, :',,,$ ':'- : ",:,: : : : i::j :j;: :
$
:'.: ::,$ :
.;, :r,:;: :: -,:
: :::.'
._J I i :i"r'-
Ft1:ltlat ir-rfitefrl
le
f:,t=j
tr
l-a,
is]
+
7.2 Activity on Stack-Overflow
7.2.1 Questions on Stack-Overflow
There are 12 questions on stack-overflow about this project all asked by django developers who were having difiiculties
to
implementthis
package to their django powered site. These questions provided a lot information to help make the project more user-friendly and easier to implement.This activity on stack-overflow shows this package is receiving traction more and more developers are being interested in using it in their own project.
:.t;.rckoverflow
Search Results
$ S:ac" !!.{!.:#
a-
r
E
60
7.2.2 Answers on Stack-Overflow
This
answerwere
posted encouragingthe use of this
packagein
djangosite
describing the installation setup and usageof
it which has received5
votes bythe
community members. This shows developers are really appreciating this package as a useful tool for their django sites.- J;':rluary 2OOil
lu {vlo Tu lYe Th
ffi
. Augu:.t iO13
511 l*:s Tri LVtr Th fr frS*t
:,
l,r_:
L _'.
O{tal}.} 200} Fr
5{r f;l$ Tir t.!.ie Th
5.1
ffi
ffi#E
:#*
*
I
r
Conclusion
t
l
I
ts r'
I
-
j
r
i
r
F
=n
L
E E
I
F
8.1 The Experience
hlcrking in this project was
a
big opportunityfor
me.I
have leameda
lot aboutthe
open-soLirce contribution to community software development. The following will indicate the leaming ftom this project.1.
The design and development strategy of a django package.2.
Publishing a well-appreciated project to the biggest online community Github and maintain a meaningful commit history3.
Unit-testing complex scenarios of software development.4.
Writing code withwell
accepted codewriting
guidelines (PEP8).5-
Working with the Travis-Cl build system and incorporating build system to a repository.6.
Generate repository coverage reportswith
Coveralls.io.7.
Learning code maintenance guidelines provided by CodeClimate.8.
Writing clear and thorough documentation of how to use a software.9.
Packaging and uploading a package to PY?ISthon
Packages Index.10. Developing a project with end-user follorv ups. bug reports and feature requests.
11. Developing a product
with
a thoughrful user-*perience"8.2 Future Work
The package
is
published onlineon
both Github andPyFl
package index and thus available to django developers to implement in their djangopower#
sites. lt's receiving lot of appreciation and new features suggestions thatwill
keepthe
project growing. Hereis a
summaryof my
preseili thoughts of future works.1.
Developinga
clock-likeUl for the tim+picker that looks
moreneat and
provide easier selection of time.2.
There are some bugs present in the date'picker library usedto
renderthe Ul
all listed on=
F
.
*
,