This is what it looks like when JavaScript development goes bad.
welcome to my blargh |
now with 88.333% more desu. repeating of course. |
Here's how you create and iterate over a list in C#:
Now, here's that same code in Java: As you can see, the Java code is a bit more verbose. While C# defines its List class as a strongly typed class, Java treats its own as a very generic collection that requires you to cast elements as you access them. Also, C# does some synaptic sugar with its "foreach" statement that automatically accesses the iterator and loops through the collection.Just something I'm working on. More details later. ;)
Real simple: by calling the preventDefault() method on the event, you can stop a link from taking a user away or a button from posting back. This is a routine task for providing controls for your web app. You will use this all the time.
Going a bit further, you can put in some code to execute:Over the last few days I've been studying Lua in order to start developing some AddOn ideas for World of Warcraft. Lua is a very lightweight OO language used for embedding in other software to provide scripting and customization features.
A feature of Lua called "varargs" caught my eye. In a nutshell, it allows you to define a function with a variable number of arguments. This is similar to C# or Java, however in those languages you pass in arguments to the main method via a strongly typed array (ie String[] args). Before the "..." or varargs operator, you can pass in any number of named arguments that must be passed to the function. It looks like this: What's this? A super loosely typed language that has the gall, the unmitigated lunacy to allow completely random and optional arguments instead of relying on that old cornerstone of OO thought, overloading? That was my initial reaction. But after a while, I started thinking about the possible reasons behind a feature like this and why it actually was a correct design. It started with my friend making the following observation. As analytical thinkers, programmers value accuracy and perfection above all else. We are obsessed over the perfect algorithm, the perfect design. We want our software to be accurate to the hundred trillionth and have a rock solid design that will be robust yet flexible. However, in this quest for perfection, we sometimes lose sight of what's important: getting the job done. While quality is important in all things, it's equally important to meet the needs of the user. At my previous job after a merger, we adopted PHP as the official development language after years on Classic ASP. As a .NET developer, I was aghast at some of the fast and loose liberties our new coworkers took with web development and the loosely typed features of the language. During a discussion over the merits of strong typing someone said, "Sure, strongly typing's great if you're working for Mission Control". For a while I was puzzled, didn't these folks want to make the most robust, rock solid software? Well yes, to a point. The fact that I overlooked was that web development is more about new features faster. In an e-Commerce system, it's important to be correct, but money only goes to two decimal places. What language can't do that accurately? More recently, I worked on a small port of a URL shortener that I call Chorty. Trying to come up with a way to create a random 4 character identifier was a bit of a challenge. I wanted to make the system never run out of possible combinations ever. The computer scientist in me was taking over. Eventually though I realized two things: 1) This is not going to be the next TinyURL.Wow, this is driving me utterly insane. Take a look at the two versions of this code:
Pretty simple right? I left out some stuff for brevity, but I have a very simple subclass defined called JsonJob into which I copy the properties from the Linq Object. Version 2:So, more brief. Selects data using Linq, returns an anonymous type which I push out as a JsonResult.Technically these two should work the same way. Why does Json() care about type? But it seems that for me, anonymous types create malformed Json or something. Here's my AJAX request using jQuery: Again, pretty simple. But if I use Version 2, the error callback is triggered every time (with no error defined!).Of course everyone says This Doesn't Happen For Me (tm), but that's no help.- You don't need a view for every controller action. For instance you can return a JsonResult for Ajax requests.
I use two (three?) tools on a daily basis to build and deploy code.
1. RobocopySo you deleted a bunch of files, or moved things around and checked in a bad revision. You need to do a "reverse merge".
1) Revert to the last known good revision.(seriously, who thought this was a good idea?)