domain-model

Constraining string length in domain classes

本小妞迷上赌 提交于 2019-12-03 15:31:52
I have a persistence ignorant domain model that uses abstract repositories to load domain objects. The concrete implementation of my repositories (the data access layer (DAL)) uses entity framework to fetch data from a sql server database. The database has length constraints on a lot of its varchar columns. Now imagine that I have the following domain class: public class Case { public Case(int id, string text) { this.Id = id; this.Text = text; } public int Id { get; private set; } public string Text { get; set; } } And an abstract repository defined as follows: public abstract class

Is there a rich domain model example?

不羁的心 提交于 2019-12-03 12:55:52
问题 I'm looking for a simple example to illustrate the benefits of using a rich domain model. Ideally, I'd like a before and after code listing (which should be as short as possible). The before code listing should show the problem being solved using an anemic domain model, and a lot of fairly procedural service-layer code, and the after code listing should show the same problem being solved using a rich, object-oriented domain model. Ideally the code listing should be in Java or Groovy, but

Building an appointment booking system in Rails

天大地大妈咪最大 提交于 2019-12-03 06:06:41
问题 I am looking to build an appointment booking app with the following characteristics: - Users can be service providers or buyers - Service providers set their availabilities (but can only set their availabilities at a maximum of 6 months ahead) - Buyers can then book appointments based on those availabilities - each appointment, based on the type of service, takes a different amount of time - Based on the appointment that a buyer selects, a different set of availabilities is shown depending on

Practical usage of the Unit Of Work & Repository patterns

邮差的信 提交于 2019-12-03 05:04:22
问题 I'm building an ORM, and try to find out what are the exact responsibilities of each pattern. Let's say I want to transfer money between two accounts, using the Unit Of Work to manage the updates in a single database transaction. Is the following approach correct? Get them from the Repository Attach them to my Unit Of Work Do the business transaction & commit? Example: from = acccountRepository.find(fromAccountId); to = accountRepository.find(toAccountId); unitOfWork.attach(from); unitOfWork

What's the difference between Data Modelling and Domain Modelling?

我的未来我决定 提交于 2019-12-03 04:46:25
问题 By the way - with reference to data modelling I'm referring to logical or conceptual data models - not physical ones. The question came up during a discussion at work; naturally I leapt to Wikipedia to get some basic definitions in place - hoping that they might clarify the difference - but they didn't... A conceptual schema or conceptual data model is a map of concepts and their relationships. Logical Data Modles seem very similar (from this definition): A logical data model (LDM) in systems

Is there a rich domain model example?

冷暖自知 提交于 2019-12-03 02:34:38
I'm looking for a simple example to illustrate the benefits of using a rich domain model. Ideally, I'd like a before and after code listing (which should be as short as possible). The before code listing should show the problem being solved using an anemic domain model, and a lot of fairly procedural service-layer code, and the after code listing should show the same problem being solved using a rich, object-oriented domain model. Ideally the code listing should be in Java or Groovy, but anything fairly similar (e.g. C#) would do. I'll give you a simple example of real production code: Person

Scala Option implicit conversion - Bad practice or missing feature?

淺唱寂寞╮ 提交于 2019-12-02 02:37:41
I represented my data model as case classes typing values that may be null as Option. case class Document(id: Long, title: String, subtitle: Option[String]) Now I try to instantiate the case class: Document(123, "The Title", "Subtitle") // Doesn't work But NOPE! This doesn't work, I have to wrap the optional value in a Some. Document(123, "The Title", Some("Subtitle")) // Works Scala is very clever about types in general, but why is it not self-evident that a hard coded literal, or (any string for that matter) is a different than null/None? I was able to fix this and make Scala "more clever"

Is it possible to modify methods of an object instance using reflection

夙愿已清 提交于 2019-12-01 13:04:32
What I'm trying to do is create a domain model with a Plain Old PHP Object. The I'm creating a library which will do all the infrastructure stuff. So one of my models looks like this class Project { public $id; public $name; public $typeId; private $type; public function getType() { return $this->type; } public function setType(Type $type) { $this->typeId = $type->id; $this->type = $type; } } Now if create a new Project and call setType with a valid Type object and save the project instance using the ORM both the project and type is saved. But then I load the Project and use getType method I

Is it possible to modify methods of an object instance using reflection

断了今生、忘了曾经 提交于 2019-12-01 10:47:16
问题 What I'm trying to do is create a domain model with a Plain Old PHP Object. The I'm creating a library which will do all the infrastructure stuff. So one of my models looks like this class Project { public $id; public $name; public $typeId; private $type; public function getType() { return $this->type; } public function setType(Type $type) { $this->typeId = $type->id; $this->type = $type; } } Now if create a new Project and call setType with a valid Type object and save the project instance

DDD: Entity identity before being persisted

孤者浪人 提交于 2019-11-30 02:14:20
In Domain Driven Design, one of the defining characteristic of an Entity is that it has an identity. Problem: I am not able to provide a unique identity to Entities on instance creation. This identity is only provided by the repository once the entity is persisted (this value is provided from the underlying database). I cannot begin to use Guid values at this point. The existing data is stored with int primary key values and I cannot generate a unique int on instantiation. My solution: Each Entity has an identity value The identity is only set to a real identity once persisted (provided by the