Chapter 6

Programming Dynamically!

IN THIS CHAPTER

check Understanding dynamic typing

check Defining variables

check Staying flexible by being dynamic

check Making static operations dynamic

Dynamic programming is another one of those buzzwords that really doesn’t have a clear definition. At its loosest, it means developing something in such a way that the program makes more decisions about the way it runs while running, rather than when you compile it.

Scripting languages are a great example of this type of programming. When you write something in VBScript, you don’t compile it at all — all the decisions are made at runtime. Ruby is another good example: Most of the time, an entire program can just be typed into a command prompt and run right from there.

Some examples are not so good — like VB Classic. Remember the Variant type? You could declare a variable to be Variant, and VB wouldn’t decide what it was supposed to be for real until the program ran. In the best of cases, this feature added immense flexibility to the language. In the worst of cases, you got Type Mismatch errors at runtime.

To give a ...

Get C# 7.0 All-in-One For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.