In this post we’ll look at some alternative solutions to the traditional loop. The great thing about the new functional features in Java 8, is that it allows us to say what we want to be done instead of saying how to do it. This is where loops fall short. Sure loops are flexible, but this flexibility doesn’t come without a price. A return, break or continue dramatically changes how the loop will act, forcing us not only to understand what the code is trying to achieve, but also understand how the loop works.
Let the coding begin!
This time we’re going to work with articles. An article has a title, an author and several tags.
[.....]
Spring Data MongoDB 1.2.0 silently introduced new feature: support for basic auditing. In this post I will show what benefits does it bring, how to configure Spring for auditing and how to annotate your documents to make them auditable. Auditing let you declaratively tell Spring to store: date when document has been created: @CreatedDate date when document has been updated last time: @LastModifiedDate user who has created document: @CreatedBy user who has done most recent update: @LastModifiedBy current document version: @Version Configuration First of all add Maven dependencies to latest Spring Data MongoDB and Spring Data Commons. Additionally in order to use date-related audit annotations we need to add joda-time to class-path.
<dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-mongodb</artifactId> <version>1.2.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-commons</artifactId> <version>1.5.1.RELEASE</version> </dependency> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> <version>2.2</version> </dependency> [.....]
Today, I want to show you debugging method, more specifically one for measuring execution times: Say hello to console.time().
Measuring Execution Times the Classic Way Here's a small JavaScript snippet which concatenates the first one million natural numbers: var i, output = ""; for (i = 1; i <= 1e6; i++) output += i;
If you're wondering what 1e6 means, it's just a short way to write ten to the sixth power, which equals one million. It means exactly the same as the number literal 1000000.
The script is very [.....]