Skip to content

Instantly share code, notes, and snippets.

View matemagyari's full-sized avatar

Mate Magyari matemagyari

View GitHub Profile
@matemagyari
matemagyari / example_pom_xml_for_sonatype
Created October 24, 2013 11:05
example pom.xml for Sonatype artifacts
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.mygroup</groupId>
<artifactId>myproject</artifactId>
@matemagyari
matemagyari / example_settings_xml_for_sonatype
Created October 24, 2013 11:09
example settings.xml for Sonatype artifacts
<servers>
...
<server>
<id>sonatype-nexus-snapshots</id>
<username>john.j.rambo</username>
<password>rambospass</password>
</server>
<server>
<id>sonatype-nexus-staging</id>
<username>john.j.rambo</username>
@matemagyari
matemagyari / Repository tests - tests
Last active December 26, 2015 10:18
Repository tests
abstract class AbstractPlayerRepositoryTestTemplate {
protected PlayerRepository testObj;
@Test
public void exists() {
// setup
...
//assert
assertTrue(testObj.exists(playerId));
@matemagyari
matemagyari / Repository tests - repos
Last active December 26, 2015 10:19
repository_tests_repos
interface PlayerRepository {
boolean exists(PlayerId playerId);
}
class InMemoryPlayerRepository implements PlayerRepository {
@Override public boolean exists(PlayerId playerId) { ... }
}
class MongoPlayerRepository implements PlayerRepository {
@Override public boolean exists(PlayerId playerId) { ... }
}
@matemagyari
matemagyari / naming_interfaces
Created October 25, 2013 09:34
Naming interfaces
class UserLifecyleService {
private IUserRepository userRepository;
public void createUser(User user) {
//do some stuff, logging, authentication,...
userRepository.create(user);
//do some stuff, send out an event or whatever
}
}
@matemagyari
matemagyari / value_object_class_id
Created October 25, 2013 12:30
Value Object Id Class Example
//application service - orchestrates beetween domain services and objects,
//authenticates, handles transactions, ....
class PlayerAccessoriesService {
public void assignAvatarToPlayer(Integer playerId, Integer avatarId) {
authenticationCheck();
logging();
transactionStart();
playerService.assignAvatarToPlayer(playerId, avatarId);
transactionEnd();
@matemagyari
matemagyari / value_object_class_player_id
Last active December 26, 2015 12:49
Value Object Id Class - PlayerId
class PlayerId {
private final Integer value;
public PlayerId(Integer value) { this.value = value; }
public Integer getValue() { return this.value; }
}
@matemagyari
matemagyari / value_object_class_id
Created October 25, 2013 12:45
Value Object Id Class - Service
class PlayerService {
public void assignAvatarToPlayer(PlayerId playerId, AvatarId avatarId) { ... }
}
@matemagyari
matemagyari / value_object_class_player_id_validate.java
Last active December 26, 2015 12:49
Value Object Id Class - validation
class PlayerId {
private final Integer value;
public PlayerId(Integer value) {
Validate.notNull("Player Id must be non-null", value)
this.value = value;
}
public Integer getValue() { return this.value; }
@matemagyari
matemagyari / packaging_example
Last active December 26, 2015 20:49
Packaging example
interface Compressor {
CompressedContent compress(UncompressedContent uncompressedContent);
}
interface CompressedContent { ... }
interface UncompressedContent { ... }
class ContentDownloader {
void downloadCompressAndSave(Compressor compressor) {
UncompressedContent uncompressedContent = downloadContent();