Hot answers tagged

23

Don't think yet about the tool that you are going to use. You can do DI without an IoC Container. First point: Mark Seemann has a very good book about DI in .Net Second: composition root. Make sure that the whole set up is done on the entry point of the project. Rest of your code should know about injections, not about any tool that is being used. Third:...


10

My observation is that WebForms is on the decline. There is a good reason for that. Having used WebForms extensively in the past, it's difficult to do something outside the box. In addition to the learning aspx controls and their proper usage, there is a lot of technical minutiae to learn about the page life cycle when going beyond basics. And in the end, ...


7

There are two parts to your question - how to implement DI properly, and how to refactor a large application to use DI. The first part is answered well by @Miyamoto Akira (especially the recommendation to read Mark Seemann's "dependency injection in .net" book. Marks blog is also a good free resource. The second part is a good deal more complicated. A ...


7

As Anders says, its partly about performance and partly about locking down poorly-thought designs down to reduce the scope of trouble caused later by people blindly inheriting things that were not designed to be inherited. Performance seems obvious - while most methods wont be noticed on modern hardware, a virtual getter might cause quite a noticeable hit, ...


6

There's two elements to your question, so I'll try and address them in turn: Why aren't .NET methods virtual by default? Inheritance, in practice, has many problems. So if it is to be used as part of a design, then it should be carefully considered. By making methods non-virtual by default, the theory is that it encourages the developer to think about ...


5

Polymorphism with no shared interface will ONLY let you store objects in the same (strongly typed) container, not actually DO anything. You can't disptach method calls or anything like that. In your specific example, I think composition would be more appropriate, no? You already have an abstraction for a specific point in 2d space, so why woudn't you reuse ...


4

The first form creates an array of integers. The second form creates an array of something. The major difference is that the first variant gives you, the developer, the explicit indication of the type of objects stored in the collection. This indication will help both at the moment of writing code if you use an IDE with IntelliSense, and at the moment when ...


2

Most databases have tables that store schema information about tables that are being maintained. For example, in SQL Server: SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = @Table ORDER BY COLUMN_NAME Will get you a list of columns for a particular table. However, in your case, I would just ...


2

The two subclasses does not have any interface in common, so why you do you want to have them inherit from a common class in the first place? The Location class does not provide you any benefit as far as I can tell. To me it would seem to more logical to have the Line contain two Point's.


2

I've worked on a number of microservice projects. Inevitably companies have taken the route because their big DB approach cant scale any further. Here are my experiences/recomenations. Org. One solution per microservice. nuget packages for shared libs Development. larger teams 5-6 devs one area of functionality at a time. Refactor into a interfaced service....


2

Assuming you will call HttpUtility.HtmlEncoded() from your extension method (otherwise it's a no-no) and also that you will use a meaningful name to your method (otherwise you will just make code less clear). Given: string someText = "This is some text"; Let's compare: string htmlEncoded1 = someText.ToHtmlEncodedString(); string htmlEncoded2 = ...


1

First I want to mention that you are making this significantly harder on yourself by refactoring an existing project rather than starting a new project. You said it is a large application, so pick a small component to start with. Preferably a 'leaf-node' component that is not used by anything else. I don't know what the state of the automated testing is on ...


1

If your create a fourth lib and use project references, you will not get the desired result, that way a consumer of that lib will still need to reference all the libs individually. However, at least you can put the initialization code in that fourth lib. Your first alternative will most probably work well when you still keep each of the current libs in its ...


1

You wrote Some applications have use for values to be remembered between sessions well, that is true whenever you have to persist data would be to create a file of a specific format (XML, JSON, ini, or something else) in the user's data directory and use it for such values. [...] One example is the timestamp of the last time a certain function ...


1

Properties.Settings are stored for the user on the machine. If you want the settings to be common to all users and/or all machines, this method would not do. You also may want to have input parameters for the application that steer its behavior rather than preferences, and have several sets of them ready to be used in different senarios. For this, Properties....


1

You could have separate classes for each queue and inject those, instead of injecting the factory. Your design as described here does not need a factory beyond the IoC-container as the type of queue can be determined at compile-time. Classes that need access to the queue can simply request an IUploadedDocsQueue or IRequestedDocsQueue as constructor ...


1

Microsoft is probably the best "person" to ask this. If you expect some rhyme or reason to their versioning scheme, you're not going to find much on the Internet; they've changed their numbering scheme at least once. However... It appears that the build number is part of a strategy of allowing the version to be encoded in a single DWORD in the registry, ...


1

I'd go to simple inheritance, but maybe you can group some classes in subsets like visual studio does. For instance, you got Control as the parent class with the core properties and behavior for all controls: caption, location, etc.; in the other hand there's a class that inherits Control that acts as a parent for SaveFileDialog and OpenFileDialog, since ...



Only top voted, non community-wiki answers of a minimum length are eligible