Formatting Cheat Sheet

No credit should be given to me, copied from color-of-code


Formatting is bound to a type, so depending on which type of object you pass to String.Format, you have different format specifiers.

The index specifies the position of the parameter that shall be used for that format specifier. It can be repeated!

When implementing custom formatting, try to stick to this behaviour for being consistent with the default implementation.

  • Generic, alignment is applied after type formatting, so can be used for all types
    • {index[,alignment][:format]}
  • For numerical values (; separator):
    • {index[,alignment]:format >= 0;format < 0}
    • {index[,alignment]:format > 0;format < 0;format = 0}

Pitfalls and gotchas Continue reading “Formatting Cheat Sheet”

Extending mocking with Moq

Coding Journeyman


In the last part of my Dependency Injection article I introduced the term of “mocking”. This kind of test double can be really powerful. Yet in my example I had to create 2 new classes (my mocks) to be able to test my functionality in order to reduced coupling. Here is the code used by the tests:

class MockNotifier : INotifier
{public MockNotifier(){
        NotifyHasBeenCalled =false;}
    publicbool NotifyHasBeenCalled {get;privateset;}
    publicvoid Notify(User user){
        NotifyHasBeenCalled =true;}}
class MockRepository : IUserRepository
{publicbool HasValidatedNotification {get;set;}
    public User GetById(int userId){returnnew User { HasActivatedNotification = HasValidatedNotification };}}
[TestClass]publicclass NotificationServiceTest
{private NotificationService _notificationService;private MockNotifier _mockNotifier;private MockRepository _mockRepository

View original post 659 more words

Some lessons learned during my job hunting with IT companies


As a developer writing source code generally means to create lines of code and then continuously find bugs and fix them in an iterative process of refining the software.
Looking for a job is not that different: you learn from mistakes and try to cope with them!
Here are some suggestions I have learned recently after having been refused by a big US company and after having accepted an offer from a UK company, which I ran away from after a terrible first day at work.

  • Never use sales technique guidelines such as “How to handle two different offers” or “What to say when the interviewer asks you if you have any questions“.
    It is still ok to know these techniques, but the truth is that your hiring manager is probably a PhD guy with several years of experience, with a QI above the average and surely…

View original post 643 more words

Blog at

Up ↑