A class diagram is a UML diagram that describes the relationship among classes.
Here's a basic cheat sheet:
Empty diamond = aggregation Full diamond = composition Arrow = association Empty triangle arrow = pointer to a parent class (inheritance) Empty triangle dotted arrow = implementation Arrowhead = pointer to the class of which another class has knowledge Plain line = bidirectional association. Dotted arrow = dependency 0..1 = zero or one * = any number 1..* = zero or more 1..5 = one to five + = public - = private # = protected ~ = package
ArgumentCaptor is a class provided by Mockito and used to verify the arguments passed to a mock method. It should be used for verification and not for stubbing.
Normally with matchers you can only verify that a method has been called with a particular object type or a specific object. ArgumentCaptor is more flexible and allows you to check each specific member of the object passed.
Here's a short example:
ArgumentCaptor<Student> arg = ArgumentCaptor.forClass(Student.class); verify(mock).execute(arg.capture()); assertEquals("Ale", arg.getValue().getName());
The OWASP Top Ten is a list of the most critical web application security risks. It is maintained by The Open Web Application Security Project (OWASP), a non-profit organization focused on software security.
Here's the list:
A1-Injection: sends untrusted data to the server
A2-Broken Authentication and Session Management: impersonates other users to gain control
A3-XSS: injects client-side scripts into web pages seen by others.
A4-Insecure Direct Object References: accesses directly internal objects like files and URLs.
Identification is telling the system who you are.
Authentication is the system checking that you really are who you are.
Authorization is the system giving you some rights, based on who you are. This is also referred to as access control or permissions.
You need a username for identification and you need a password for authentication.
Namespaces are used to avoid element name conflicts and they allow to use of prefixes.
Here's an example for the namespace "p":
<p:order>...</p:order>
A namespace can be defined in any tag (usually the root tag), pointing to a URI (which is not required to have content):
<p:order xmlns:h="http://www.mywebsite.com/order"> <p:item>book one</p:item> <p:item>book two</p:item> </p:order>
A default namespace is not associated to any prefix:
<order xmlns="http://www.mywebsite.com/order">
If your class is stateless and contains a set of utility methods, then you certainly have to use a static class. Consider a normal class in the other cases, but consider using a singleton if a single instance of the object is required.
Here are the difference between static classes and singletons:
Static class Singleton ------------------------------------ Stateless Stateful or stateless No polymorphysm Polymorphism possible Hard to mock Easy to mock No concurrency risk Concurrency risk Better performance Lower performance Eager loaded Lazy loaded
XML (EXtensible Markup Language) is a markup language to store and communicate data.
It's extensible because it's backward-compatible, when you add data. It's a markup language because it uses tags to organize data.
Each tag is also known as element. An element can contain other elements, text and attributes. Attribues are not expandible and should only be used for information that is not relevant to the data.
Tags are not predefined like in HTML, but they are user defined. You can define tags using a DTD document and reference it in that way:
Junit provides a set of methods to assert tests.
Here are some examples on how to use the class org.junit.Assert:
// Check with equals() that two objects are identical Assert.assertEquals(expectedResult, actualResult); // Check with equals() that two objects are different Assert.assertNotEquals(expectedResult, actualResult); // Check that the condition is true Assert.assertTrue(result); // Check that the condition is false Assert.assertFalse(result); // Check that the result is null Assert.assertNull(obj); // Check that the result is not null
When the user's input is validated on the server-side, we don't usually want to stop to the first error. Instead, we want to validate all the inputs and send back a list of the parameters that are invalid. In order to do that, we need an object that keeps track of the errors.
Here's an example of that object:
public class ErrorNotification { private List<String> errors = new ArrayList<>(); public void add(String message) { errors.add(message); } public boolean isEmpty() { return errors.isEmpty(); } public String toString() {
HTML 5 supports the geolocation API to find geographical positions on a map.
Here is a basic example:
<!DOCTYPE html> <body> <script> /* * This method renders the map of the current location */ function success(position) { // Retrieve current latitude and longitude var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); // Set options used to render the map var myOptions = { zoom: 15, center: latlng, mapTypeControl: false,
Copyright © 2013 Welcome to the website of Davis Fiore. All Rights Reserved.