Friday, March 27, 2015

How much code coverage do you really need?


http://software-development-thoughts.blogspot.ca/2011/04/how-much-code-coverage-do-you-really.html

Two quotes from Uncle Bob
“Two things. Repeatability and cost. Manual tests are horrifically expensive compared to automated tests.”

“Manual tests aren't tests; they are trials. And since there are humans involved, they are suspect."

Tuesday, March 24, 2015

Last line effect

We expose the “last line effect,” the phenomenon that the last line or statement in a micro-clone is much more likely to contain an error than the previous lines or statements. We do this by analyzing 208 open source projects and reporting on 202 faulty micro-clones.


x += o t h e r . x ;
y += o t h e r . y ;
z += o t h e r . y ;

http://www.st.ewi.tudelft.nl/~mbeller/publications/2015_beller_zaidman_karpov_the_last_line_effect_preprint.pdf

Thursday, March 19, 2015

About Command Idempotency

Definition from Gregor (New ACID)
“In the world of distributed systems, idempotency translates to the fact that an operation can be invoked repeatedly without changing the result.”

http://www.eaipatterns.com/ramblings/68_acid.html
http://codebetter.com/gregyoung/2010/08/12/idempotency-vs-distibuted-transactions/

Idempotency Patterns
http://blog.jonathanoliver.com/idempotency-patterns/

Tuesday, March 10, 2015

How to deal with communication between aggregate roots?

http://danielwhittaker.me/2014/11/22/4-secrets-inter-aggregate-communication-event-sourced-system/

What is Event-driven architecture?


Behind Event-driven architecture, system model is treated as a state machine. After a command changed the state, an event is generated to notify other components.
http://c2.com/cgi/wiki?EventDrivenArchitecture


What is a simple explanation of higher order functions and callbacks in JavaScript?

  { name: 'Waffles'type: 'dog', age: 12 },
  { name: 'Fluffy',   type: 'cat', age: 14 },
  { name: 'Spelunky', type: 'dog', age: 4 },
  { name: 'Hank',     type: 'dog', age: 11 },
];
var oldDogs = animals.filter(function(animal) {
  return animal.age > 10 && animal.type === 'dog';
});

Friday, March 6, 2015

What is category in Event Store?

 If put dash into stream name, the first part will be saved as category name

Source code from Event Store 

  _handler = new CategorizeEventsByStreamPath("-", Console.WriteLine);

        public override string GetCategoryByStreamId(string streamId)
        {
            string category = null;
            if (!streamId.StartsWith("$"))
            {
                var lastSeparatorPosition = streamId.IndexOf(_separator);
                if (lastSeparatorPosition > 0)
                    category = streamId.Substring(0, lastSeparatorPosition);
            }
            return category;

        }



http://codeofrob.com/entries/creating-a-projection-per-stream-in-the-eventstore.html

How to add Multiple Regular Expression Validation attribute into one Property in ASP.Net MVC?



Create another new attribute and inherit from RegularExpressionAttribute

    public class RegularExpressionAttribute : ValidationAttribute
    {
        private string _pattern;
        public RegularExpressionAttribute(string pattern)
        {
            _pattern = pattern;
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            if (value == null) return null;
            if (!System.Text.RegularExpressions.Regex.IsMatch(value.ToString(), _pattern))
            {
                return new ValidationResult(FormatErrorMessage(validationContext.DisplayName));
            }
            return null;
        }

    public class RegularExpression2ndAttribute : RegularExpressionAttribute {}


So in view model:
        [ValidURL(ErrorMessage = "Invalid URL")]
        [RegularExpression(@"^.*\.(jpg|JPG|gif|GIF|jpeg)$", ErrorMessage = "Not a image URL")]
        public string LogoUrl { get; set; }