Flashcards
Important questions
Cards in this deck (67)
- 1What is an API?An API is a specification of possible interactions with a software component
It defines the rules that programmers must follow in order to interact with and access the features or data of an application.
APIs let your product or service communicate with other products and services without having to know how they’re implemented. This allows a programmer to write code to one software, that can then carry out certain desired actions, without a programmer having to write that software from scratch. - 2What is a REST api?A REST API is an API which is based on the architectural style REST.
It defines a set of functions which developers can use to perform HTTP requests such as GET, POST and DELETE. - 3What is Mongo DB?MongoDB is a NoSQL document-based database that stores data in JSON-like format.
- 4What is separation of concerns?Always separate the code for different purposed into different files.
Structure: HTML. Describes the content in a way that a browser can interpret it
Presentation: Css
Behaviour: Javascript
By separating them into different layers you gain several things. It becomes:
Easier to maintain
Increased performance
Better accessibility
A good foundation for SEO - 5What does "usability" refer to?Usability is a quality attribute that assesses how easy user interfaces are to use.
Usability is defined by 5 quality components:
Learnability: How easy is it for users to accomplish basic tasks the first time they encounter the design?
Efficiency: Once users have learned the design, how quickly can they perform tasks?
Memorability: When users return to the design after a period of not using it, how easily can they reestablish proficiency?
Errors: How many errors do users make, how severe are these errors, and how easily can they recover from the errors?
Satisfaction: How pleasant is it to use the design? - 6Give examples of dark patternsDisguised adverts
Friends spam
Hidden costs
Forced continuity - 7What are dark patterns?Dark Patterns are tricks used in websites and apps that make you do things that you didn't mean to, like buying or signing up for something.
- 8Questions for selecting keywordsWhich keywords they search with?
How frequently they use them?
How relevant they are to you?
How competitive they are? - 9What are arguments agains the overlap of a11y and SEO?The vast majority of the search enginge ranking factors have no relationship of any kind with Accessibility.
In other words, if you’ve optimized a page for search engines, it doesn’t mean you’ve necessarily made it accessible — and vice versa. - 10Why does SEO and a11y go hand in hand?Search engine crawlers can’t see or hear, and they rely on content to rank sites, not images, audio, or video - similar to many people with disabilities. This means that some of the tasks of optimizing for web accessibility overlap with the things we look at for SEO.
For example: Title tags make it easier for people using screen readers to quickly comprehend the differences between pages. Similarly are well chosen titles crucial for good SEO. I.e, often when you optimise for accessibility you improve SEO - 11What is Localisationrefers to the adaptation of a product to meet the language, cultural and other requirements of a specific target market (a locale)
- 12What is i18n?Internationalization is the design and development of a product that enables easy localization for target audiences
For example: if you follow separation of concerns. Keep content and code separate. - 13What is a locale?Locale = language + region + cultural preferences
(a meer translation is always not enough! - 14What is an example of a REST API?The World Wide Web (WWW) is an example of system that uses REST protocol architecture s
- 15What are requriments for an API to be considered "RESTful"?Client–server – client application and server application MUST be able to evolve separately without any dependency on each other.
Stateless – the server does not need to know anything about what state the client is in and vice versa - In this way, both the server and the client can understand any message received, even without seeing previous messages. - 16How are RESTful systems characterized?RESTful systems are characterized by how they are stateless and separate the concerns of client and server.
In the REST architecture, clients send requests to retrieve or modify resources, and servers send responses to these requests. - 17What is REST?Representational state transfer (REST) is a architectural style for creating stateless client-server communications that is typically implemented using the HTTP protocol.
It is a set of conventions that strive to create simplicity and consistency across different web-based applications or APIs. - 18What is the DOM?The Document Object Model (DOM) is a programming interface for HTML documents. It represents the page so that programs can change the document structure, style, and content. The DOM represents the document as nodes and objects. That way, programming languages can connect to the page.
- 19different methods to get elementsgetElementsByTagName
getElementById
getElementsByClassName - 20add element to DOMappendChild()
append() - 21Write a JSON object with name, agemyObj = { "name":"John", "age":30 };
- 22What are the three stages of file in GIT?Untracked: the file exists, but is not part of git's version control
Staged: the file has been added to git's version control but changes have not been committed
Committed: the change has been committed - 23what does git commit do?The git commit command captures a snapshot of the project's currently staged changes.
It save your changes to the local repository. - 24What does Representational state transfer mean?It means when a RESTful API is called, the server will transfer to the client a representation of the state of the requested resource.
For example, when a developer calls Instagram API to fetch a specific user (the resource), the API will return the state of that user, including their name, the number of posts that user posted on Instagram so far, how many followers they have, and more. - 25What is HTTP?HTTP is the protocol used to transfer data over the web. The protocol is the set of rules that conducts the client/server interaction between your web browser and the destination web page
- 26method to find an item by name or id and remove it - mongoosefindByIdAndRemove
findOneAndRemove - 27what are the three assertion styles in Chai?Three Styles:
1. assert – similar to node.js built-in assert
2.expect – BDD style
3.should – BDD Style (requires a function) - 28Write a test with chai that you expect to throw a TypeErrordescribe('test with non-number arguments', function() {
it('findSum(?,?) should throw error', function() {
expect(function() {
sum.findSum('a','b')
}).to.throw(TypeError, 'findSum() expects numbers.')
})
}) - 29Write a test in pure Mocha where you assert that the length of a string "mocha" is exactly 6describe('Mocha Test Example 1', function () {
it('check the length of a string - FAIL', function () {
assert.strictEqual("mocha".length, 6);
});
}); - 30save a user to dbconst User = mongoose.model('users');
const createUser = function (req, res) {
const user = new User({
"id": req.body.id,
"name": req.body.name,
"email": req.body.email,
});
user.save(function (err, newUser) {
if (err) {
res.sendStatus(500);
} else {
res.render('index', {
title: 'Home'
});
}
});
}; - 31Query for finding one or several documents (mongoose)findOne()
example:
Adventure.findOne({ type: 'iphone' }, function (err, adventure) {});
findByID()
// find adventure by id and execute
Adventure.findById(id, function (err, adventure) {});
find()
MyModel.find({ name: 'john'})
find all cafés with - 32What is the HTTP status code for "all good"200
- 33What is the HTTP status code for "Resource Not Found"404
- 34how to we apply specific padding to all sides?padding: top right bottom left
- 35how to we apply specific padding to top/bottom and left/right?padding: 25px 50px;
top/bottom: 25px
right/left paddings are 50px - 36What is the viewport?A viewport is a term for the visible area of a webpage on a display device
The viewport varies with the device, and will be smaller on a mobile phone than on a computer screen. - 37What is DIP?Device Independent
Pixels
It allows you to render content independent of the pixel density of the device - 38What are template engines?JavaScript templating engines enable you to add dynamic logic to static HTML pages. For instance, you can declare a variable that the engine replaces with an actual value at runtime. Similarly, you can use conditionals, loops, filters, mixins, and other constructs, depending on the templating engine you choose.
- 39What is AJAX?Asynchronous JavaScript and XML -describes a set of development techniques for building web applications.
It is a mechanism for the client to
request data from the server without loading/refreshing the entire page
A user’s web browser doesn’t need to reload an entire web page when only a small portion of content on the page needs to change. - 40Do a GET request using AJAX on the url '/users/' + id and read the responsevar url = '/users/' + id;
var request = new XMLHttpRequest();
request.open('GET', url);
request.responseType = 'text';
request.onload = function () {
var res = request.response
};
request.send(); - 41How can we access the data from a XMLHttpRequest ?request.onload = function () {
var res = request.response
} - 42check global installations npmnpm root -g
npm list -g - 43write the mocha assert syntaxassert.equal(50, 70, "My message goes here");
- 44What is BDD?Agile software development process which focuses the testing on the behaviour of the system from the perspective of the end-users.
- 45What is Sinon?Sinon helps eliminate complexity in tests by allowing you to create so called test-doubles. For example it lets you wrap functions in spies or substitute them with stubs.
Very useful when can’t test/touch the production code or you don't have a database to test with. - 46Write a test with CHAI which checks if a functions throws an error if no arguments are passeddescribe('#testing the findSum() function', function() {
context('test without arguments', function() {
it('findSum() should throw error', function() {
expect(function() {
sum.findSum()
}).to.throw(TypeError, 'findSum() expects numbers.')
})
}) - 47Write a test in CHAI which checks if a functions returns a sum of two numbers as expectedcontext('test with two arguments', function() {
it('findSum(n1,n2) should return sum of n1 and n2', function() {
expect(sum.findSum(1, 2)).to.equal(3)
}) - 48what are test doubles?A test double block of code that replaces some portion of code for testing purposes. Useful when you can’t test/touch production code. It can also simplify testing
- 49What is a stub?A stub replaces a functionality or function with the behavior you specify.
Stubs can be used to replace code that makes writing tests difficult. For example we can write stubs to simulate database related behaviours when we don't have a database setup. - 50What are dark patterns?Dark Patterns are tricks used in websites and apps that make you do things that you didn't mean to, like buying or signing up for something.
- 51Give example of four dark patternsDisguised adverts
Friends spam
Hidden costs
Forced continuity - 52What are the six security principles?Expect the worst
Least privilege
Simple is more secure
Defence in depth
No security in obscurity
Fail security - 53What is hashing?Hashing performs a one-way transformation on a password, turning the password into another String, called the hashed password. A mathematical operation that's easy to perform, but very difficult to reverse.
password -> hashing -> hdhfhhrogiorhgdbl3 - 54What are rainbow tables?Rainbow Tables are a dictionaries of plaintext passwords and their corresponding hash values which can allow hackers to reverse the hashing function to determine what the plaintext password might be
- 55What are some important "best practises"? in testing?Regulate requests
Validate input
Sanitise data
Keep code private
Vague security errors - 56What does "Sanitise data" mean?Is the data potentially dangerous? For instance, including HTML in a comment on a message board may be harmful to someone viewing the message since their computer might interpret the HTML as a command. Therefore, HTML tags and special character sequences are usually sanitized (removed) from message data that might be misinterpreted as computer instructions or database queries. If its inputs are not sanitized, the application may be vulnerable to attacks such as an SQL injection.
- 57Name two types of confindetality attacksPacket sniffing - attacker captured the data packets in travel. Once the data is captured, the attacker can read the sensitive data like passwords or card numbers, if the network traffic is not encrypted.
Port Scanning. - 58Give an example of an integrity attack?Man in the middle: Is an attack where the attacker secretly relays and possibly alters the communications between two parties who believe they are directly communicating with each other
- 59Name 4 different attacks when communicating?Confidentiality attacks
Integrity attack
Availability attack
Authenticity attack - 60Authenticity attackSomeone is impersonating you accessing data
- 61What are the five "stages" of risk assessement?risk
trigger
likelihood
impact
CONTINGENCY PLAN - 62How do you manage risks?Prevention
Detection
Response
Recovery and Remediation - 63Give examples of common web attacksSQL - injection
Url - manipulation
XSS - Cross-Site Scripting
CSRF - Cross-Site Request Forgery - 64What is SQL-injection and how can you prevent it?SQL injection is the placement of malicious code in SQL statements, via web page input. If you’re not sanitising your form input - then people can enter SQL statements that that you will unknowingly run on your database and damage it.
Prevent: Give limited privileges to the user AND sanitise the input. Don’t let everyone create or delete tables for example - 65what is URL-manipulation? How to avoid?By manipulating certain parts of a URL, a hacker can get a web server to deliver web pages that they are not supposed to have access to.
Even unlinked pages are accessible - don’t rely on obscurity as access control! Make sure the server protects access to directories containing sensitive data;
Never use important data in get - 66what is XSS? How to avoid?Cross-Site Scripting (XSS) attacks when malicious scripts are injected into otherwise trusted websites. The end user’s browser has no way to know that the script should not be trusted, and will execute the script - the malicious script can access any cookies or other sensitive information
Avoid: if you have an input form: sanatise & validate! - 67What is CSRF?Cross site request forgery (CSRF) is an attack that tricks a web browser into executing an unwanted action in an application to which a user is logged in.
CSRFs are typically conducted with an email or link that tricks the victim into sending a forged request to a server.
Avoid: GET requests should make no change, should be for lists etc at max you can filter things by ID, but they should not make change. Do post request instead! It is very hard to make someone accidentally do a post request.
Information
- Description
- Webdev Flashcards on Important questions, created by Emma Tysk on 23/06/2019.
- Created by
- Emma Tysk
- Views
- 2
- Rating