Tag Info

Hot answers tagged

18

For .NET it may depend on the deployment target. .NET 3.5 is supported in even early editions of Windows XP, whereas 4.5 is only supported on Vista and above. At my workplace we opted to stay on 4.0 because we still have workstations running on Windows XP Pro SP3 (which 4.0 supports). We cannot consider migrating until next year or so just because of that. ...


11

"Good enough is the enemy of better." -- Jerry Pournelle Seriously, there has to be a reason for an upgrade besides just "ooh, shiny!". Among other issues, any time you switch versions of a package your code depends on, you switch out one set of bugs that you're adapted for to another set that you may not be. In the process of switching, you frequently ...


7

It would get a lot more uptake, I suspect, if one could answer "If I compile it, will it work on every [desktop] platform?" with "Yes.". You can say that today! (or at least you could 8 years ago when I tried) Seriously. Build some plain jane vanilla C# (really, any .NET language) dll on windows. Good. Now move that over to some linux machine with ...


6

Try looking for MVVM instead of MVC. Here's an MS article on MVVM which is very much applicable to WPF And here's another tutorial on MVVM with WPF Or look at MVP with winforms. From a broad point of view, MVVM and MVP are just variants of MVC.


6

Recommend an upgrade to a million dollar software project from v3.5 to v4.0 (Not always the same as going from .50 to 1.0), you better have a very good reason. Sorry, but just stating it's 5-10 years old isn't good enough IMHO. Be prepared to identity the new features and how they will benefit this project. You could argue that if you don't, making an even ...


6

Just keep them as string as long a possible. A stream is bound to external resources (hidden buffers, read ahead cache,...) and it is a good idea to minimized the time those are bound to your objects. Some systems have a hard limit of how many files are open as well so if you open all streams at once it may happen that some streams don't open.


4

You could make static properties on Planet for each of the specific planets you want to create. For example: public class Planet { public string Name { get; set; } public double Mass { get; set; } private static Planet _earth; public static Planet Earth { get { return GetEarth(); } } //Use this approach so that you only create a ...


4

Unit testing can involve a number of different libraries and dependancies than the application that is associated with it. Thinking of an application I recently wrote as a proof of concept (Java) - a simple CRUD app with unit tests against an in memory database. WebApp | Unit Test -------+---------- | JUnit | Mockito Tomcat | Jetty Mysql | ...


3

WinRT was made to target devices with ARM processors. The downside of this is that legacy Win32 API, which was thought for x86 architecture back in the days, now has very limited support. The only desktop mode application WinRT supports are the ones that are shipped with it. Unfortunately, both Winform and WPF architecture relies on desktop mode, so they ...


3

As david.pfx writes in his comment, there is a bit of info missing, but I am willing to give it a shot. I am making an assumption in my answer. The reason that C and D both want to use B is, at least in part, to use M100Communicator Thereafter it kinda depends on if other modules are around that want to use the ICrt570 interface. Scenario A If it is ...


3

The default XML Serializer is quite flexible. Ignores (by default) what doesn't know (that's it information on the xml file/stream for which there is no member variable), and what it knows and it is not present (in the xml file/stream), it gives defaults. So, a very dirty way is just to add what you need where you need it. It will work. It will not be ...


3

There's a third option: mock the object with the event and use behavior testing to verify the mock's subscriptions at given points. Several mocking frameworks allow for this. public interface INeedToBeMocked { public event EventHandler EventRaised; } NSubstitute var mockedItem = Substitute.For<INeedToBeMocked>(); ...


3

Consider using delegates instead of abstract classes. The Template Method pattern is mostly a hack to work around a language's lack of first-class functions. So instead of overriding "execute", pass it in as an argument. That aside, why don't you want dependencies between assemblies? What good is your Common assembly if you're not going to use it?


3

The .NET heap is an object graph, only boxed types will have a contiguous memory block for you to scrape. If you pinned an object and everything it referenced, and everything that stuff referenced recursively pinning the entire object graph you wanted to serialize, then you could start walking the object graph scraping it all into a contiguous byte array ...


2

The .NET Framework provides the Stream abstract class for this purpose. .NET offers a number of Stream Reader and Writer objects out of the box. One of those may already fit your needs, or you can inherit from Stream in a new class, and write your own custom implementation.


2

Keep it small and simple. You mention your text file has a lot of data in it that you don't need. If you stuff all of that in your database, you'll have a much more complicated / harder to understand structure that the next person will have to decipher. Can you imagine inheriting a large complicated structure where only 10% is in actual use? See also ...


2

In general, if your mobile app is based on remote web services, you should establish a secure connection (ssl/tls) to the remote server and pass the username/password directly to the server for processing on the server, not on the client. I presume this is some kind of a web server. You are almost definitely not going to be connecting directly from your ...


2

We had a similar situation and we asked Microsoft's lawyers. They (eventually) responded that they regarded it as falling within the "fair use" provisions of copyright law. We used their source code on that basis. As any competent lawyer will tell you, fair use: allows you to copy and use small parts of a copyright work without seeking permission, ...


2

This exact problem is why Dependency Inversion Principle exists. This principle says. High-level modules should not depend on low-level modules. Both should depend on abstractions. Abstractions should not depend on details. Details should depend on abstractions. In your case, the business layer depends on detail that is data access. To fix this you ...


2

Providing support for an older OS is one reason (see Crono's answer). The other reason is to "save money". Quoted because it only saves money on the short run. It depends on the type of project of course, but for business applications, which usually survive a significant number of years, there's a good chance an upgrade will be required at some point, for ...


2

Is there a better way to solve this problem? Yes! C# allows you to override the += and -= syntax. I'm not sure how easy it is to supply in common mocking frameworks like Moq, but it should be trivial to build your own fake object that has hooks into the subscribe and unsubscribe methods of your interface: private Action foo = () => {}; ...


1

The "Correct" approach to modify an XML file is any method that results in well-formed and valid XML, with the least bit of work on your end and an appropriate amount of repeatability in the future. If you already have a object reference that typically manages and creates them, deserialization and re-serialization may meet that requirement. However, ...


1

I would propose an approach based on Dependency Injection and Null Objects. If you let your configuration define which object should be used for a specific task in each environment, then you can define specific behaviors within these objects. Then you use a Factory to initialize your objects depending on the environment. I will use the mail as an example, ...


1

First, you should not use your real production data (especially not person-related data) in development or test (you may use carefully choosen excerpts from production data, of course). So your data pools (maybe a database, maybe a pool of files, maybe both), should be separated between those environments. So the only thing you need to change is the config ...


1

I need a way out of this conundrum, one that has the smallest technical cost in relation to changing the other controllers, I need a sort of "structural polymorphism" for these types, where the type is the same but its internal structure different. You mean like basic inheritance? I'm not sure I see the trouble here. If you have a common set of ...


1

From what I understand your question to be, it seems like your Data Access Layer classes were accessing the Common Assembly and then your Business Layer accessed your Project Specific Data Access Layer. Now you want to put some of your Common Data Access layer classes into the Common Assembly. You think it is no longer OK for the Business Layer to access ...


1

It is normal to have a build server with a very well control version of the compiler etc on it that builds the software, runs the tests and if the tests pass creates the installer using the same dlls that were tested. There is an additional risk of configuration errors if the software is built in a different way for testing then for shipping.


1

I'd go with Option 3, with the following notes: Try and reduce the amount of domain logic that your clients need to know to get the job done. Create services that expose that data in meaningful (to your clients) ways, so that you can request collections of domain objects which fulfil certain criteria, rather than doing that crunching on your client. ...


1

Generally singletons are considered bad: ...if you still feel the need to use Singleton objects, consider using the Factory Method pattern instead. It gives you all of the flexibility of the Singleton, with nowhere near as many problems. ...and you're supposed to inject the logger implementation into any class that uses it (or inject a logger factory ...


1

I would have a generic planet class, with read-only properties that were set by constructor parameters. class Planet { public string Name { get; private set; } public double Mass { get; private set; } public Planet(string name, double mass) { this.Name = name; this.Mass = mass; } } I would then have a PlanetFactory ...



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