Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

I've been to a ton of conferences and heard a lot of keynote speeches, and I don't remember that many of them. Nick Petreley's Clarion keynote of many years ago is high on that list, but mainly because of the cool Pinky and the Brain clip he showed and not because of what he actually said. And Hank Asher's Clarion keynote has stuck with me because a few years later I was contacted by a lawyer interested in my recording of that event. 

But at the Open Source Convention (OSCON) in 2006 I heard Six Apart's Anil Dash present Trying to Suck Less: Making Web 2.0 Mean Something. I wasn't so much impressed with his take on web development, as good as it was. It was the frank admission that what we do as software developers so often sucks.

I came away with a whole new perspective on my work as a software developer. I've written code that I'm proud of, and code that should never have seen the light of day.

Some of my best code from years ago really really really sucks. And that's okay, because it was the best code I knew how to write then. 

The real question is, how do I improve my code right now, using the best practices that are available? 

The reality is there's a whole lot room for improvement in the Clarion world. Yes, we have a great tool that <insert your favorite rant about Clarion's magnificence here>.

That doesn't mean flies to a frog. Your customers either don't or shouldn't care about what tool you use. They care that you can deliver reliable code that does what they need it to do, at a price they can afford. Similarly you care (or should care) that you can create the required functionality with the highest reliability and the lowest total cost. 

Clarion's code generation technology provides a huge assist; you get rapid production of highly reliable code, easily maintained and extended within the AppGen environment. That's great, up to a point.

Crack for Clarion developers

But what happens when you want your app to do something the AppGen and its many templates can't handle? You open an embed point and you start writing code. Wonderful!

Except that embed points are like crack, and way too many Clarion developers are embed-heads. It's just so easy once that embed point is open to keep on writing. 

Most of the evils of Clarion development boil down to this one thing: abuse of embeds. But there are lots of ways to get better. 

Sucking less

Here are some of my favorite ways to make Clarion development suck less:

THE BIG ONE: Get that business logic out of embed points!

This is best done with classes, so if you haven't learned OOP, get started! If you don't want to learn new stuff, it's time to get out of the business. Learning new stuff is how we all got here; it's what we do. 

Take a layered approach

Start thinking about your apps as having distinct areas of code responsibility: user interface, business logic, database access, and the database storage (there are other ways to break this down, but this is a common approach). Although Clarion procedures tend to combine all the layers in a single procedure, you can still adopt this kind of separation when dealing with your own code. 

Use version control

Keep your Clarion environment and your applications under version control. 

Move to SQL (if you haven't already)

There are lots of SQL flavors out there, and almost certainly you can find one that is a good replacement for your current flat file database. Once you go SQL you never want to go back. 

Make your code readable

Use fully descriptive names for variables, procedures, classes, methods etc. Keep individual code blocks (procedures, methods, routines) short and focused on one task. If you find yourself needing to comment your code then it's probably too obtuse; code should be its own description. Adopt a naming convention (but please, not some variation on systems Hungarian...).

Create unit tests for your business logic

Use ClarionTest or CWUnit to unit test your business logic, or set up your own testing framework/coding convention.

Create integration tests

Unit tests run standalone and are typically lightning-fast and run constantly during the development phase; integration tests use databases and other external resources. Because of these external dependencies they typically run more slowly and are more fragile, but they can also be a vital part of your development toolkit. 

Create a build server

Once you have your code under version control you're not that far away from creating a build server that sees when you've committed code to the repository, pulls that code and does an automated build. Especially useful in large multi-app systems with multiple developers. 

Automate your tests

Ideally your tests should run as part of your automated build process, but the tooling for this isn't readily available yet. 

Adopt Test-Driven Development

Whether or not you use one of the existing Clarion unit testing frameworks, you can still adopt the TDD approach. TDD has numerous benefits not just for code reuse and reliability, but also for code design. 

Take an API approach

The golden age of the standalone desktop app running on just one platform is coming to an end. That doesn't mean the end for Clarion, but it does mean that Clarion's role is beginning to change. A system might have a desktop component, a web component, a mobile component and any number of services. Think about how you can extract functionality from your code base. Perhaps you have code that a mobile app might need to call, using JSON as the data format. Or there's a web app somewhere that needs to call your code via a web service. 

 

 

  • No labels