Domain Driven Design – how the layers should be organized?

Speaking in terms of more “classical” DDD, yes domain objects are typically not allowed anywhere outside of the domain. But it is not an absolute rule that domain objects are not used in the presentation layer. For example, Naked Objects represents a school of thought where domain objects are used directly. I myself adhere mostly … Read more

Organising my Python project

Create an __init__.py file in your projects folder, and it will be treated like a module by Python. Classes in your package directory can then be imported using syntax like: from package import class import package.class Within __init__.py, you may create an __all__ array that defines from package import * behavior: # name1 and name2 … Read more

The Pythonic way of organizing modules and packages

Think in terms of a “logical unit of packaging” — which may be a single class, but more often will be a set of classes that closely cooperate. Classes (or module-level functions — don’t “do Java in Python” by always using static methods when module-level functions are also available as a choice!-) can be grouped … Read more

What are common conventions for using namespaces in Clojure?

I guess it’s ok if you think it helps, but many Clojure projects don’t do so — cf. Compojure (using a top-level compojure ns and various compojure.* ns’s for specific functionality), Ring, Leiningen… Clojure itself uses clojure.* (and clojure.contrib.* for contrib libraries), but that’s a special case, I suppose. Yes! You absolutely must do so, … Read more

How do I add a resources folder to my Java project in Eclipse

When at the “Add resource folder”, Build Path -> Configure Build Path -> Source (Tab) -> Add Folder -> Create new Folder add “my-resource.txt” file inside the new folder. Then in your code: InputStream res = Main.class.getResourceAsStream(“/my-resource.txt”); BufferedReader reader = new BufferedReader(new InputStreamReader(res)); String line = null; while ((line = reader.readLine()) != null) { System.out.println(line); … Read more

Including one C source file in another?

Used properly, this can be a useful technique. Say you have a complex, performance critical subsystem with a fairly small public interface and a lot of non-reusable implementation code. The code runs to several thousand lines, a hundred or so private functions and quite a bit of private data. If you work with non-trivial embedded … Read more

Django: “projects” vs “apps”

Once you graduate from using startproject and startapp, there’s nothing to stop you from combining a “project” and “app” in the same Python package. A project is really nothing more than a settings module, and an app is really nothing more than a models module—everything else is optional. For small sites, it’s entirely reasonable to … Read more