The tag has no wiki summary.

learn more… | top users | synonyms

1
vote
0answers
38 views

Producer-Consumer Pattern: Raise Event on ConcurrentQueue.Enqueue with Method Extension?

I'm trying to code a multi-threaded producer-consumer pattern with ConcurrentQueue. There will be a background worker thread (BackgroundWorker) that waits for new commands to become available in the ...
5
votes
2answers
89 views

Extension methods for methods and properties that don't use non-public data

Generally speaking, I try and write my classes so they are highly cohesive. Sometimes I have accessors (this problem isn't limited to accessors) which derive their value from non-public data only, ...
3
votes
2answers
86 views

improve the design of class “accuracy” in Python

I am learning about the class and methods in Python. The class Accuracy is a class of several (13 in total) statistic values between a reference polygon and one or more segmented polygons based on ...
4
votes
2answers
122 views

Task.Finally extension, good, bad, or ugly?

I wrote this, and it has helped to avoid the 'Some exception weren't handled' problem. Is there something glaringly wrong with this that I might have missed? /// <summary> /// Handles ...
7
votes
2answers
164 views

Synced/Atomic access

Forward I would love any comments you have, any ideas, any flaws you can find, and any suggestions you might have regarding the code below. If this is similar to other implementations, I would love ...
2
votes
2answers
21 views

Naming a method that filters or repeats elements as needed

I'm having trouble thinking of a good name for the following extension method: public static IEnumerable<T> TrimOrExpand<T>(this T[] items, int desiredCount) { var ratio = ...
0
votes
1answer
278 views

My own implementation of Linq SelectMany extension method

What do you think of my own implementation of the extension method SelectMany? Motivating criticism is always welcome. public static IEnumerable<TResult> MySelectMany<T, TResult>(this ...
2
votes
1answer
206 views

Clever way to build a extension method that ordenate my IQueryable<T>?

I want to create a ExtensionMethod to ordenate my linq query, called Ordenar. I'll sort it depending what columns is in sortColumns ListDictionary. I tried some ways, but the best way I arquieve was ...
2
votes
4answers
285 views

60 helper methods in the same class

I have a pretty complex Java class with over 60 small helper methods used for easy readability and understanding. Just wondering, do you think having these many methods in a class could affect ...
2
votes
1answer
156 views

Cycle through an IEnumerable

I built an extension method to cycle through all items of an IEnumerable starting at some index: public static IEnumerable<T> Circle<T>(this IEnumerable<T> list, int startIndex) { ...
7
votes
3answers
141 views

Evaluate my helper please

I have some static helper class: public static class Helper { public static bool IsNull<T>(this T value) where T : class { return (value == null); } public static bool ...
6
votes
3answers
688 views

Grouping by sequence in LINQ

Suppose a series of objects (presented here as tuples): "a" | 1 "a" | 2 "b" | 3 "b" | 4 "a" | 5 There is no built in function (that I know of) to group by the first columns's sequence, that is, ...
3
votes
3answers
214 views

Javascript inheritance: is my solution correct?

I have been developing Javascript for few months, and, as a former Java developer, needed a simple way to perform class inheritance. My needs are: having private members not accessible ...
3
votes
3answers
160 views

Chained Assertions

Wouldn't it be nice to just chain assertions after a method call or is it just me? I was thinking that it'd improve readability. Instead of: var myObject = _objectService.GetRandomObject(); ...
6
votes
1answer
4k views

Getting the value of a custom attribute from an enum

Suppose we have an enum called "Planet" and it has a custom attribute of class "PlanetAttr", these methods will give you the attribute value for a given Planet value: private static PlanetAttr ...
3
votes
1answer
940 views

Convert .NET DateTime to a string using ordinals

With a DateTime object, it's easy to get, for example, 11 October 2011 by using: d.ToString("d MMMM yyyy"); However, there seems to be no built-in method to get the output 11th October 2011. So ...
1
vote
1answer
1k views

Creating Extension Method to map entity with subentities object to Poco object

I am trying to create an extension method that builds a POCO object (copies all the fields) for an Entity Object. When Entity object is simple (no navigation, no sub collections), it works fine. I ...
8
votes
7answers
834 views

Extension methods, is this too dirty?

I love lambdas, and functional programming etc. But sometimes I wonder if I take it too far.. public static T With<T>(this T source, Action<T> action) { action(source); return ...
2
votes
4answers
309 views

Using an extension method for a small helper task that (ab)uses the fact that the object is not dereferenced

I've recently got into an habit where I've used extension methods for giving things fluent-like properties - such as the below example or as another example entity.AssertNotNull() public static class ...
7
votes
1answer
1k views

Review my small C++ boost extension

This is a small extension based on a boost::property_tree, which supports arbitrary values for the properties and appropriate serialization. Can be used as an alternative to QSettings in Qt and ...
5
votes
2answers
865 views

Converting objects to type Bool

The following extension method is being used in our code base: public static bool ToBool(this object src) { return src != null && ((string) src).ToBool(false); } It leverages off ...
6
votes
3answers
315 views

Can you review my two extension methods?

public static class StringHelpers { public static string CapitalizeEachWord(this string sentence) { CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo ...