Skip to content

Instantly share code, notes, and snippets.

View aparnachaudhary's full-sized avatar

Aparna Chaudhary aparnachaudhary

View GitHub Profile

MongoDB Replica Set Configuration

MONGO_HOME=/Users/Aparna/Development/Projects/NoSQL/MongoDB
$MONGO_HOME/mongodb/bin/mongod --replSet nosqlmatters --dbpath $MONGO_HOME/mongodata/replica1 --port 27017 --rest --directoryperdb --fork --logpath $MONGO_HOME/log/replica1.log

$MONGO_HOME/mongodb/bin/mongod --replSet nosqlmatters --dbpath $MONGO_HOME/mongodata/replica2 --port 27018 --rest --directoryperdb --fork --logpath $MONGO_HOME/log/replica2.log

$MONGO_HOME/mongodb/bin/mongod --replSet nosqlmatters --dbpath $MONGO_HOME/mongodata/replica3 --port 27019 --rest --directoryperdb --fork --logpath $MONGO_HOME/log/replica3.log
@aparnachaudhary
aparnachaudhary / jQA-Constraints.asciidoc
Last active August 29, 2015 13:57
jqassistant JavaEE constraints

Constraints

JPA2

FieldAccess

Verifies that entities prefer field access over property access.

@aparnachaudhary
aparnachaudhary / JAX-RS-Resource.asciidoc
Created April 30, 2014 15:45
JAX-RS Resource specification and implementation conflicts

JAX-RS Resource and use of @Path

Based on JAX-RS specification; @Path annotation is not mandatory on Resource classes. But many implementations seem to deviate from the specification. But shouldn’t reference implementation adhere to the specification?

JAX-RS 2.0 spec:

Resource classes are POJOs that have at least one method annotated with @Path or a request method designator.

RESTEasy:

@aparnachaudhary
aparnachaudhary / jQA-CDI.asciidoc
Last active August 29, 2015 14:02
jqassistant CDI Plugin

Concepts

Bean

Managed Bean

  • Concrete POJO

    • No-arg constructor

    • Constructor with @Inject

  • Objects returned by Producers

layout title author
post
Context Dependency Injection - Are you doing it right?
aparnachaudhary

CDI specification allows Field, Property (aka setter) and constructor injection. Like many developers out there, I also habitually use field injection. I must admit I never gave enough thought about it. But recently I saw a bean with more than 10 injection points and started to ponder over Dependency Injection.

The following blog post discusses why you should prefer constructor injection over field or setter injection. In the later part of the post, we will see how jQAssistant can be used to find beans with too many injection points or to enforce use of constructor injection.

@aparnachaudhary
aparnachaudhary / change-log-level.cli
Created July 22, 2015 13:49
WildFly Change Log Level in Domain Mode at runtime
/profile=full/subsystem=logging/root-logger=ROOT:write-attribute(name=level,value=TRACE)

CodeMotion Amsterdam

How to write maintainable code?

  • https://github.com/Droogans/unmaintainable-code

  • How much time to invest in code refactoring?

    • Typically for new projects, assuming you are curating code well, no dedicated effort

    • Second year of the projects - start investing 10% of team effort on code refactoring

    • Increase this effort by 10% every upcoming year

  • Spagetti codebase