Menu
  • HOME
  • TAGS

Namespace for (DDD) entities cutting across domains

Tag: namespaces,domain-driven-design,modeling

I have a couple of business-related domains like Purchase, Marketing and Economy. Having the models arranged into a namespace* for each domain would be nice, but there are some entities cutting across domains, like an Item. How to organize those cross-cutting objects?

* = As in C#/Java/Python namespaces.

Best How To :

Since you have the concept of Bounded Context, you should not share domains between the namespaces. Actually, you should have one Item for each namespace that requires it, and each of those Item should have it's own fields as required by the context it is included.

As Eric Evans said, it is not a big deal replicate data in order to never share the same domain between contexts, but only data.

KDB+ / Q Accessing root namespace from namespace

namespaces,q,kdb

Context (namespace) is just a dictionary so you can use dictionary syntax. q) \d .seed q.seed) `.[`n] Reference: http://code.kx.com/wiki/JB:QforMortals/workspace_organization Check section: A Context is a Dictionary ...

how to add new account in outlook with Name Space C#2003

c#,outlook,namespaces

The Outlook object model doesn't provide any method or property for creating new accounts. You can add a new store, not an account. See the AddStoreEx method of the Namespace class which adds a Personal Folders file (.pst) in the specified format to the current profile. To create a new...

Domain Driven Design for Rails App: Implementing a service in a basic example

ruby-on-rails,ruby,design-patterns,domain-driven-design,component-based

Here are the few things that I would do if I were to refactor this code: Writing numbers in your code is a bad thing, either you have defined them as constants like ENERGY_PER_WALK_FOR_DOG = 20 or a better way is to define a field in the table of Dog...

How to Move a class to another dll and change the namespace without altering the method usage

c#,.net,namespaces,refactoring

Unfortunately you can't. If you keep same namespace then you can use TypeForwardAttribute but if you also change namespace (not just assembly) then it doesn't work. What I suggest is to move it to new class, keep old class to don't break code both at run-time & compile-time and forward...

Big collections in DDD using Entity Framework

c#,entity-framework,domain-driven-design

should I load all users collection in Club to add new and save? No, you can add a new User to Club.Members and EF will save the new user. It's not necessary to load the users first. What is the best way for modeling entities with big collections That...

Should i validate if related entity exists before insert?

c#,entity-framework,domain-driven-design

I usually don't do that. Normally, these information comes from the client which was loaded before (it existed). However, there are cases that the CustomerId is missing at the time you update your db. Due to concurrency when many users access the system at the same time. But this case...

The name 'Thread' does not exist in the current context

c#,visual-studio-2013,namespaces

I assume this is a Portable Class Library or Windows Store/Phone project targeting Windows Runtime which does not have such a construct. An alternative and recommended way would be to use: await Task.Delay(TimeSpan.FromSeconds(2)); or for a blocking call in case you are not in an async context: Task.Delay(TimeSpan.FromSeconds(2)).Wait(); Similar issue...

Python class and global vs local variables [duplicate]

python,class,namespaces,global-variables

There are four scopes here: the global scope the function scope the class body the lambda scope When creating a class statement, the class body is executed as a function would and the local namespace of that 'function' is used as the class attributes. However, a class body is not...

Silex namespace : class MainController does not exist

php,class,namespaces,autoload,silex

I believe your problem is caused by the way you named your directory controllers. According to the documentation about PSR-4 standard: 5) Alphabetic characters in the fully qualified class name MAY be any combination of lower case and upper case. 6) All class names MUST be referenced in a case-sensitive...

Deleting namespace in Socket IO

node.js,namespaces,socket.io,typescript

For anyone else who has this specific problem, I found the answer. I misunderstood the linked question: I didn't realize the array that was being discussed was located in the Server object in SocketIO, not an outside array. Furthermore, at the time of this post, Typescript's SocketIO .d.ts file doesn't...

Reference C# type within XML schema?

c#,xml,namespaces,xml-namespaces

Not directly. There's sort of two ways you can do this though. The first is to mark your class as Serializable and use the XmlSerializer to serialize it to XML. In conjunction with this, you can also use xsd.exe to create a schema for your class, and that could be...

How to use namespace System; in MFC application with VC++

