SGRH (Sistema de Gestión de Reservas Hoteleras) follows Clean Architecture principles with clear separation of concerns across multiple layers. The system is designed to be maintainable, testable, and scalable.
All entities inherit from EntityBase which provides identity equality:
public abstract class EntityBase{ protected abstract object GetKey(); public override bool Equals(object? obj) { if (obj is not EntityBase other) return false; if (ReferenceEquals(this, other)) return true; if (GetType() != other.GetType()) return false; return GetKey().Equals(other.GetKey()); } public override int GetHashCode() => GetKey().GetHashCode();}
Domain validation is enforced through guard clauses:
public static class Guard{ public static void AgainstNullOrWhiteSpace(string? value, string name, int maxLength) { if (string.IsNullOrWhiteSpace(value)) throw new ValidationException($"{name} no puede estar vacío."); if (value.Length > maxLength) throw new ValidationException($"{name} supera el máximo de {maxLength} caracteres."); } public static void AgainstOutOfRange(int value, string name, int minExclusive) { if (value <= minExclusive) throw new ValidationException($"{name} debe ser mayor a {minExclusive}."); }}