Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

112 Neutral

About freddyscoming4you

  • Rank
  1. freddyscoming4you

    When To And Not To Use Exceptions?

    Conceptually speaking I see exceptions as something that needs to halt execution of your application and NEEDS your application's attention if you're looking for specific exceptions to handle. Return codes on the other hand are simply ways to do small talk, so to speak, in your code. I find it to be generally useful to use state enums to let your code know where it is since exception throwing in most cases is a very slow event. So... enum ProcessingStatus { Pass, InputIsIncorrectFormat } void DoProcess(string input) { switch(ProcessWork(input)) { case ProcessingStatus.Pass: // proceed, return, do nothing, call NextStep() or w/e break; case ProcessingStatus.InputIsIncorrectFormat: // either report back and ask for new input or try to auto correct and try again break; } } ProcessingStatus ProcessWork(string input) { /// validate code if fail return ProcessingStatus.InputIsIncorrectFormat else carry on and return ProcessingStatus.Pass on success // however on something critical like a memory you may want to throw MemoryLeakException("ProcessWork created a memory leak with the following state at the time of the leak") } To me that is pretty easy to read, understand and is generally friendly. Granted, that is coming from a C# background but it's generally very clean.
  2. freddyscoming4you

    C vs C++ features

    I wasn't trying to say that antiquated style is preferred or not. I was simply curious if some of the older features are "better" for highly performant systems like a game engine. Regardless, excellent commentary!
  3. freddyscoming4you

    C vs C++ features

    So it's like calculus... excellent. LOL
  4. freddyscoming4you

    C vs C++ features

    Listening to the dotnetwrocks pod cast here: http://dotnetrocks.c...spx?showNum=695 Kate talks briefly how people are actually using C rather than C++ with things like using malloc rather than just newing an object or using smart pointers. Is using the older methods for these things preferred for game development or are people just being newbs and not realizing what tools they have at their disposal?
  5. freddyscoming4you

    [web] Javascript & PHP

    Javascript is inherently insecure. That said you can implement some schemes to mitigate its insecurities such as having your script make a call for a decryption key that expires very soon (like 5 seconds) or even is only good for one use but that could take some more algorithmic math than you may have. The only way to be able to "secure" your app is to use a browser plug in that incorporates encrypted communication like Java. I'm not sure about Flash but I would think they'd have something like that built in. No matter what though, you should NEVER take input received by the server from the client and pass it directly to your database. The best way to secure your database is to thoroughly scrub and verify the data you pass into your database. I would argue that this single task will take about as long to develop the game mechanics themselves. Best of luck to you.
  6. freddyscoming4you

    [.net] Trying to Implement Generic Method

    I started coding that around 12:30 and I was trying to think of a generic way to use interfaces and generics to create a singular method that I could use to execute API calls since they all follow the same pattern and my mind shouted "GENERICS!" And, so it was, or wasn't. Haha. Thanks for the suggestion. I stripped out all the generics stuff and simply passed in a IApiResponse object and return it's parse method from that. Subsequently I removed the parsing code out of the constructor and put it in the parse method which returns void. A few hours of sleep and a thought out suggestion will do wonders.
  7. I have implemented an interface to be used by all certain types of a class which represents a response to a WebRequest. I have the interface implement a method whose return type is also the interface so I can get a return value to be the parsed response. The parsing of the response is handled in the interface implementation in each class, naturally. However, I'm having difficulty in implementing this as I don't have hardly any experience writing generic methods and I'm not having much help using Google. Below is my class implementation, or what I have managed to cobble together so far. Can you see what's off? Thanks. First, the interface declarations: using System.Xml; namespace EVE_API.Interfaces { public interface IAPIResponse { IAPIResponse ParseResponse(XmlDocument response); } } using System.Collections.Generic; using System.Xml; namespace EVE_API.Interfaces { public interface IEveAPI { string ApiName { get; } Dictionary<string,string> Arguments { get; set; } } } Now, the response class: using System; using System.Xml; using EVE_API.Interfaces; namespace EVE_API.APIs.Miscelleneous { public class ServerStatusResponse : IAPIResponse { private string _version; private DateTime _currentTime; private bool _open; private int _onlinePlayers; private DateTime _cachedUntil; public string Version { get { return _version; } } public DateTime CurrentTime { get { return _currentTime; } } public bool Open { get { return _open; } } public int OnlinePlayers { get { return _onlinePlayers; } } public DateTime CachedUntil { get { return _cachedUntil; } } private ServerStatusResponse(XmlDocument responseDocument) { _version = responseDocument.SelectSingleNode("/eveapi").Attributes["version"].Value; DateTime dtTry = DateTime.MinValue; DateTime.TryParse(responseDocument.SelectSingleNode("/eveapi/currentTime").Value, out dtTry); if (dtTry != DateTime.MinValue) { _currentTime = dtTry; } else { throw new MalformedResponseException("Could not find currentTime in response from SeverStatus API."); } bool boolTry; bool.TryParse(responseDocument.SelectSingleNode("/eveapi/result/open").Value, out boolTry); _open = boolTry; int intTry; int.TryParse(responseDocument.SelectSingleNode("/eveapie/result/onlinePlayers").Value, out intTry); if (intTry > int.MinValue) { _onlinePlayers = intTry; } else { throw new MalformedResponseException("Could not find onlinePlayers in response from SeverStatus API."); } dtTry = DateTime.MinValue; DateTime.TryParse(responseDocument.SelectSingleNode("/eveapi/result/cachedUntil").Value, out dtTry); if (dtTry != DateTime.MinValue) { _cachedUntil = dtTry; } else { throw new MalformedResponseException("Could not find cachedUntil in response from SeverStatus API."); } } public IAPIResponse ParseResponse(XmlDocument response) { return new ServerStatusResponse(response); } } } And now the class trying to wrap all the above together using System; using System.Collections.Generic; using System.IO; using System.Net; using System.Xml; using EVE_API.Interfaces; namespace EVE_API { public class APICaller<T> where T : IAPIResponse { public APICaller() { } public T ExecuteAPICall<T>(IEveAPI api) { List<string> urlParts = new List<string>(); urlParts.Add(api.ApiName); if (api.Arguments != null) { urlParts.Add("?"); var keys = api.Arguments.Keys; foreach (string key in keys) { urlParts.Add(key); urlParts.Add("="); urlParts.Add(api.Arguments[key]); urlParts.Add("&"); } urlParts.RemoveAt(urlParts.Count - 1); } string completeUrl = urlParts.ToString(); WebRequest request = WebRequest.Create(completeUrl); WebResponse response = request.GetResponse(); XmlDocument document = new XmlDocument(); document.Load(response.GetResponseStream()); IAPIResponse apiResponse = new (IAPIResponse)T(); return apiResponse.ParseResponse(document); } } }
  8. freddyscoming4you

    Opinions on C# dynamic

    I wasn't aware of the dynamic type. After the reading I've done I don't see why anyone would use it with a purely .NET application. From what I can see the dynamic type itself is for interop purposes only. While you can use it and abuse it I'm guessing if you're on a project where such horrible code can be used then I'd suggest you upgrade to a better place to work.
  9. freddyscoming4you

    Opinions on C# dynamic

    The point of var is so you can focus on coding. C# isn't nearly as dynamic as you might think. Once the type is set from the instantiation line then that's the type and it can't be changed later on. You will actually get a compiler error. Also, the "right" way to instantiate a var is to either set it right away or do "default(type)". So if you have a var you want to use as an int you would say "var a = default(int);." To me that's very clear. You would be dumb to declare a var way up in your code and initialize it much later where there could be ambiguity issues. Furthermore, once you set a var Visual Studio will examine the type that you're setting the var to and after the instantiation line if you hover over the variable intellisense will report the correct type in the flyout box that appears.
  10. freddyscoming4you

    [.net] DllImport Marshaling Issue

    You should be able to use the same types from VB to C#. It sounds like one of those "if it aint broke don't fix it" situations. One of the reasons the VB code is the way it is may be because that array structures may be different and the DLL you're using parses the incoming and outgoing values in a custom way. I would just use the C# equivalent types that the VB code used.
  11. freddyscoming4you

    Opinions on C# dynamic

    Using var is ingenious for LINQ. Whether you're using LINQ to SQL or LINQ to objects it removes a lot of guess work in which type you need to cast to/from. I've never had an issue either supporting or writing new code where var messed me up with LINQ. Granted, that's about the only places I've seen it used heavily but it's treated me pretty swell.
  12. freddyscoming4you

    Legalizing my Game

    I seriously got negged for that? Wow... someone needs to lighten up. *preps for another neg on this post. weeeee*
  13. Who pissed in your cheerios? I thought the same thing when I read the OPs question. It sounds very much like an image with text boxes set on top of it.
  14. freddyscoming4you

    Legalizing my Game

    If they sign it, then you can forget I said it might be too late to expect them to sign it, because, well, because they signed it. [/quote] Alright cool. Now what is the best template contract you think I should use? [/quote] I prefer contracts that use verbiage similar to "I'm in your codes stealin' your rights."
  15. Pretty much. Your only other option besides using a 3rd party library is going the unsafe route and copying frame data directly to memory. Which, you could get some speed boosts using native pointers while getting to switch to and from the managed environment of .Net. It could work.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!