Classes Come Last
(Programming)
Noferblatz (08 November 2017 07:16:41)

Peculiar name for an essay on programming, don’t you think? Let me explain what I mean by that, and you’ll see why I named this essay that way.

In accordance with the principle of “incremental development”, you’d build an application a bit at a time, perhaps one loop or one function at a time. Between each burst of coding, you’d test to ensure what you have so far works.

One additional technique which is useful (at least in my opinion) is to build classes first by code with no functions. Each “function” of the code is written in the same file, without functions and with all variables in scope. Testing occurs after each block of code is written. Blocks of code are added and tested, perhaps a block at a time.

After most or all of the blocks get built and tested, each piece is then turned into a function. Testing occurs again. This phase of turning code blocks into functions continues as before, and variable visibilty is now taken into account.

Once this is done, each function can be turned into a class method, and variable visibility can be resolved, possibly with variables turned into class member. Once this is done, each function can be turned into a class method, and variable visibility can be resolved, possibly with variables turned into class members.

Testing continues.

Finally, the class is complete and the full assembly of the class can be tested within the class file. Finally, the whole package can be called and tested from a controller file, or whatever.

Thus, the class comes last.

I’m just sayin’.

Add Comment: