Tag Info

Hot answers tagged

74

It is... Not great. I've worked with code that did this clever trick and it led to confusion. After all, you would expect to be able to just assign the BigObject into a SmallObject variable if the objects are related enough to cast them. It doesn't work though - you get compiler errors if you try since as far as the type system is concerned, they're ...


15

I think "info" is a misnomer. Objects have state and actions: "info" is just another name for "state" which is already baked into OOP. What are you really trying to model here? You need an object that represents the hardware in software so other code can use it. That is easy to say but as you found out, there is more to it than that. "Representing ...


10

While I can see why you would need to have a SmallObject, I would approach the problem differently. My approach to this type of issue is to use a Facade. Its sole purpose is to encapsulate BigObject and only make available specific members. In this way, it is a new interface on the same instance, and not a copy. Of course you may also want to perform a ...


10

It may be a little difficult to find a single unifying convention here because these classes are spread out over a number of namespaces, (ConnectionInfoseems to be in CrystalDecisions, and DeviceInfo in System.Reporting.WebForms). Looking at these examples, though, there seem to be two distinct uses of the suffix: Distinguishing a class providing static ...


8

First I don't like using IDisposable on actual collection. It muddles the actual meaning of Disposable. I would do it like this: public class CollectionUpdateContext<T>: IDisposable // can also be inner class of custom collection { public CollectionUpdateContext(ObservableCollection<T> inner) { inner.BeginUpdate(); } ...


6

There is a very strong convention that casts on mutable reference types are identity-preserving. Because the system generally does not allow user-defined casting operators in situations where an object of the source type could be assigned to a reference of the destination type, there are only a few cases where user-defined casting operations would be ...


4

Iterating through a List is (slightly) slower than a plain array due to a few factors: Bounds checks: This is likely to be the biggest factor; every single indexer access to the List is going to do a bounds check. Bounds checking on a raw array can often be trivially optimized out of a loop by the JIT. Method call costs: The indexer on a List is a method ...


3

Yes, there is a Flags attribute that lets you use enums as flags for an int, and the type has methods to help identify if a flag is set and the such.


2

As much as I am an amateur in such situations as these, it seems that an appropriate and well constructed argument is required to justify to the heads of departments a need for the extra expense (and expanse) of the IT resources. You probably want a good speaker who is able to intermediate the issues and relate the potential value of the proposal to those ...


2

Does it mean that F# can be used like unmanaged code similar to C++ and C? Theoretically, yes. Practically, no. Languages often don't specify how they're compiled. There's nothing precluding you from taking the syntax and semantics of Java or C# and have them compile down directly to x86 assembly and avoid the need for the JVM or .NET runtime. That ...


2

I would say that context/domain matters, since we have high level business logic code and low level models, architecture components and so on... 'Info', 'Data', 'Manager', 'Object', 'Class', 'Model', 'Controller' etc. can be smelly suffixes, especially on a lower level, since every object has some information or data, so that information is not necessary. ...


2

Considering the actual devices (sensors and receivers) are one thing, and their representation in software is another, I am thinking about naming some classes with the "Info" suffix name pattern. For example, while a Sensor would be a class to represent the actual sensor (when it is actually connected to some working device), SensorInfo would be used ...


2

In general, an Info object encapsulates information about an object's state at some moment in time. If I ask the system to look at a file and give me a FileInfo object associated with its size, I would expect that object to report the size of the file at the time the request was given (or, to be more precise, the size of the file at some moment between when ...


1

A classic problem - the simplest resolution is to do what everyone does, treat your Core product as a separate product, similar to how you'd treat an open source project you were reusing in your product. For example, I use log4net in my product. I don't have a copy of their source, I only take the latest stable dll and use that directly, putting it in a ...


1

Expanding on @Telastyn's answer, you can declare your flags as an enum with the Flags attribute instead of using an array of booleans: [Flags] public enum Options : uint { Empty = 0, FancyClouds = 1, EnhancedGrassTextures = 2, HiDefNoses = 4, NoPantsMode = 8, // etc. values are increasing powers of 2 up to 2^31 } You can fiddle ...


1

So far nobody in this question seems to have picked up on the real reason for this naming convention. A DirectoryInfo is not the directory. It is a DTO with data about the directory. There can be many such instances describing the same directory. It is not an entity. It is a throw-away value object. A DirectoryInfo does not represent the actual directory. ...


1

ThingInfo can serve as a great read only Proxy for the Thing. see http://www.dofactory.com/net/proxy-design-pattern Proxy: "Provide a surrogate or placeholder for another object to control access to it." Typically the ThingInfo will have public properties with no setters. These classes and the methods on the class are safe to use and will not commit any ...


1

Whether or not you need to use a unit testing framework is up to you. Any dependency will need to be faked so that logic can be tested in isolation. With legacy code where the dependencies are not visible a mocking or faking framework can help expose those dependencies for you and replace them so you can test that code easily without major refactoring. In ...


1

It might be okay. A problem with your example is that you use such example-ish names. Consider: SomeMethod(long longNum) { int num = (int)longNum; /* ... */ Now, when you've a good idea what a long and int means, then both the implicit cast of int to long and the explicit cast from long to int are quite understandable. It's also understandable how 3 ...


1

Yes, from what I understand the .NET regex flavor has not changed since 1.0.


1

I agree that web app must be the only one accessing mysql. So web app must inevitably provide some sort of api that let your public web api access relevant data. This API is a contract between web app and mysql that allow them to be developed separately without breaking. The complexity and flexibility of this API must reflect your business needs but keep ...


1

Using IXmlSerializable There are some things to take into consideration when implementing this interface and you should check to see if your intended use is compatible with this. Big advantage of this approach is that you can serialize what are otherwise private or protected fields, and the fairly straightforward usage of serialization (method on the object ...


1

Just to clear up a few things that are well documented in the official Rx Design Guidelines and at length on my web site IntroToRx.com: You dont rely on the GC to clean up your subscriptions. Covered in detail here There is no Unsubscribe method. You subscribe to an observable sequence and are given a subscription. You can then dispose of that subscription ...


1

Code should not be environment aware, that's why we have configs. Also, you usually do not want to ship your code with development secrets (DB connection string, etc.). Or sometimes it is not desirable to give developers access to the production secrets. Although it's a typical task in programming, to have separate configurations for different environments, ...



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