Namespaces are a language feature of many programming languages, allowing local reuse of class and variable names.

learn more… | top users | synonyms

33
votes
3answers
2k views

Why do so many namespaces start with com

I've noticed that a lot of companies use "reverse domain name" namespaces and I'm curious where that practice originated and why it continues. Does it merely continue because of rote practice, or is ...
32
votes
6answers
2k views

Why is “tight coupling between functions and data” bad?

I found this quote in "The Joy of Clojure" on p. 32, but someone said the same thing to me over dinner last week and I've heard it other places as well: [A] downside to object-oriented programming ...
16
votes
6answers
8k views

Best practices for using namespaces in C++ [closed]

I have read Uncle Bob's Clean Code a few months ago, and it has had a profound impact on the way I write code. Even if it seemed like he was repeating things that every programmer should know, ...
14
votes
4answers
3k views

Using static classes as namespaces

I have seen other developers using static classes as namespaces public static class CategoryA { public class Item1 { public void DoSomething() { } } public class Item2 { ...
9
votes
1answer
487 views

Evaluating PHP namespaces

I'm at the pre-release stage of an open-source PHP project, one which I hope will be used by other developers in their own projects. The project doesn't currently support namespaces and I'm trying to ...
9
votes
2answers
774 views

How do I partially add PHP namespacing to a library without breaking existing code?

My company has created a modular PHP framework over the years, beginning long before PHP 5.3 added namespaces. Recently, we decided to start using namespaces in our library's new code, and we intend ...
8
votes
3answers
4k views

Why do we need URIs for XML namespaces?

I am trying to figure out why we need URIs for XML namespaces and I cannot find a purpose for that. Can anyone brighten me a little showing their use on a concrete example? EDIT: Ok so for ...
8
votes
4answers
2k views

Number of Classes in a Namespace - Code Smell?

I have a C# library that's used by several executables. There's only a couple namespaces in the library, and I just noticed that one of the namespaces has quite a few classes in it. I've always ...
7
votes
4answers
428 views

When to import names into the global namespace? (using x::y, from x import y etc.)

I've been programming in various languages for about 10 years now. And I still haven't figured out when it is a good idea to import something into the global namespace (using x::y in C++, from x ...
6
votes
2answers
566 views

Why use typedefs for structs?

in C (ANSI, C99, etc.), structs live in their own namespace. A struct for a linked list might look something like this: struct my_buffer_type { struct my_buffer_type * next; struct ...
6
votes
1answer
177 views

Should classes from the same namespace be kept in the same assembly?

For example, ISerializable and the Serializable Attribute are both in the System.Runtime.Serialization namespace, but not the assembly of the same name. On the other hand, DataContract attributes are ...
5
votes
4answers
983 views

Adding to the System namespace in C#

Would it be acceptable for some very generic utilities or classes to be added in the System namespace? I'm thinking of really basic stuff like a generic EventArgs (EventArgs<T>), Use case: ...
5
votes
3answers
145 views

Where do I place my example implementations in my framework?

I've created a pretty simple templating framework and have default implementations for some of my interfaces used for passing around information. I store these in MyFramework.Default namespace ...
4
votes
3answers
237 views

How should modules access data outside their scope? [closed]

I run into this same problem quite often. First, I create a namespace and then add modules to this namespace. Then issue I always run into is how best to initialize the application? Naturally, each ...
3
votes
1answer
499 views

Pros and cons of namespaces vs include/require in PHP?

I recently started using namespaces in PHP. When I first saw them, I thought that their syntax was ugly and I'd never use them. However, I created an autoloader (spl_autoload_register) that makes it ...
3
votes
2answers
623 views

Derived Classes and namespaces

I am deriving a class, for use in my application, from a class provided by another group. Should the derived class be in the namespace for my application or the namespace of the parent class? While ...
3
votes
1answer
170 views

What is meant by namespaced content and what advantages does it have?

I was reading this blog by James Bennett regarding HTML vs XHTML . He writes : I don’t have any need for namespaced content; I’m not displaying any complex mathematical notation here and don’t ...
3
votes
2answers
326 views

Namespaces just seem to be making things more complicated. Am I missing something?

Now that I am using namespaces in my php files which match the file's path, I have to append a namespace to pretty much every class instantiation. The namespaces definitely help my autoloader find ...
3
votes
2answers
103 views

Should package structure closely resemble class hierarchy?

Pretty simple question. Should package structure closely resemble class hierarchy? If so, how closely? Why or why not? For instance, let's say you've got class A and class B, plus class AFactory ...
3
votes
1answer
152 views

Advices on structure and names for namespaces and classes [closed]

I'm resistant to calling the "main" class the same as the namespace, but I sometimes find myself needing it. Considering I'm using the Vendor.Namespace.[Subnamespace].Class formula, imagine this ...
2
votes
6answers
309 views

Nested Classes or Namespace

Why do need namespaces when we have nested classes. What can be done through namespaces, can also achieved through nested classes. so I don't understand the reasoning of having namespaces ?
2
votes
3answers
183 views

Is prefixing symbols also considered as namespacing?

For example, the Objective-C convention is to prefix the symbols with two or three capital letters which are abbreviations of the project: NSString, CABasicAnimation, MGTwitterEngine… In C, many ...
2
votes
1answer
1k views

How to choose a good namespace name? (Linguistically)

English in not my native language, therefore it is a little more difficult to pick a good name for a namespace. One example to make you see my problem a bit better: We have a set of classes that have ...
2
votes
1answer
416 views

What should be done with class names that conflict (common) framework names

What should be done exactly when the most obvious class name for a component is taken by a framework? In my case, I need to make a class that describes an HTTP request. Of course, the most common name ...
2
votes
3answers
338 views

Should I use a root namespace?

I'm currently working on a couple projects in Flash ActionScript, and I've been building up a small library of classes. I've been using a naming convention similar to: foo.events.Bar and ...
2
votes
3answers
398 views

Company namespace in web applications

Most (good) namespace conventions require a company name scoped namespace. eg CompanyName.ComponentName.x.y.z How well does this translate over to web applications? In many websites, the company is ...
1
vote
1answer
168 views

Separate namespace just for exceptions?

I was doing a code review and came across something odd which I've never seen before. The developer decided to create a sub-namespace just to contain all the assembly's exceptions. I thought I had ...
1
vote
1answer
950 views

Dynamic Class Inheritance For PHP

I have a situation where I think I might need dynamic class inheritance in PHP 5.3, but the idea doesn't sit well and I'm looking for a different design pattern to solve my problem if it's possible. ...
1
vote
1answer
239 views

Does putting types/functions inside namespace make compiler's parsing work easy?

Retaining the names inside namespace will make compiler work less stressful!? For example: // test.cpp #include</*iostream,vector,string,map*/> class vec { /* ... */ }; Take 2 scenarios of ...
1
vote
1answer
172 views

Organization standards for large programs [closed]

I'm the only software developer at the company where I work. I was hired straight out of college, and I've been working here for several years. When I started, eveeryone was managing their own data as ...
0
votes
3answers
472 views

What are the good practices for including namespaces in C++ that avoid more typing?

I am starting out with C++ and almost everywhere I see there is these 2 sentences at the top. #include <iostream> using namespace std; As I understand namespaces are something to keep names ...
0
votes
1answer
77 views

How to use namespaces to separate interface from implementation, in c++?

As far as I can tell, you can make your interface known to others by providing your .h file. Your .cpp is the implementation. Then they can see the function names, the parameter types, the return ...
0
votes
1answer
334 views

Is C# namespace should be Project-Name?

I am working with multiple websites (freelancer) and a good amount of them I write using C# MVC4. I created a very good boilerplace project that I plan to use on every next starting mvc4 application ...
0
votes
1answer
389 views

Nested classes vs namespaces

Is it good to use nested classes or should I use namespaces instead? In context: I have a templated codec loader and a codec have In objects and Out objects template<class TypeOfData> class ...
0
votes
0answers
22 views

port code from XP to Win 7 [migrated]

I have developed a Delphi application (XE4) on a Windows XP machine. When I copy all the project files to a Win 7 machine (also Delphi XE4) it will not compile. The source has "uses Vcl.Grids" and the ...
0
votes
0answers
40 views

jQuery UI Widget Factory namespace limitations

As I can read in this tutorial, "There is a limitation that namespaces be exactly one level deep – that is, we can't use a namespace like nmk.foo". What isn't clear to me (and something I was unable ...
0
votes
0answers
105 views

Ruby module namespacing advice

in my current project have: module Stats class Site ... end class Product def initialize(product_id) @product_id = product_id end end class Profile ... end end ...
0
votes
0answers
123 views

Namespace conventions in Redis

My Java code has packages that look like, e.g. me.unroll.monitoringclient And we've largely followed this convention through - e.g., for RabbitMQ our queue names are things like ...
0
votes
1answer
171 views

Handling table name collisions in Django

Django creates a table name by joining the app label with the model name. A project can have many apps. If two have the same label, how can both be used in the same database? I'm currently using very ...
-1
votes
2answers
223 views

Do programmers (using an IDE) need to know namespaces? [duplicate]

I got into a discussion with a coworker over an interview question that was asked of a potential employee. "Name some namespaces/what do they do/what namespace is involved with x". I'm of the opinion ...