If I have objects on one layer with the same name as objects on another layer, is it best to change the object names with some prefix or have new namespace and refer to them with fully qualified names? For example:
namespace Project1.Data
Object Person;
namespace Project1.Model
Object Person;
Data.Person.Name=Person.Name;
OR
dbPerson.Name= Person.Name;
I'd use namespaces and namespace aliases, e.g:
Define your classes in appropriate namespaces:
namespace Project1.Data
{
public class Person {...}
}
namespace Project1.Model
{
public class Person {...}
}
And where you use the classes, either use fully qualified names or define an alias for the namespaces (especially usefule if the full namespace is long):
using data = Project1.Data;
using model = Project1.Model;
data.Person p1 = new data.Person();
model.Person p2 = new model.Person();
//...
p1.Name = p2.Name;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With