Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

08-22-2011 , 04:54 AM
Quote:
Originally Posted by goofyballer
Does VS2010 do anything new that's cool? We have it available at work but I've been putting it off because getting my plugins working after upgrading from 05 to 08 was a pain.
2010 is my first go at VS, so I don't know if there are any significant changes from earlier versions.

I'm probably easily impressed though since, up to now, I've only been working with an in-house procedural language and development environment that hasn't evolved much for the past 15 years
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-22-2011 , 12:17 PM
Thought Paypal was earlier I posted, I take it back. Sandbox sucks balls I've spent about 3 hours on it so far
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-22-2011 , 04:36 PM
Shameless plug, released commercial licenses now and a much better designed website

http://www.scirra.com

Commissioning original music and art was also great fun It can be expensive but if you look in the right place you can find very talented people for good prices.

http://www.scirra.com/construct2/music
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-22-2011 , 04:51 PM
looks good!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-23-2011 , 10:44 AM
Any of you guys use Chef for server management? I spent a few days on configuring linode VPS servers, and then was like... **** I'm not going back down that road again. So I've been diving into the ec2 world, and have found Chef for automating server bootstrapping and configuration, but still struggling a bit with the deploy side.

Sigh, it's been months of having to take time out of being productive while I learn some new tech to add to my stack. It's a fun process when it happens occasionally, but now that I'm on my 8th new tech (with like at least 4 to go) it's getting old.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-23-2011 , 10:46 AM
Gullanian, what was your role with that site/software? Looks like a fun project..
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-23-2011 , 10:52 AM
i have ~no concrete experience but i've been planning to add puppet to the mix at work for a while now. by all accounts puppet is awesome and well worth the investment.

my research suggests that puppet > chef unless you're in a select minority of users who think it's really important that the configuration language be more like real ruby and less like a DSL. puppet has a longer history and a larger user community than chef.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-23-2011 , 11:04 AM
Quote:
Originally Posted by redCashion
Gullanian, what was your role with that site/software? Looks like a fun project..
Thanks! I just do the website/admin side of things mainly at the moment, my brother writes the actual software. Just the two of us! It is good fun working on it, the users are all great and it's fun to see what people make. I do want to learn C++ at some stage so I can help, I do plan on writing lots of Javascript plugins for it soon though.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-23-2011 , 11:28 AM
Quote:
Originally Posted by Gullanian
Thanks! I just do the website/admin side of things mainly at the moment, my brother writes the actual software. Just the two of us! It is good fun working on it, the users are all great and it's fun to see what people make. I do want to learn C++ at some stage so I can help, I do plan on writing lots of Javascript plugins for it soon though.
i think this is especially impressive given it's a 2 man project. nice work. how long did it take you guys?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-23-2011 , 06:23 PM
When you hover over the "About Us" tab, the help says "About Scirra and it's game making history." Change "it's" to "its" imo. I'm listening to the funky music now.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-24-2011 , 06:14 AM
Thanks for typo will fix Website I've been doing for a few months. It's been hard though b/c I'm full time web dev at work 9am-6pm so coming home at 7pm and then doing 3 hours more of the same sort of work is kind of crushing, I wouldn't recommend it. Down to 3 days a week at work now so should improve and get more done. Loads more to do on it.

My brothers spent about 6 months to date writing Construct 2 I think, probably around the same amount of time left until it's full release. His other one Construct Classic he started writing when he was 16 I think, had around 500,000 downloads to date! Construct 2 should be more popular and all round better.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-24-2011 , 10:56 AM
Anyone think of a good way to make this more concise? It seems like duplicate code to me although it is simple, it feels ugly having it:

Code:
    /// <summary>
    /// Is a group in the basket already?
    /// </summary>
    public static bool isItemInBasket(List<BasketItem> BasketItems, int GroupID)
    {
        foreach (BasketItem B in BasketItems)
        {
            if (B.GroupID == GroupID)
                return true;
        }
        return false;
    }
    public static bool isItemInBasket(List<BasketItem> BasketItems, int GroupID, DateTime ArtworkDate)
    {
        foreach (BasketItem B in BasketItems)
        {
            if (B.GroupID == GroupID && B.ArtworkDate == ArtworkDate)
                return true;
        }
        return false;
    }
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-24-2011 , 11:21 AM
You can make a private method that takes the list and a delegate that takes in a BasketItem and returns a bool. The body is all the duplicated code, but the if clause just calls the delegate method. The two methods you have now become wrappers for the private method and pass in a lambda expression or declared method that performs the specific boolean expression.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-24-2011 , 11:34 AM
Seems like that would increase the complexity of the code with very little benefit
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-24-2011 , 11:35 AM
Quote:
Originally Posted by Gullanian
Anyone think of a good way to make this more concise? It seems like duplicate code to me although it is simple, it feels ugly having it:

Code:
    /// <summary>
    /// Is a group in the basket already?
    /// </summary>
    public static bool isItemInBasket(List<BasketItem> BasketItems, int GroupID)
    {
        foreach (BasketItem B in BasketItems)
        {
            if (B.GroupID == GroupID)
                return true;
        }
        return false;
    }
    public static bool isItemInBasket(List<BasketItem> BasketItems, int GroupID, DateTime ArtworkDate)
    {
        foreach (BasketItem B in BasketItems)
        {
            if (B.GroupID == GroupID && B.ArtworkDate == ArtworkDate)
                return true;
        }
        return false;
    }
