No, they left long ago. What confuses me the most is how you can know enough code to be able to write something like that, but not enough to know how to do it without the ridiculous switch statement. It's like a weird ignorance knife-edge.
Kieryn Phipps
Posts
-
Beautiful code... -
Beautiful code...... discovered in a legacy app.
public string GetCode(string ProjectCode, string id) { try { int len = ProjectCode.Length + id.Length; int rem = 10 - len; switch (rem) { case 1: ProjectCode = ProjectCode + "0" + id; break; case 2: ProjectCode = ProjectCode + "00" + id; break; case 3: ProjectCode = ProjectCode + "000" + id; break; case 4: ProjectCode = ProjectCode + "0000" + id; break; case 5: ProjectCode = ProjectCode + "00000" + id; break; case 6: ProjectCode = ProjectCode + "000000" + id; break; } } catch (Exception ex) { } return ProjectCode; }
-
Testers coding bug fixes directly?So I'm a dev manager and our QC lead who is gaining proficiency in coding, though is by no means even a junior programmer has taken it upon himself to directly fix some easy bugs. This is certainly a faster way to get things fixed as our dev resources are severely limited. So far it's restricted to typos/grammar mistakes in hard-coded string UI messages and that type of thing. Good or bad? Thoughts?
-
Randall Munroe is mad - but good.I actually did sit there for 130 days as did many others A community was formed and much fan art was created of which I played a large part. I now have my own web-comic-like thing going because I was inspired by what Randall did with Time and the hundreds of other people that contributed as we were watching it unfold on the forum. Here's Randall's own blog post he wrote about it when it finished: http://blog.xkcd.com/2013/07/29/1190-time/
-
Office layoutsIn my experience I would say it depends on the type of work being done. If the work involves lots of small tasks/requests done by and for many different people or even if it's a medium-sized single project but done in an agile way, open plan or cubicle is best. However if the work is for a large complex system and is technically difficult, requires focus, and many hours of work, then private offices are more suitable.
-
My First Post Of Shame - ReturnFalse()?I think it would be less misleading if the ReturnFalse function was instead named AbortAction or something closer to the intention. I think it is better practise to name a function or method for it's intended purpose or meaning than for what it literally does. The intention/meaning and what the method actually does usually are the same, but there can be subtle differences and occasionally vast differences such as in this case. Oh and a comment for the function would not go amiss either:
//This function is used to suppress events such as onclick
function AbortAction()
{
return false;
} -
Could be the most 'meta' class I ever wrote... or a coding horror?ServiceCallInfo is actually a DataContract. Yes... I have actually implemented a service that can call any other service it happens to find in it's configuration. I'm sure none of this would be necessary in a dynamic language like Ruby, however what other framework/language provides such a comprehensive and flexible service framework like WCF? I wasn't sure if this should go in "Clever Code" or "Hall of Shame" for it's meta-ness. I put it here, because I like to doubt myself :-) Right now it depends on all the service contracts being contained in one interface assembly though... I suppose I could also pass in the assembly name containing the contract and have it dynamically try to find or load the assembly too. Or would that be too far?
internal class ReflectedServiceChannelMethod
{
private static readonly Assembly InterfaceAssem = Assembly.GetAssembly(typeof(IGeneralLookupService));
private readonly Type _contractType;
private readonly Type _channelFactoryType;
private readonly object _channelFactory;
private readonly MethodInfo _createChannelMethod;
private readonly MethodInfo _callMethodInfo;
private readonly ParameterInfo[] _methodParams;public ReflectedServiceChannelMethod(string interfaceName, string methodName) { \_contractType = \_interfaceAssem.GetType(interfaceName); \_channelFactoryType = typeof(EdsChannelFactory<>).MakeGenericType(\_contractType); \_callMethodInfo = \_contractType.GetMethod(methodName); \_methodParams = \_callMethodInfo.GetParameters(); var channelFactoryConstructor = \_channelFactoryType.GetConstructor(new Type\[\] {}); \_channelFactory = channelFactoryConstructor.Invoke(new object\[\] {}); \_createChannelMethod = \_channelFactoryType.GetMethod("CreateDefaultChannel", new Type\[\]{}); } public object CallService(ServiceCallInfo job) { object channel = null; try { channel = \_createChannelMethod.Invoke(\_channelFactory, new object\[\] { }); var parameters = new List<object>(); foreach (var methodParam in \_methodParams) { object value = null; var paramType = methodParam.ParameterType.MakeByValType(); if (job.Parameters != null) { ParameterInfo param = me
-
Nested loopsI have a razor view for a model that contains categories, sub-categories and then the items. That's a 3 level foreach right there. Personally I don't think it's messy. Maybe the sub-categories could be refactored to a separate partial, but seeing as for now this is the only view using them I see no reason to do that:
var subCategoryGroups = Model.GroupBy(r => new { r.Category, r.SubCategory });
var categoryGroups = subCategoryGroups.GroupBy(r => r.Key.Category);foreach (var catGroup in categoryGroups)
{@catGroup.Key
@foreach (var subCatGroup in catGroup) {
@subCatGroup.Key.SubCategory
@foreach (var item in subCatGroup) { @Html.ActionLink(item.DisplayName, "RunReport", new { item.ReportProcedureId }) } }
}
-
Anyone used/using MonoTouch for ipad/iphone?If the app is anything game-like, I would recommend Unity3d. It's a 3d engine (you can implement 2d gui's - though not in a clean way) that supports monotouch. It builds to multiple target environments including iOS. I recently published an iPad app using Unity (Fish Swarm)
-
Computer Science: So, what's it like?I started out doing Aerospace Eng. but switched to Comp Sci after 1 year. Basically I spent most of my time in the 1st year programming games etc as a hobby and fell behind on the engineering coursework etc - of which there was A LOT. For me, it was a smart move - computer science in comparison to Engineering was generally a breeze - there was about 60% the number of lectures and coursework to do, and for me it was all easy and stuff I mostly knew. It covered various advanced topics and specialisms in the 2nd and 3rd years which kept me interested and broadened my knowledge, but I never felt pressured doing something I was not interested in. In retrospect, in some ways it did not discourage my lazy tendencies, which could be a bad thing. However, if I had continued down the engineering path, I might have become overwhelmed and depressed and totally failed... who knows? If you feel you could overcome and become very hardworking and dedicated enough to get through engineering that would probably be a great thing, but if you feel it is getting you down, then a switch to Comp Sci is probably just what the doctor ordered :-) PS... As a follow up, 10 years after I graduated from Computer Science I am a seasoned software developer and enjoy my work. I moved to New York about 7 years ago from the north of England (where I'm from originally) where it is reasonably easy to find software development work as long as you are good, passionate and interview well. Not sure how this might compare to the UK as a whole, but New York is probably similar to London. As a side hobby I still write video games (published my first completed game for the iPad last year) There's not usually that much money in the game industry, unless you are lucky, which is why I have not made it my main career focus.
modified on Monday, January 17, 2011 10:31 AM
-
Which language is faster?This is spot on. I did a year of Aerospace Engineering at University before switching to Computer Science. We used Fortran in Engineering because it was numerically tight. It has strict standards on numerical accuracy and replicating results independent of platform or compiler. I never used or have heard of anyone else using Fortran since that switch. Regardless of speed, if numerical accuracy matters then stick with Fortran. I have seen first hand that the same code in other languages like C/C++ can produce slightly different results depending on the compiler used because the standards are not as strict.
-
Which language is faster?It's the compiler that matters more than the language. Any compiler that is written specifically for a native architecture is going to do better than one that is standard or for a general architecture. Also certain compilers may work better with certain algorithms. Same for the language probably - perhaps certain algorithms work better for certain languages. In terms of language, there will be probably be little difference between C, C++ or Fortran. It will depend most on which compiler you choose and the algorithm you are writing than it will the language.
-
Why I Hate VB TodayMicrosoft should have just called C# "VB7" and never invented VB.NET. Old school VB programmers like myself would have naturally moved to the new "C-style" VB language long ago, and we would all be better off. Why they would keep perpetuating this duality of quality on the same framework I have no idea...
-
today's newsletterNope, me too. Actually I posted the question in the main questions board. Should probably have asked it here... oops.