Skip to main content

Why you should look around before writing something from scratch

Nowadays there are a lot of SPA websites used for different purposed. Almost all of them need to access different resources in CRUD format (Create/Read/Update/Delete).
I had to take a look into a project that was using Angular to offer the SPA support. The application is hosted in Azure using Web Sites. Everything was great, except one thing. There were around 100 types of entities that were accessed by the SPA application through API controllers.
For CRUD access, the development team defined a dynamic mechanism that was able to fetch data from the database and expose it using REST services over API controllers. The code was pretty ugly, even though the design was good. Personally I had the feeling that they reinvented the wheel.
On top of this custom implementation, there was another mechanism for caching on client side, based on dictionary. Very simple, but perfect for their needs.
When the project ended, they realized one thing. Everything that was made to support client side caching and CRUD access to entities was already supported in Angular using Breeze.
Breeze is a JavaScript library that is used to access data from client side. This library has the ability to cache entities on the client browser even if the client navigates from one page to another. On top of this, you have the ability to write queries in a fluent way (LINQ style) based on OData protocol (Open Data Protocol) and promises.
Breeze is made around EntityManager object, which caches all the entities and also plays the role of the gateway when entities cannot be found in the cache.
Things that I like:
+The way we can define queries
var myFooQuery = breeze.EntityQuery()
var entityManager = new breeze.EntityManager(myFooServiceName);
+the API Controller has support for OData (out of the box support to expose the services)
+You have full control when you save data from the local instance (entityManager) to the backend
+Custom validation rules (you can define your validation logic on client side)
+Full integration with Entity Framework and API Controller
public class UsersController : ApiController {
    readonly EFContextProvider<UserDbContext> _contextProvider =
        new EFContextProvider<UserDbContext>();
    // ~/breeze/users/Metadata
    public string Metadata() {
        return _contextProvider.Metadata();
    // ~/breeze/users/Users
    public IQueryable<User> Users() {
        return _contextProvider.Context.Users;
    // ~/breeze/users/SaveChanges
    public SaveResult SaveChanges(JObject saveBundle) {
        return _contextProvider.SaveChanges(saveBundle);
I invite all of you to take a look at Breeze.JS
Lesson learned: Investigate a problem, look to see what kind of 3rd parties you can use to solve your problem before starting to implement your own custom solution.


Popular posts from this blog

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine:
threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration:

TeamCity.NET 4.51EF 6.0.2VS2013
It seems that there …

How to check in AngularJS if a service was register or not

There are cases when you need to check in a service or a controller was register in AngularJS.
For example a valid use case is when you have the same implementation running on multiple application. In this case, you may want to intercept the HTTP provider and add a custom step there. This step don’t needs to run on all the application, only in the one where the service exist and register.
A solution for this case would be to have a flag in the configuration that specify this. In the core you would have an IF that would check the value of this flag.
Another solution is to check if a specific service was register in AngularJS or not. If the service was register that you would execute your own logic.
To check if a service was register or not in AngularJS container you need to call the ‘has’ method of ‘inhector’. It will return TRUE if the service was register.
if ($injector.has('httpInterceptorService')) { $httpProvider.interceptors.push('httpInterceptorService&#…

Fundamental Books of a Software Engineer (version 2018)

More then six years ago I wrote a blog post about fundamental books that any software engineer (developer) should read. Now it is an excellent time to update this list with new entries.

There are 5 different categories of books, that represent the recommended path. For example, you start with Coding books, after that, you read books about Programming, Design and so on.
There are some books about C++ that I recommend not because you shall know C++, only because the concepts that you can learn from it.


Writing solid codeCode completeProgramming Pearls, more programming pearls(recommended)[NEW] Introduction to Algorithms


Refactoring (M. Fowler)Pragmatic ProgrammerClean code[NEW] Software Engineering: A Practitioner's Approach[NEW] The Mythical Man-Month[NEW] The Art of Computer Programming


Applying UML and Patterns (GRASP patterns)C++ coding standards (Sutter, Alexandrescu)The C++ programming language (Stroustrup, Part IV)Object-oriented programming (Peter Coad)P…