Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

June 12, 2009

On Programming

Here's some quotes, mostly pulled from here.

The difference between a Designer and Developer, when it comes to design skills, is the difference between shooting a bullet and throwing it.

Scott Hanselman

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.

Brian Kernighan

On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.

Charles Babbage

Beware of bugs in the above code; I have only proved it correct, not tried it.

Donald Knuth

Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem.

David Wheeler

Read More......

May 7, 2009

Simon .NET

So I got it into my head today that I'm going to build my own Simon game.

It should be relatively simple, to start with anyways. I'll start with 3 basic pieces, 1-2 of which are most likely going to be re-used.

  • A Simon Generator/Validator: really simple. Pass it the round number and it generates an random sequence of that many buttons. Pass in the sequence it sent out, plus the sequence the player it, and it verifies that the sequence matches.
  • A game logic piece: this will control starting/ending the game, flashing the lights/making sounds at the start of the sequence, validating the user's input in-place and using the validator piece whenever it thinks the user's turn has ended.
  • A GUI. 4 colored buttons that can flash and accept user clicks, plus a start game button and difficulty selector. Possibly also a game-mode selector, if I choose to to implement more that just the most basic game mode.
Here's the slightly insane part: I want to take this basic stuff and expanded it into a fully-logged, fully-networkable game. Play against your friends or play in ladder tournaments. That's the really crazy part.

Anyways, I plan on attempting to do this with TDD, or at least building some unit tests along the way. Wish me luck!

Read More......

August 5, 2008

Sharepoint?

I can't find a reference to the earlier versions in the usual source (wikipedia), but I can tell you this: earlier versions of Microsoft Sharepoint were not well received by the community. Apparently the latest version is more friendly (but still not as friendly as it could be) and is a lot more than what I remember Sharepoint being advertised as (a long time ago, admittedly).

Last night was the monthly FSDNUG meeting. We started out with a brief tool presentation from David Mohundro about Lutz Roeder's Reflector. It's a great tool for analyzing the libraries you're using or figuring out how the IL the .NET compiler generates looks like when disassembled and uncompiled. I was talking to David after the meeting, and he mentioned a feature that sounded useful, if a little out of the way: you can bind Reflector such that special hyperlinks can open it to specific assemblies. That would be handy for sharing assembly locations.