c++,sql,visual-c++,mfc,namespaces

Namespace System is part of the .NET library, which requires you to use the C++/cli or C# language. MFC is a C++ library, programmed with C++. If you are new to all this I do not recommend you attempt to program in two languages. You can find some other way...

how to solve the type and namespace could not be found

c#,namespaces,mono

You need to pass the referenced assembly path using -pkg switch. I think you did not reference VehicleRoutPlannerCore dll while compiling. Please refer to http://linux.die.net/man/1/mcs you should invoke it like mcs -pkg:path-to-VehicleRoutPlannerCore-assembly VehicleRoutingConsole.cs ...

R cannot load package forecast due to namespace error

r,namespaces,packages

I tried to reproduce. I get no message about either loading timeDate or the error you see. I do get a message about loading pkg:zoo. The package loads and announces its version number. Try updating to R version 3.2.1, since that is where a new argument to nchar was introduced:...

PHP require files when use namespace

php,namespaces

When you are working with namespaces you must fully qualify each class unless it's a child of the current namespace. As such the FluentPDO is probably on the root namespace which means you need to access it like such: self::$_instance = new \FluentPDO(new \PDO("mysql:host=8273639.mysql.rds.aliyuncs.com;dbname=db", 'name', 'password')); ...

DDD logic and Persistence Ignorance

c#,.net,orm,domain-driven-design,persistence

this was quickly done up so it's not perfect but you get the gist of it: public class User { public Guid UserId { get; set; } } public class Document { public string Name { get; private set; } private ICollection<User> sharedWith = new List<User>(); private DateTime? publishedOn; public...

C# : Why is First namespace redundant?

c#,namespaces,projects-and-solutions,qualifiers

I thought I understood what was happening here, but now I'm seeing some weird behavior that's making me question my understanding of C#'s namespace scoping behavior. Obviously, the basic issue is scoping. Presumably, you're working on something in some namespace under OurCompany; let's just say for sake of argument, you're...

Using framework event dispatcher to raise domain event

php,events,laravel,domain-driven-design,dispatcher

Lately I favor returning events from domain methods and handling those in the application service layer. Since the application service layer is where you bring together all kinds of infrastructure further processing of the returned events, such as dispatching, can be handled in the application service layer. In this way...

Javascript variable is set in one function, but undefined in another function

javascript,jquery,namespaces,scope

The context of this has changed. The easiest way to address the issue is to reference this outside the function, or pass a data object (as suggested by the two other fine posters, Richard Healy and AlliterativeAlice). A third way is to explicity bind the context of this. Using jQuery,...

Disabling default namespaces

namespaces,rust

