pdr
  • Member for 10 years, 11 months
  • Last seen more than 3 years ago
  • London, United Kingdom
Simple hashing code with excessive conditional statements
0 votes

I'm not a Python developer, so this might be completely missing the point. But I look at the code for hashlib.py. And there is a chunk of code in the middle that looks a lot like yours, so I wonder if ...

View answer
Design dilemma: extensibility vs simplicity
8 votes

The fact that you have two completely different outputs from these two examples should be a huge clue as to the answer. Eagle shall fly now! Eagle speaking! Penguin shall fly now! Penguin speaking! ...

View answer
Calculating compass direction
2 votes

Another alternative: public enum Direction { North = 0, NorthEast = 1, East = 2, SouthEast = 3, South = 4, SouthWest = 5, West = 6, NorthWest = 7 } public static ...

View answer
Displaying RSS feeds from Google Feed API as HTML list
Accepted answer
13 votes

Looks ok, to be honest. A few minor changes I would make: I would pull this code out into a function function ProcessFeedResult(result) { if (!result.error) { FeedManager.$feedContainer =...

View answer
Comma delimited string from list of items
Accepted answer
72 votes

Would this not suffice? private string ConcatenateCheckBoxListItems() { return string.Join(", ", from item in MyList select item.Value); }

View answer
Moving to other game states with ScreenManager
Accepted answer
19 votes

You could use generics public static void MoveToScreen<T>() where T : Screen, new() { if (currentscreen != null) currentscreen.Remove(); currentscreen = new T(); currentscreen.Init(...

View answer
Implementation of costreams
Accepted answer
5 votes

Depends what you're trying to do. Is it really possible to have multiple Read threads, as the comment suggests? If so then you're going to run a risk of having several Reads released at once and ...

View answer
Recursive database actions
Accepted answer
5 votes

What you're talking about is called object-relational mapping. You could do this, but it will be a fair amount of effort. Luckily many people have run into this same question before, answered it and ...

View answer
Refactoring a bunch of and statements
5 votes

[Edit] Corrected given edit to question Try something more like this [Flags] public enum PersonType { None = 0, Employee = 1 << 0, Manager = 1 << 1, Contractor = 1 <&...

View answer
Interrupt lengthy for loops
4 votes

You say that Start is running in a thread other than the UI thread and that the Stop method is called from the UI thread. That being the case, why not just call Abort on the thread Start is running ...

View answer
How to break up long lines of code. (Example Line: Results of method call added to list.)
8 votes

Interesting to see the range of responses. I would tend towards a different answer from any of those so far: shippedItems.AddRange(OrderItem.Fetch( market: this.MARKET, shipConfirmState: ...

View answer
Better ways to build a linq specification for querying or is this the only way?
3 votes

How about adding an extension method to IAttachmentSpecification, such as public static class AttachmentSpecificationExtensions { public static IAttachmentSpecification And(this ...

View answer
Sorting Visitors
Accepted answer
4 votes

Have you considered using the Chain of Command instead of the visitor? public interface IFooChainLink { void Execute(Foo foo); } public interface IBarChainLink { void Execute(Bar bar); } ...

View answer
Adding flair to PHP page with Sassy (SCSS)
6 votes

It looks a bit like block-1's height is calculated from @block-height, in which case I would do that calculation rather than putting in a literal value. This way if you change @block-height, block-1 ...

View answer
NHibernate (UoW) + cCommand pattern
3 votes

This seems to be a lot of code to say the same as this: [AjaxOnly] [Authorize] public ActionResult Details(int id) { User userToGet = _session.Get<User>(id); if (userToGet == null) ...

View answer