Programming paradigms and best practice Flashcards
What is a programming paradigm?
a style or way of programming
What is POP?
Procedural orientated programming
- Top down approach
- A list of instructions that tell the computer what to do step by step. It relies on procedures or routines
What is OOP?
About encapsulating data and behaviours into objects
Based upon classes, methods and objects
a. Class- ‘blueprint’ for an object and its associated attributes
b. Methods- functions that define behaviour
c. Objects- instances of a class
Classes may inherit attributes and methods from other classes and a class may have another class as an attribute
What are the advantages of using a OOP paradigm?
- Can reuse code
- Easier to maintain
- As the code is modular, parts of the system can be changed or updated easily
- Faster development as you can reuse code
What is functional programming?
a. Programming with function calls that avoid any global state
b. Functions are treated as data
c. Data is immutable
d. Functions take data as input and return an output dependent on the input
What are the 10 principles for programming best practice?
- Commenting and documentation
- Consistent indentation
- Avoid obvious comments
- Consistent naming system
a. camelCase
b. Underscores - Write DRY code
- Avoid deep nesting
- Limit line length ~80 characters
- Consistent temporary names- for k,v…
- Capitalize SQL special words
- Use version control
What is PPP?
Pseudocode Programming Process
Pseudocode refers to an informal, natural language-like notation for describing how an algorithm or a programme will work
What is version control?
Process of managing changes to documents or programs
a. E.g. Github
Enables traceability of any changes that occur to a document and allows the user to compare, restore and in some cases merge files
Changes are labelled using informative commit messages
Required by Whiffin et al’s 2017 NGS pipeline best practice
What are the benefits of using version control?
- Important for accountability, traceability, QA and audit
- Allows developers to keep track of where they are in the development process
- Facilitate collaborative working
What are the 6 steps in a the github version control workflow?
- Raise an issue
- Fork the code and create a development branch
- Make changes and commit
a. Commits should contain informative messages - Send pull request
- Other developer will review pull request
- If changes are accepted, these are merged to the master branch