Yeah I don't like it. The Thug's idea is pretty good, but I'd prefer to create a class wrapping your List<BasketItem>, call it BasketItems. Now these two search methods become instance methods of this class rather than generic static methods, and they will require 1 less argument when you call them. It will also be easy to remove the duplicate code this way. And you can also abstract out the process of putting conditions on the list items to search for, in case you are planning to add even more variations on this method. That is, BasketItems could have a addSearchCondition method or something like that. Or the search conditions could themselve be made an object, etc. This part may be overkill for your current dillema.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-24-2011 , 11:44 AM
Code:
    /// <summary>
    /// Is a group in the basket already?
    /// </summary>
    public static bool isItemInBasket(List<BasketItem> BasketItems, int GroupID) 
    {
         return isItemInBasket(BasketItems, GroupID, null);
    }

    public static bool isItemInBasket(List<BasketItem> BasketItems, int GroupID, DateTime ArtworkDate)
    {
        foreach (BasketItem B in BasketItems)
        {
            if (B.GroupID == GroupID && (ArtworkDate == null || B.ArtworkDate == ArtworkDate)
                return true;
        }
        return false;
    }
Not sure if I actually like it, but I don't like overloaded methods having different bodies.

Edit: I like it better than creating a BasketItems class. I think wrapping generic concepts can often be a huge pain in the ass because you end up having to pass through more and more features as you use it in more and more places.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-24-2011 , 11:45 AM
jj, your solution is perfect if he doesn't want to do any refactoring at all.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-24-2011 , 11:48 AM
shabby's solution is what i thought of if the language in question (javascript?) doesn't support default args.

if the language does support default args, then i'd collapse those methods into one with this signature:

Code:
public static bool isItemInBasket(List<BasketItem> BasketItems, 
    int GroupID, DateTime ArtworkDate = null)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-24-2011 , 11:49 AM
Quote:
Originally Posted by gaming_mouse
jj, your solution is perfect if he doesn't want to do any refactoring at all.
I'm not sure what you mean. What other refactoring would you do?

Edit:

Removed my totally wrong assumption about the language...
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-24-2011 , 11:51 AM
jj that's basically what I was thinking of doing as well, it's definitely an improvement over what I posted.

Also like other ideas posted but seems slightly over complicated for this, but the lamdba/linq idea is a good one. You can reduce both functions to one liners like:

Code:
    /// <summary>
    /// Is a group in the basket already?
    /// </summary>
    public static bool isItemInBasket(List<BasketItem> BasketItems, int GroupID)
    {
        return (from c in BasketItems where c.GroupID == GroupID select c).SingleOrDefault() != null;
    }
    public static bool isItemInBasket(List<BasketItem> BasketItems, int GroupID, DateTime ArtworkDate)
    {
        return (from c in BasketItems where c.GroupID == GroupID && c.ArtworkDate == ArtworkDate select c).SingleOrDefault() != null;
    }
I think that's probably best

Edit: This is ASP.net/C#
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-24-2011 , 11:54 AM
I stand by my statement that I don't like overloaded functions implementing the body twice.

It seems like a clue that either the logic can be combined or the functions aren't doing the same thing and should be named differently.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-24-2011 , 11:55 AM
I actually think gaming_mouse's solution is the Better™ answer. But yeah, this comes down to how much you want this to effect the rest of the code base.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-24-2011 , 11:58 AM
Quote:
Originally Posted by jjshabado


Edit: I like it better than creating a BasketItems class. I think wrapping generic concepts can often be a huge pain in the ass because you end up having to pass through more and more features as you use it in more and more places.
Isn't that an argument in favor of it? Otherwise you are creating more and more static methods like the ones in question. One of the main points of OO is to keep data and the methods that operate on it together. Creating static methods like these is essentially doing procedural programming with global functions.

The refactoring I was referring to was creating a BasketList class, and then potentially changing other client code that uses the current static methods to use that class.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-24-2011 , 11:59 AM
Quote:
Originally Posted by TheIrishThug
I actually think gaming_mouse's solution is the Better™ answer. But yeah, this comes down to how much you want this to effect the rest of the code base.
Why?

The only downside that I see of the pass null for date solution is that now that function accepts null in a way that maybe doesn't make sense for the app.

The downside of wrapping List<BasketItem> in a class is that now you have to pass all of the List functionality to BasketItem as you need it. You're adding a lot of code for almost no value. IMO, this is a good example of over-engineering.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-24-2011 , 11:59 AM
Doh still getting to grips with linq/lambda, but this one seems as good as any other solution right? Nothing repeating technically:

Code:
    /// <summary>
    /// Is a group in the basket already?
    /// </summary>
    public static bool isItemInBasket(List<BasketItem> BasketItems, int GroupID)
    {
        return BasketItems.Where(c => c.GroupID == GroupID).SingleOrDefault() != null;
    }
    public static bool isItemInBasket(List<BasketItem> BasketItems, int GroupID, DateTime ArtworkDate)
    {
        return BasketItems.Where(c => c.GroupID == GroupID && c.ArtworkDate == ArtworkDate).SingleOrDefault() != null;
    }
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m