简体   繁体   中英

How should I deal with namespace and classname collisions

My program has a Model Foo and a namespace that I want to also call Foo. They both make sense to me, but I want to avoid namespace and classname collisions.

Which one should I change? The namespace App.Foo or the Model App.Models.Foo?

Note: I'm using mvvm structure so I have binding code in the namespace App.Foo which uses App.Models.Foo in many places, therefore causing collisions unless I specify Models.Foo everytime (which is ugly).

I would opt for renaming App.Model.Foo to FooModel , as you would likely have at least one FooView and FooViewModel ...

Given your short description, Foo seems to be rather a high-level concept, and FooModel would be the "data" representation of this concept...

My 2 cents

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM