0% found this document useful (0 votes)
24 views

GitHub - nprapps:bestpractices: Best practices and coding conventions for the NPR Visuals team.

Best practices and coding conventions for the NPR Visuals team.

Uploaded by

zvqjjkz49g
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

GitHub - nprapps:bestpractices: Best practices and coding conventions for the NPR Visuals team.

Best practices and coding conventions for the NPR Visuals team.

Uploaded by

zvqjjkz49g
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

nprapps / bestpractices Public

Code Issues 10 Pull requests Actions Projects Wiki Secu

1 Branch 0 Tags Go to file About Go to file Code

Best practices and coding conventions


connjin Update assets.md: upda…
for the NPR Visuals team.
22c1f08 · 2 months ago 65 Commits
blog.apps.npr.org/

R… Rem… 6 years ago Readme

Activity
a… Upda… 2 months ago
Custom properties
g… Add … 6 years ago
292 stars

h… Style… 7 years ago 47 watching

29 forks
j… Upda… 5 years ago
Report repository
p… Not a… 11 years ago

Releases

README No releases published

Packages
NPR Visuals' No packages published

Best Practices
Contributors 6

The contents of this repository


are released under a Creative
Commons CC BY 3.0 License.

Index
Project documentation
Naming things
Version control
Servers
HTML and CSS
Javascript
Python
Assets

Project documentation

Always ensure the following


things are documented in the
README:

Steps to setup the project


from a blank slate. (Data
loading, etc.)
Required environment
variables. If these are secrets
they should also be stored in
the team Dropbox.
Cron jobs that must be
installed on the servers.
When using the app-template
specifying these in the
crontab file is sufficient.

Dependencies that are not


part of our standard stack.
This includes documenting
how to install them.
Whenever feasible this
documentation should be in
the form of fab commands.

Naming things

Naming things (variables, files,


classes, etc.) consistently and
intuitively is one of the hardest
problems in computer science. To
make it easier, follow these
conventions:
Always proceed from more
general to more specific. For
example, widget-skinny is
better than skinny-widget .
Strive for parallelism. If you
have a begin() function,
then have an end() function
(not stop() or done() ).
Group related names with
common prefixes, e.g.
search_query and
search_address .

Prefer more specific terms to


more vague ones. If it's an
address call it address , not
location .

When a function operates on


a variable, their naming
should be consistent. If
working with updates then
process_updates() , don't
process_changes() .

Maintain naming conventions


between lists and their
iterators: for update in
updates , not for record
in updates .

Prefer... to...

create insert, add, new

update change, edit

delete remove, purge

setup init

make build, generate

wrapper wrap

render draw
(Note: sometimes these words
don't mean the same thing, but
when they do, prefer the former.)

Version control
Development of major
features should happen on
separate branches which
periodically merge from
master until development of
the feature is complete.
Never, ever store
passwords, keys or
credentials in any
repository. (Use environment
variables instead.)

See git.md.

Servers

Environment variables belong


in /etc/environment . This
file should be sourced by
cron jobs. (This happens
automatically when using
run_on_server.sh .)# git

HTML and CSS


See html_and_css.md.

Javascript

See javascript.md.

Python
See python.md.

Assets
See assets.md.

You might also like