Folders and Namespaces vs Multiple Assemblies
-
I was in a shop that did that too. I'm not saying one way is always better than another way - it's more likely that one way is more appropriate in a given situation.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013Didn't came to argue or convert...Just told my story...
Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.
-
John Simmons / outlaw programmer wrote:
code re-use
In theory you should be using pre-compiled assemblies that perform certain logical tasks - printing, file storage, uploading, etc.... The term "code re-use" started off as a business side term, IIRC - because most business people don't know any better. If you are copying actual code from one solution/project to another (repeatedly), then you are probably doing something wrong (i.e. put it in its own assembly and re-use that), unless you are working in the WPF world, etc.
Slacker007 wrote:
you are copying actual code from one solution/project to another (repeatedly), then you are probably doing something wrong (i.e. put it in its own assembly and re-use that),
I don't think you understand the differences of which I speak. IN Native C++ solutions, you can actually include external libraries' SOURCE CODE in your new solution, and make changes to it there (ostensibly without breaking other stuff already in use by orther solutions). In .Net solutions, that isn't possible without either opening up the library's project in another instance of Visual Studio, or copying that assembly's code to the new solution. This isn't NEARLY as convenient.
Slacker007 wrote:
unless you are working in the WPF world, etc.
Bingo.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
This discussion came up at work today, with pretty much everyone falling on the side of using multiple assemblies, but with no viable reason for doing it that way, and most of the time saying, "because I've always done it that way". Beyond utility methods or object extensions living in assemblies that could be added as a reference and that could be used throughout other solutions, what's the point of creating multiple assemblies when a thoughtful arrangement of folders in a single-project solution would be perfectly adequate? It even appears as if Microsoft intended for it to be this way. I suppose an argument could be made in a team environment to more clearly separate concerns and ease source control issues, but even that's kinda flimsy at the heart of it.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013Long response. Short answer: re-usability, modularity, separation of concerns, work through interfaces and pub-sub calls as opposed to direct instance-method calls. As you said, one reason I keep functionally distinct code in separate assemblies is because of re-use -- I have a library of code pieces that live in separate assemblies so that I can pull in what I need. This is how I've done things: Core - all the stuff I almost always use: assertions extension methods model-table management module management pub-sub service management state management workflow Then, because I use runtime loading of modules that an application needs, these are broken out into separate assemblies as services: AppConfigService ConsoleLoggerService ConsoleCriticalExceptionService DatabaseService PubSubService PaperTrailAppLoggerService EmailExceptionLoggerService EmailService MessageBoxLoggerService For web development, there's additional service assemblies: FileResponseService WebResponseService WebRouterService WebServerService WebSessionService WebSocketService WebWorkflowService and finally, for application specific stuff, I typically write various components as services (assemblies), so for example, for the ATM/Kiosk applications, I have assemblies that handle: ATM specific API's Card swipers Pinpad API's Drivers License scanners / PDF417 readers Receipt printers Voucher printing etc. The real power of having separate assemblies comes to play then, when, for example, I can replace a particular service with a different hardware implementation, or even an assembly that mocks the hardware. So, for example, when I write the ATM software, I don't have a 200lb ATM sitting in my office, I instead use the services for a small Magtek card reader and either an Ingenico or Verifone pinpad, depending on what I'm testing. The interfaces are consistent, so the core ATM software doesn't know or care what the underlying implementation is. So basically, I find separate assemblies really useful, not just for code reuse, but also for creating a modular system. By asking the service manager what services are loaded, the "system" (either the back-end server or, in the case of a CefSharp hosted app, the Javascript, I can tell others what services are available. And speaking of the CefSharp hosted app, the cool thing there is that the services, as assemblies, are the same whether it's a hosted web app talking through the hardware abstraction layer or it's a WinForm app. The
-
This discussion came up at work today, with pretty much everyone falling on the side of using multiple assemblies, but with no viable reason for doing it that way, and most of the time saying, "because I've always done it that way". Beyond utility methods or object extensions living in assemblies that could be added as a reference and that could be used throughout other solutions, what's the point of creating multiple assemblies when a thoughtful arrangement of folders in a single-project solution would be perfectly adequate? It even appears as if Microsoft intended for it to be this way. I suppose an argument could be made in a team environment to more clearly separate concerns and ease source control issues, but even that's kinda flimsy at the heart of it.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013I prefer multiple compilation units, but all the code in one directory, and make files that specify what to build and how. All this separation into multiple directories causes confusion, accidental duplication, and bugs that are difficult to track down.
-
Didn't came to argue or convert...Just told my story...
Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.
Kornfeld Eliyahu Peter wrote:
Didn't came to argue or convert
We're not arguing - nobody has made defamatory speculations regarding parental heritage, sexual preference, or the possibility of affiliation with the Nazi party.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
This discussion came up at work today, with pretty much everyone falling on the side of using multiple assemblies, but with no viable reason for doing it that way, and most of the time saying, "because I've always done it that way". Beyond utility methods or object extensions living in assemblies that could be added as a reference and that could be used throughout other solutions, what's the point of creating multiple assemblies when a thoughtful arrangement of folders in a single-project solution would be perfectly adequate? It even appears as if Microsoft intended for it to be this way. I suppose an argument could be made in a team environment to more clearly separate concerns and ease source control issues, but even that's kinda flimsy at the heart of it.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013To add to what is being said. It will depend on the project for me. If the project is a simple utility then I will use folders within the project. If the project may have different UI depending on the user I will use assemblies to house the logic layer etc to allow for re-usability I also like to keep an ever growing assembly of custom routines / objects that I feel I could re-use with other projects.
Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON
-
This discussion came up at work today, with pretty much everyone falling on the side of using multiple assemblies, but with no viable reason for doing it that way, and most of the time saying, "because I've always done it that way". Beyond utility methods or object extensions living in assemblies that could be added as a reference and that could be used throughout other solutions, what's the point of creating multiple assemblies when a thoughtful arrangement of folders in a single-project solution would be perfectly adequate? It even appears as if Microsoft intended for it to be this way. I suppose an argument could be made in a team environment to more clearly separate concerns and ease source control issues, but even that's kinda flimsy at the heart of it.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013I remember one idiotic "Microsoft Field Engineer" recommends to publish all your assemblies to Nuget. I was this close to insult him since all of our assemblies are not public.
-
I remember one idiotic "Microsoft Field Engineer" recommends to publish all your assemblies to Nuget. I was this close to insult him since all of our assemblies are not public.
Errm, you can self host NuGet so it is a perfectly valid suggestion. For internal deployment of referenced assemblies, NuGet isn't a bad solution.
This space for rent
-
This discussion came up at work today, with pretty much everyone falling on the side of using multiple assemblies, but with no viable reason for doing it that way, and most of the time saying, "because I've always done it that way". Beyond utility methods or object extensions living in assemblies that could be added as a reference and that could be used throughout other solutions, what's the point of creating multiple assemblies when a thoughtful arrangement of folders in a single-project solution would be perfectly adequate? It even appears as if Microsoft intended for it to be this way. I suppose an argument could be made in a team environment to more clearly separate concerns and ease source control issues, but even that's kinda flimsy at the heart of it.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013I'm a sole developer, so the team aspect doesn't affect me. But...I mostly use separate assemblies rather than folders within a single assembly, mostly for separation and reuse reasons. I just find that it makes it easier to "black box" a class or layer if it's "physically" separated in a different assembly as I have to think "what else will that affect?" when I make a change - there's a reluctance to change an assembly for a specific task unless it's justified by the possible uses in others. That means that when I do change an assembly the additions are more generic than they probably would have been in a single block, simply because I may want to use the additional feature in other systems later. I generally don't use separate folders except for resources (where I like to separate text, images, control images (such as button "skins"), and such like from each other). Not sure if that makes any sense, but it's the way I work! :laugh:
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
Slacker007 wrote:
you are copying actual code from one solution/project to another (repeatedly), then you are probably doing something wrong (i.e. put it in its own assembly and re-use that),
I don't think you understand the differences of which I speak. IN Native C++ solutions, you can actually include external libraries' SOURCE CODE in your new solution, and make changes to it there (ostensibly without breaking other stuff already in use by orther solutions). In .Net solutions, that isn't possible without either opening up the library's project in another instance of Visual Studio, or copying that assembly's code to the new solution. This isn't NEARLY as convenient.
Slacker007 wrote:
unless you are working in the WPF world, etc.
Bingo.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013John Simmons / outlaw programmer wrote:
I don't think you understand the differences of which I speak. IN Native C++ solutions, you can actually include external libraries' SOURCE CODE in your new solution, and make changes to it there (ostensibly without breaking other stuff already in use by orther solutions). In .Net solutions, that isn't possible without either opening up the library's project in another instance of Visual Studio, or copying that assembly's code to the new solution. This isn't NEARLY as convenient.
Why would you want to? Sounds dangerous to me. I suspect that others at Microsoft felt the same way?
-
This discussion came up at work today, with pretty much everyone falling on the side of using multiple assemblies, but with no viable reason for doing it that way, and most of the time saying, "because I've always done it that way". Beyond utility methods or object extensions living in assemblies that could be added as a reference and that could be used throughout other solutions, what's the point of creating multiple assemblies when a thoughtful arrangement of folders in a single-project solution would be perfectly adequate? It even appears as if Microsoft intended for it to be this way. I suppose an argument could be made in a team environment to more clearly separate concerns and ease source control issues, but even that's kinda flimsy at the heart of it.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013Yes. No. Maybe.
-
Errm, you can self host NuGet so it is a perfectly valid suggestion. For internal deployment of referenced assemblies, NuGet isn't a bad solution.
This space for rent
It's not for us. We don't want to put our library for public usage. It remains in our org. That's makes it idiot.
-
John Simmons / outlaw programmer wrote:
I don't think you understand the differences of which I speak. IN Native C++ solutions, you can actually include external libraries' SOURCE CODE in your new solution, and make changes to it there (ostensibly without breaking other stuff already in use by orther solutions). In .Net solutions, that isn't possible without either opening up the library's project in another instance of Visual Studio, or copying that assembly's code to the new solution. This isn't NEARLY as convenient.
Why would you want to? Sounds dangerous to me. I suspect that others at Microsoft felt the same way?
Recompiling a project in an external solution that's referenced in your current solution causes reference problems in your new solution, Pain.In.The.Ass.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
This discussion came up at work today, with pretty much everyone falling on the side of using multiple assemblies, but with no viable reason for doing it that way, and most of the time saying, "because I've always done it that way". Beyond utility methods or object extensions living in assemblies that could be added as a reference and that could be used throughout other solutions, what's the point of creating multiple assemblies when a thoughtful arrangement of folders in a single-project solution would be perfectly adequate? It even appears as if Microsoft intended for it to be this way. I suppose an argument could be made in a team environment to more clearly separate concerns and ease source control issues, but even that's kinda flimsy at the heart of it.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013I'm working with a suite of tools, all sharing a common framework. I tend to split things up into assemblies based on their general use... One assembly for market data interfaces, one for product valuation, one for my data access layer, etc. The advantage is that different projects only pull in the assemblies they need, so when I'm making a change, it's easier to see the potential downstream effects. If I'm modifying my "Base" assembly (Pretty much the hub of the entire framework), I know to be a LOT more careful not to make any breaking changes. If I'm working on an assembly that's only used by one non-critical application, I can save time and play it a bit looser (RAD environment, so patches can be released in minutes instead of days). Technically I could do the same thing with namespaces, but it's a lot easier to look at DLL references than to scan an entire project to see which namespaces it touches. Also, as a side benefit, I make heavy use of 'internal' classes. While various parts of an assembly might interact which each other, I maintain careful control of which parts are actually public. That way I can look at each assembly as black box, and minimize the danger of breaking other parts of the system. TL;DR;: I use assemblies as another level of encapsulation, to minimize regression issues.
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
Used carefully,
internal
(Friend) classes, methods and so on can be a useful tool for controlling who uses what and that capability is lost to you if you have everything lumped into one large assembly.That's what
protected
andprivate
are for.#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
johannesnestler wrote:
There are ohter technical reasons too... e.g sometimes (for me mostly when working with WPF) I have to split up the Code to different assemblies to "Support" the VS designer. (Better dont try to create and use MarkupExtension in the same assembly..., same with (themed) resources, UserControls etc.)
Dontcha wish they'd fix that? I have to deal with that as well. Not only that, but don't get me started on the WPF designer's complete inability to resolve XAML references if the source code is on a network share.
johannesnestler wrote:
I wonder why you stated that MS intended it to use folder structures instead of more assemblies (which would contradict the name they choose)
Because they went completely away from code re-use strategy that exists in native C++ code. You could include a library's source code in a solution without having to actually copy that library's source code to the new solution. I found that quite handy (even though we all know that code re-use in its intended form is pretty much a myth).
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013John Simmons / outlaw programmer wrote:
You could include a library's source code in a solution without having to actually copy that library's source code to the new solution.
You can still do that.
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
It's not for us. We don't want to put our library for public usage. It remains in our org. That's makes it idiot.
um, the point was, you can make your own PRIVATE nuget repository located on your own server. But whatever...
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
um, the point was, you can make your own PRIVATE nuget repository located on your own server. But whatever...
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
Nailed it. Was waiting @Pete-OHanlon response this way!
Wonde Tadesse
-
It's not for us. We don't want to put our library for public usage. It remains in our org. That's makes it idiot.
Stephen Gonzalez wrote:
We don't want to put our library for public usage
That's why I said self-host. You don't have to make it public - if you host it yourself, you can keep it internal. So, perhaps you're being harsh about them calling them idiot. After all, it's not their fault you don't know about how your organisation can host NuGet internally.
This space for rent
-
Nailed it. Was waiting @Pete-OHanlon response this way!
Wonde Tadesse
Funnily enough, I was just posting.
This space for rent