You can create your own String by... creating your own String: struct String { len: u8, } fn main() {} You can then disambiguate which String you want using fully-qualified paths: fn main() { // String::new(); // error: type `String` does not implement any method in scope named `new` std::string::String::new();...

TYPO3-Upgrade 4.5 to 6.2: namespaces

namespaces,typo3,typo3-6.2.x

To use the new XLASS feature, you need to provide a proper autoloading, by either sticking to the convention or by creating an ext_autoload.php file. http://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Autoloading/Index.html http://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Xclasses/Index.html...

how to use class of other project in a solution (internal)? [duplicate]

c#,namespaces

In visual studio you should have a "References" area in the Solution Explorer. Right click that and click "Add Reference..." From here, it's just a matter of locating where you other code is on your machine. Edit: Here is some additional information on DLLs, in case it helps you....

Dynamic content display with Naked Objects or Dynamic Data

c#,jquery,domain-driven-design,dynamic-data,naked-objects

Declared bias: I am the products manager of the open source Naked Objects framework. (Also, both your posting and my response might get criticised for being an unsuitable topic - request for product advice - for Stack Overflow. But meantime ...) Yes, I absolutely think Naked Objects would be suitable...

System.ComponentModel.DataAnnotations.Schema namespace conflict

c#,.net,entity-framework,namespaces

Problem .NET 4.0 really shouldn't include System.ComponentModel.DataAnnotations.Schema so it's a little baffling that you'd get a reference conflict, but apparently .NET 4.5 overwrites 4.0 assemblies. You can find more information in this post by Marc Gravell which states: fact 1: 4.5 is an in-place over-the-top install on top of 4.0,...

Python: is there a way to use “unimported” objects in function definitions?

python,function,namespaces,python-module

Is there a reason you aren't importing before the function is defined? I'm not sure why you would need to put the import in the main function to begin with. I don't believe there's any magical way for the function to already know what turtle's modules are unless they're either...

How to follow DRY principles in different namespaces Rails 4.2?

ruby-on-rails,api,ruby-on-rails-4,namespaces

There are a couple ways I can think of doing it: (NOT RECOMMENDED) - Send the urls to the same controller in your routes.rb file. Shared namespace that your controllers inherit from For example you could have: # controllers/shared/users_controller.rb class Shared::UsersController < ApplicationController def index @users = User.all end end...

Laravel Interfaces

php,laravel,interface,namespaces

In my recent laravel 5 project, I'm used to prepare my logics as Repository method. So here's my current directory structure. For example we have 'Car'. So first I just create directory call it libs under app directory and loaded it to composer.json "autoload": { "classmap": [ "database", "app/libs" //this...

Fatal error: Class 'Psr\Log\AbstractLogger' not found in Logger.php on line 30

php,namespaces,rackspace-cloud,rackspace,psr-3

It sounds like you missed a step during the installation of the SDK. Take a look at https://github.com/rackspace/php-opencloud#installation , you should be using composer to manage your package dependencies, which will take care of the Psr/Log (https://github.com/rackspace/php-opencloud/blob/working/composer.json#L31)

Domain Logic and Referencing AR by ID

domain-driven-design,aggregateroot

First of all, I have to agree with plalx's last paragraph regarding the need to synchronise the hidden flags in both Post as well as Comment. One would assume that the UI would look at a Post and realise it's hidden and not bother fetching/showing the comments? But I appreciate...

Are namespaces in PHP “inherited”?

php,drupal-7,namespaces

To answer the base question (and pending further code) PHP namespaces are set by whichever namespace is declared in the file. // Bar.php namespace Foo; class Bar {} // some other file use Foo\Bar; $test = new Bar(); //works // different file namespace Foo; $test = new Bar(); // works...

Should i do authorization on my Domain Services?

c#,authorization,domain-driven-design

It makes sense to do authorization in any methods that need authorization otherwise there will be a security problem, especially when these methods are entry points in your backend logic. That means if you deploy these domain services as another tier which is accessible from outside, these methods really need...

DDD aware of existance of an entity outside the context?

domain-driven-design

From the implementation point of view. You may write the code as: var assistant = GetAssistant(Id); var therapist = GetTherapist("[email protected]"); therapist.ManagedBy(assistant); repository.Save(therapist); The therapist knows if he/she is managed by an assistant, so the rule is applied here. And the therapist can handle concurrency contention with locks. On the other...

XML, XSL namespaces

xml,xslt,namespaces

To produce a valid output HTML document you just need to add exclude-result-prefixes="xsi xslFormatting" on the <ins:stylesheet> (root) element of your stylesheet. But indeed in your stylesheet you don't use the xsi and xslFormatting namespaces anywhere. Thus you could also modify your stylesheet by removing these namespaces declarations, leading you...

Get rid of Visual Studio Namespace error message

c#,.net,wpf,xaml,namespaces

It seems to me that your main application namespace is TreeViewTestC and not MyNameSpace. Therefore, you may well need to tell the compiler that your MyNameSpace is actually in the TreeViewTestC assembly, despite you only having a single project. Try using this instead: xmlns:MyTree="clr-namespace:MyNameSpace;assembly=TreeViewTestC" ...

Namespace keyword in TypeScript

c#,namespaces,typescript,keyword

You can read about it in the namespace keyword issue, but the basic idea is to differentiate between internal (namespace) and external (module) modules. To better align with ES6 modules as suggested in #2159, this PR introduces a new namespace keyword as the preferred way to declare what was formerly...

friendship and namespace issue

c++,namespaces

By using the scope operator :: friend void ::Bar(Class&); This tells the compiler that Bar is in the global scope. Apparently the Bar function needs to be declared before it's used in the friend declaration when using the scope operator. The problem is that for Bar to be declared you...

c++ operator overloading and associated namespace

c++,namespaces,operator-overloading,clang,argument-dependent-lookup

This is caused by two different CWG issues: CWG issue 2052 and CWG issue 1391. First, CWG 1391. On encountering x + a, the usual name lookup finds, among other overloads, template <typename T> double operator+ (T, double); Template argument deduction is performed by match T to the type of...

Namespace for (DDD) entities cutting across domains

namespaces,domain-driven-design,modeling

Since you have the concept of Bounded Context, you should not share domains between the namespaces. Actually, you should have one Item for each namespace that requires it, and each of those Item should have it's own fields as required by the context it is included. As Eric Evans said,...

Why is ::class appended to PHP class in Laravel 5.1

php,namespaces,laravel-5

PHP Documentation on ::class The feature has been introduced with version 5.5, which is now required by Laravel 5.1 The magic ::class property holds the FQN (fully qualified name) of the class. The advantages of it mostly comes with a good IDE. Some are: Less typos Easier Refactoring Auto-Completion Click...

C++: Does inheriting from a class bring it into the namespace?

c++,namespaces

Because of the injected-class-name rule, the name of a class is visible as though it were a member. 9/2 A class-name is inserted into the scope in which it is declared immediately after the class-name is seen. The class-name is also inserted into the scope of the class itself; this...

Leiningen REPL not autoloading project.core namespace [duplicate]

clojure,namespaces,read-eval-print-loop

in-ns does not load code. It switches to an ns, creating it if needed. It also does not do the default ns setup (eg. referring clojure.core). The proper way to load a namespace from code in the repl is with require (require 'some.ns), which can then be followed by (in-ns...

How do I access DbContext.Entry Method (TEntity) in my generic repository class?

c#,entity-framework,namespaces,dbcontext

The problem is that in your Update method, all the compiler knows is _context is of type IBusinessEntityContext and the compiler has no idea that _context has type DbContext somewhere in its inheritance tree. You could add this to your interface: public interface IBusinessEntityContext { DbSet<TEntity> Set<TEntity>() where TEntity :...

Mediawiki custom namespaces id change

namespaces,mediawiki,identifier

To answer the question, you would need to update the page table with the new namespace ID: http://www.mediawiki.org/wiki/Manual:Using_custom_namespaces#Use_a_database_query To fit this to your occassion, it would be: UPDATE page SET page_namespace = 3000 WHERE page_namespace = 1100 You shouldn't have to replace the page_title since these articles are already in...

What's the recommended way to load an object graph from Data Access Layer?

c#,architecture,domain-driven-design,data-access-layer,software-design

What the author (Dino Esposito) is missing in his book is the clear separation of concerns that CQRS brings. If I'm not mistaking, this pattern is completely missing from his book. In Esposito's latest MSDN article, he explains CQRS, so I think he just wasn't that experienced at the time...

C# Obtaining Namespace Based on CSProj settings

c#,.net,c#-4.0,visual-studio-2013,namespaces

No, there is no way to use the "Default Namespace" from within source code. It is used by the boilerplate T4 templates to automagically prepare new files, but it is a Visual Studio parameter and not an actual property of the code. As you said, this can be done with...

autoloading nested classes with composer

php,namespaces,psr-0,psr-4

Well you need to keep the guidelines of psr-4 as you are using it to autoload. change the folder name "rules" to "Rules" Uppercase all your file names of classes like: between.php --> Between.php that should do the job...

Rails: Rendering a template in a different namespace

ruby-on-rails,namespaces

This worked for me render 'api/events/index' ...

Should one forward declare classes from a namespaced library?

c++,design,namespaces,forward-declaration

As @molbdnilo pointed out, there is nothing wrong with forward declaring with namespace. First option is not an option at all, for various reasons I dont want to include header until I have to, forward declaration is always preferred way. Why dont you just provide a header with forward declarations...

How to avoid anemic data model? Can repositories be injected into entities?

java,oop,design,domain-driven-design

For a system-wide password expiration policy your approach is not that bad, as long as your UserPasswordService is a domain service, not an application service. Embedding the password expiration policy within User would be a violation of the SRP IMHO, which is not much better. You could also consider something...