Some notes on DDD

Software Architecture, Software Development
Some Vocabulary Problem Domain/Domain The actual problem our software is going to solve, the purpose it is built for. Core Domain It's a subset of the previous ones. It's the essential part of the problem domain, the part which cannot be delegated and must be solved by us, software developers. Business Logic, Business Rules, Domain Logic, Domain Knowledge, Domain Model The business logic you enclose in your code represents the knowledge that you as a software developer have about the problem domain. The business logic of an application typically resides in the two innermost layers of the onion architecture. We refer to the notions of those two layers as domain classes, so a domain class might be a repository, an entity, aggregate, ... nut not an application service. Main concepts…
Read More

The RESTful way

Software Architecture, Web standards
The idea of building your website services in a RESTful way consists on using the HTTP protocol to determine the Action you are going to perform instead than some Action name on the URL. This way, we can build APIs that are more standarized and easy to sue for everyone. But... what is REST? REST is an abbreviation for "Representational State Transfer" and, as its name points out, it's an "idea" (let's call it idea for now) to transfer the State of an object through a Network. But that idea is based on the HTTP protocol, in fact REST was born as a way of using HTTP properly, some type of "HTTP good practices", which we can call "an architectural style", or architectural pattern if you prefer. The point is...…
Read More

Creational Patterns

Software Architecture
Singleton This pattern consists on making sure that there is only one instance of an object and provide a global access to such instance (this would be an static object in C#). Prototype Creates a duplicate of an existing instance (clone) so you end up with two instances with the same state at the moment of creating it. Useful if you want to keep a copy of the original. This can be done by having a method like ".Clone()" or by using an injection on the constructor: "Person copy = new Person(personToCopy);". Factory method Allows you to determine the type of the instance on run-time by calling a method that has some internal logic to determine which instance you get. While this was planned as a "parent-child" to determine which…
Read More

Improving your website’s performance

Software Architecture, Web programming
Using Cache One of the best ways to improve your website's performance is by using cache. That way you can save lots of db requests and server processing time. Using Cache for static data Let's start by caching all those reference tables with user roles, categories, error messages, cities, countries, etc. Normally this uses minimal cache and saves thousands of db requests, probably the best improvement possible. Caching often requested dynamic data Imagine you have a real state website for the UK with thousands of possible requests on it (as there are thousands of cities, towns, combinations of filters, etc. But you notice that due to peaks of population requests for London, Manchester, Liverpool and a few more take like 30% of all the overall requests. Of course there are…
Read More

Association relationships between objects

Software Architecture
An Association relationship between two objects can have different levels of dependency. In some situations, an object just knows about the existance of another and works with it while in other scenarios it may be the one in charge of all its lifetime. Depending on how much dependency there is between those objects we can define 3 types of Association Relationship: Composition: The owner controls the child lifetime. Aggregation: The main object has inside of it the other but doesn't control its lifetime. Delegation: The main object just knows about the existence of the other one. Composition This is a has-a relationship, meaning the main object has a child object type inside of it. With Composition, the life-cycle of the objects that compose an object ends when the main object…
Read More