Today I spent the afternoon building a sample project to demonstrate the power of the Specification pattern. I’m not done yet, but I uploaded sample project on github. This pattern comes particularly handy if you have a lot of search conditions and you’d like to isolate them and make them testable.
About the implementation: ASP.NET MVC 3 running dependency injection on Castle Windsor. I didn’t take the time to include a database so I just created a fake Repository. I used a Façade for abstracting data access away, and there’s a Builder to create the appropriate specification objects based on user input. And user input is aggregated into a query object to enhance loose coupling.
And of course there’s a home-brew implementation of the Specification pattern and the project comes with pretty good test coverage, too. Note that I’d never recommend writing your own implementation, this project is for educational purposes only. In a following post I’ll describe the Good Way™ which I use in work.
The one thing that bothers me with this project is that I had the thought that having interfaces for every class is a nice example of YAGNI, so I only added one when it was absolutely needed. This lead to difficulties in testing and an awkward feeling working with these concrete classes. I guess that I’m yet to find the balance in this question.
So next week I’ll post how the Specification pattern is usable and how to implement it.
I took the Microsoft exam Programming in C# back in August and today I got the result that I passed. To be honest this exam was pretty easy so it isn’t the achievement of my life but it’s my first (and yet, the only one) .NET 4.5 certification.
I didn’t prepare too much for this exam, I once read the syllabus and take a look on the async/await pattern new in .NET 4.5 and programmed in C# all day in the job. What was a little striking is how this one revolved around syntax questions. Those are very hard to answer wrong if you’ve worked with C# for a while.
Anyway if you’re pursuing this exam you might read a comprehensive C# book, such as C# in Depth or Pro C# 5.0 and the .NET 4.5 Framework and you are pretty much over prepared yourself.
My job is to develop custom SharePoint solutions (mostly web parts with various business functionality). Since SharePoint doesn’t support ASP.NET MVC I need to work with WebForms. It’s a decent technology, but after working with MVC for years it’s a serious fallback. Fortunately there’s a pattern which helps you maintain clear separation of concerns and loose coupling which lends itself well for ASP.NET WebForms, the Model-View-Presenter pattern.
The main concept behind the pattern is that you have a model you need to work with in your UI, a view which is the UI and a presenter which glues these two together. It’s pretty similar to MVC. I’ve created a sample project and hosted it on GitHub, all the code in this post can be found there. Continue reading “The Model-View-Presenter pattern”
I love learning. There’s hardly any skill in the world which can get you further than your ability (and passion) to learn new things and learn them fast. This holds true for me as a software developer, but I can’t think of a profession or craft which wouldn’t benefit from keeping up with it and taking the time for learning new concepts and ideas.
But learning comes with a great price – it costs time, and once you spent time doing something, you never get it back. Although one can’t argue that time spent learning is time spent well, this also means that you can’t learn everything in the world. This may seem self-evident and even funny to a degree, but the problem is every profession became so specialized nowadays that you can’t even learn everything in a domain, so you have to subspecialize. I face this problem every day, and it’s a very challenging one. Whenever you make a decision you lock the door on thousands of other possibilities.
This is why I constantly search ideas on how to improve my learning, and the very reason I write this blog, and wrote the previous one. Continue reading “How do I learn(ed) programming?”