The main presentation was from Steve Walker (he hasn't posted in a while), of Microsoft Consulting Services, about Microsoft Sharepoint. I'll admit I was a little biased coming in, remembering what was probably the first version of the servers being marketed around my Dad's office, thinking, "How could this be useful to us?" Sharepoint, though, looks like a great resource for enterprise situations that can really use a combination web-development framework and deployment solution. The biggest problem I can see with using it is that if you don't deploy your applications the "right way", the incredible scalability possible, where you can just bring a new Sharepoint server online and make it add itself into your farm of Sharepoint servers, disappears.

Mostly, though, I see it as a way to handle deployment of web applications across server farms in an easily repeatable way (QA and operational departments should love this). It also provides a framework to work within as well, especially through the use of what's called Delegate Controls. These are basically controls that you can setup that say, "Hold a place me, I'm going to put something else here - maybe more than one - but I also want some functionality in case I don't replace you." The most visible of these on Sharepoint sites is usually the search box in the upper right. There's a default version and appearance of the control, but if you want to roll your own you can set up your search box in the place of the delegate control.

But I'm not really qualified to talk about it. Best to give you a link, in this case one that Steve pointed us too after the meeting: FanU. I won't get any use out of it, but that whole site is setup using Sharepoint.

Read More......

July 26, 2008

Overrides and Shadows

Nice little inheritance tools there. I have no problem with them, except that I've had to shadow way to many methods on List and LinkedList for my combat tracker.

See, I need to know when my CreatureList (inherits List) and InitiativeList (inherits LinkedList) objects change. Neither base list type does - for that you have to use BindingList.

So I've been using not insubstantial, even if small, time shadowing (actually "new"-ing in C#, Shadows is the keyword from VB.NET) every add/remove method on those two classes to run the base's version and then fire off an event.

Which also leads me to post the following: the difference between overriding and shadowing.

When you override a function implemented by a base class, you change the function pointer for all instances of that derived class no matter what they look like to the outside world.


public class BaseClass
{
public override string ToString()
{
return "BaseClass";
}
}

public class InheritedClass : BaseClass
{
public override string ToString()
{
return "InheritedClass";
}
}

BaseClass testOne = new BaseClass();
//testOne.ToString() == "BaseClass"
InheritedClass testTwo = new InheritedClass();
//testTwo.ToString() == "InheritedClass"
BaseClass testThree = new InheritedClass();
//testThree.ToString() == "InheritedClass"


Shadows/new works differently. It only 'overrides' the function pointer if the inherited class is being used as the inherited class.


public class BaseClass
{
public override string ToString()
{
return "BaseClass";
}
}

public class InheritedClass : BaseClass
{
public new string ToString()
{
return "InheritedClass";
}
}

BaseClass testOne = new BaseClass();
//testOne.ToString() == "BaseClass"
InheritedClass testTwo = new InheritedClass();
//testTwo.ToString() == "InheritedClass"
BaseClass testThree = new InheritedClass();
//testThree.ToString() == "BaseClass"

Read More......

July 24, 2008

Combat Tracker

http://code.google.com/p/4ecombattracker/

That's where you can find my combat tracker. It's totally non-functional (the trunk version, anyways). I'm using "/branches/initiative/" to get the basic turn order stuff working.

Hopefully putting this out there will be a good experience. Plus, I'm trying out VisualSVN to handle my stuff. It's basically a VS plugin to handle source control via TortoiseSVN. I'm just on the trial now, but if it works out, I'll buy it.

Read More......

July 23, 2008

Combat Tracker

My creative functions are being seriously consumed by efforts to create a 4E combat tracker. It would work for other things too, just not so easily.

That and watching the end of the latest series of Doctor Who.

Read More......

July 19, 2008

No-CD Cracks

This is pretty crazy. Why on earth would your devs do that - especially when you consider that, with the size of the internet, someone is doing everything conceivable with your files. And that, sounds dirty for some reason.

Read More......

July 14, 2008

How I Got Started in Programing, Part Two

What was your first professional programming gig?
My first and only, so far, professional programming gig is at Data-Tronics. COBOL, VBScript ASP with JavaScript clientside, VB.NET (both console and WinForms apps; not much ASP.NET though). Although, it's not the first time I got paid for code or markup.

If you knew what you know now, would you have started programming?
I'm not sure. Probably, I would, but I'm also interested in and somewhat knowledgeable about the hardware side of things. Sometimes I feel that would be a bit slower: unless there's a problem or new hardware requirements, things could be pretty quiet. It's not that way at our shop, but we've got thousands of systems interacting.

If there was one thing you learned along the way that you would tell new developers, what would it be?
I can't write just one, so here's 2-3:

Learn how to maintain code. Learn how to write maintainable code. They're hard to do outside of a professional gig, but they're important. There is such a thing as objectively maintainable code, but I haven't seen any (including my own) that looked it.

Get used to other people seeing your code. There will always be someone who thinks it's crap, and usually someone who thinks it's good (as long as it works, anyway).

To second Brian, get involved. Even if you don't want to spend an excessive amount of time learning, you should always learn something new. I don't care if it's programming, computers, science, art, or history. The act of learning keeps your mind flexible, which keeps you employable.

What's the most fun you've ever had... programming?
It's a toss up between the final group project for a video game programming course we convinced out college faculty to "teach" and getting a joystick to run a little robot for JPL (it was a summer research fellowship) over a wifi connection.

Tag, you're it!
I'm not sure who to tag with this, so I'll hit some of Brian's up.

And add one: Tim Franklin.

Read More......

How I Got Started in Programing, Part One

I've been called out, so here's a response. At least, as good of one as I can think at 6:10 in the morning.

How old were you when you started programming?

I don't really remember for certain, but I'd say fairly young. Probably by the time I was 10.

How did you get started programming?

I think I got started on either Timex Sinclair or a TI-99 4a. It appears that I'm following a path not unknown to most programmers of that era: I copied down games in BASIC. That's right, I think I had a book of BASIC programs that were just games.

Of course, not all of them worked, and I stopped after a few years - mostly. See, my dad's in the other side of the computer business. He's been a lot of things over the years, but now he's the Technical Support Manager for a state organization. So I've been around a lot of computers.

What was your first language?

BASIC. I remember, in addition to copying down some games, writing some really simple math programs. My first "real" language that I took seriously though was C++. Like Brian, I think this is why I'm more comfortable in C# - although sometimes I wish it would stop asking me for semicolons. Not all the time though, because it's nice to no have to use a line continuation character.

What was your first real program?

I'll take this to be the same question as Brian did. I'll also answer the same way: my capstone project at Arkansas Tech University. In our case, though, they have us do what's effectively "community service" programming. I don't think it ever saw real use, but my group and I wrote a fairly standard news system (and some other stuff - I think we had job listings and profile pages) for the CS Alumni site done in PHP with a MySQL backend on Linux.

What languages have you used since you started programming?

In college: C++, PHP, I think several different Motorola Processor Assembly languages. Real World: VB.NET, Javascript, COBOL, a really weird in-house macro'ed assembler (barely), VBScript. I've dabbled in some Python and C#, but haven't really finished anything in either language.

--------

I know this is supposed to be a one post thing, but I'm running short on time this morning. I'll finish up this evening.

Read More......

July 7, 2008

July DNUG Meeting

So tonight, in addition to the traditional pizza, we also had the traditional (I guess that's ok to say, it has only been a few months though) presentation and the soon to be traditional "Tool Tip".

This first presentation of a "Tool Tip" - my own name for it, though if you want to take it, do so Paladino - was vouching for and showing some uses of some of Sysinternals's utilities. Now, I'd heard of Sysinternals before, but didn't know they'd been bought by Microsoft.

Two things of note not mentioned at the meeting:

  1. Sysinternals is the group behind Rootkit Revealer, which famously uncovered the infamous Sony Music CD rootkit.
  2. Some PC games have copy-protection software that watches for either an installation of Process Explorer or for an active Process Explorer, uh, process. So, fair warning to those of you who may game on a machine you also use for developing.
The meat of the meeting though, was a presentation on the Windows Communication Foundation (WCF), which is part of the .NET framework since version 3.0. Its focus is on abstracting most of the communication involved in passing messages between clients and services (both local and intra-/inter-network) while allowing both the ability to build in your own handlers/channels for the communication and to communicate with at least some non-WCF clients or services.

It's all based around the decoupling of client and service (or server) through the use of Web Service Definition Language (WSDL) "contracts". This means that you don't need to explicitly share code between your two pieces and really facilitates having, say, an internal WinForms or WPF application and an external ASP.NET or Silverlight application that make use of the same functionality.

Since WCF is entirely opt-in through attributes (except for the actual host of the service, which I would hope is obvious), it should be pretty easy to adapt an existing codebase - probably the "business logic" layer of a standard WinForms app - for use as a service. And like I said above, depending on how the service is being hosted or the service itself, a WCF service can talk to a non-WCF client and a non-WCF service can communicate with a WCF client. That means you can talk cross-platform if you have a mixed shop.

It's some pretty cool stuff, especially with the use of the IExtensibleDataObject interface that allows a service and the client to pass around information that they don't really understand but some service in chain uses or requires. It's a sort of "soft versioning" so that the clients don't blow up when you change the service.

Read More......

June 23, 2008

Introducing Unit Tests (aka The Joy of Tweets)

You know, this is one of the reasons I like Twitter. If you follow people who interest you, you'll find out interesting things and possibly see some good ideas.

In particular, Jeff Atwood was tweeting about unit testing a linked to this old blog post of his. In it, he complains about excessive religious fervor from the TDD crowd, and suggests it's more important that people get used to using unit tests than that they get used to writing them before the code. Honestly, I agree and not just because I'm not used to unit tests.

I say this because he then goes on to make 2 great suggestions. First, that unit tests are important enough that they should be first class language constructs instead of being implemented the way they are now, with 3rd party libraries and external executables. Second, though quoting someone else (the link's dead though, now), that a great - if not the best - way to get people used to writing unit tests is to write a test whenever you'd think about using print or debugger code.

It may be an old post, but it's one I didn't know about and one I wouldn't have found without Twitter. Now, if only we could magically make it more scalable.

Read More......

June 11, 2008

Stored Procedures

A friend of mine is studying up for an SQL Server certification, and posted some commentary on a section about stored procedures.

I have to say I don't like the tone of the passage either. I think I see where the author's coming from, though, and, like the first commenter, I think it's largely for protection against injection attacks. In particular, I'd say it's because they provide language-agnostic protection against injection attacks. I almost wanna say that it's an attempt at protection against developer error creating attack vectors in your software.

What I mean by this is simple: if your policy is to only ever use stored procedures, you don't have to worry about a choice of languages, libraries, or SQL server calls allowing end-users to get into your database. You don't have to depend on someone coding input sanitization (which you should do anyway) or the use of parameterized queries when all the data access is being done with delegated authority through a stored procedure.

Read More......

June 2, 2008

Object-Relational Mapping

For those of you who haven't noticed these past three months, I tend to blog about the FSDNUG meetings relatively shortly after. Since the meetings happen on the first Monday of every month, guess what time it is?

Since the dawn of time (ok, for as long as there have been databases and programmers that could connect to them), man has searched for ways to get database ... data ... into a usable form that programs could use. One of the solutions to this problem, in the land of object-oriented programming, is to use an ORM (see title) tool to help. There are a variety of these available, probably as many as there are motivated, capable people who have different ideas of how to do things. Of the many, the .NET world includes NHibernate (a port of Hibernate Core for Java), the ADO.NET Entity Framework (which hasn't quite been released yet, I believe), and SubSonic.

Tonight, Michael Paladino gave a presentation on ORMs and, in particular, SubSonic. SubSonic is an open-source (free as in speech and free as in beer) ORM tool designed for use with ASP.NET websites. From the demos offered, it looks like an incredibly useful tool if you set you database up properly (it's definitely possible to use configurations to get some functionality out of it, but at its base it relies on certain conventions being followed). They even include some fairly handy web forms controls, even if some of them are only really useful to accelerate your RAD processes at the earlier stages.

It really sucks, IMNSHO (that's right, look it up), that I'll probably never see use out of any tools like this at my current office. First, we'd have to find something that supported DB2 (I jokingly asked during the meeting, "So we won't be getting LINQ to Mainframe?"). Then we'd have to convince the DBAs and the cpu-efficiency folks that it was a good idea.

By the way, Paladino, you should at least update your blog to mention/discuss the presentation. For those interested in the PPT or the sample project, click the Fort Smith .NET User Group link to the right and then go to "Previous Meetings". Until next month, it should be the first meeting at the top of the page (for future reference, it's the June 2, 2008 meeting).

Read More......

May 22, 2008

Really?

Somehow I doubt this is true. I'll admit it's possible, but I think it's more likely that some people screwed up and were looking for a scape goat. Even if this was the case, Moody's wasn't the only financial institution giving the AAA ratings.

Read More......