Que sera, sera, whatever will be, will be, but first I need more coffee.

Tag: python

Oh, the fun I am having

So I'm a web developer and mostly set up WordPress websites for individuals and small businesses. I help them to maintain them, but my clients manage their own content. It requires very little programming on my part. I'm in the process of working more with Django which is a web framework. However, it requires more programming on my part which is what I want to do. Django can be used to build WordPress like websites. It also gives me more flexibilty to build what I want.

In order to do this I need to change my development methodology. I'm currently working my way through Test Driven Development With Python (Using Django, Selenium, and JavaScript). I've done enough of it that I'm going to give a book review and demo to my local Python user group tomorrow. My presentation is more or less ready. I need to review my slide show, tweak it if necessary, and make sure all the development environments I've set up the demo at various stages works.

I'd like to be able to do a chapter a day in the book, but chapters vary greatly in length. I can sometimes do two or three chapters in a day or one chapter over two or three days. This is not a book to breeze through. It requires more patience than I'm giving it. It'll pay off in the end, just a little longer than I had planned for. By using the methodoligies and tools outlined in the book I can be more rigorous, document my projects better, and deploy them more easily. Also, as the projects are written in Python they'll be easier to read, maintain, and modify.

My goal is to convert my own WordPress website to Wagtail which is a content management system based on Django. It still requires programming, but it's a matter of assembling and testing all the pieces then moving my content. After, I see how that goes, I'll set up some starter Wagtail projects for future clients. In the meantime I'll keep plugging away at the book tutorials.

Test Driven Development is driving me nuts

I’m working my way through Test Driven Development With Python and I don’t quite grok it yet. It feels like I’m missing part of the puzzle. Granted I’m only in the early stages of the book, but still. It feels like how the Underpants Gnomes operate:

Step 1: Collect underpants.
Step 2: ???
Step 3: Profit!

As a developer I want to be more rigorous in my development process. Right now I’m a bit of a cowboy coder (no, not in the cyberpunk cowboy hacker sense). In the sense I play it by ear and that my process changes with little formal documentation. My source control is making copies and storing them on my computer or having two setups. I do keep notes but they aren’t in one central repository nor labeled for what project they belong to. Most of my documentation is the email conversation I have with my clients.

The TDD process is

Step 1: Write a test that fails
Step 2: Write shell code that makes the test pass barely
Step 3: Rewrite the code so it actually functions and passes the test.
TDD Global Lifecycle

It seems backwards. You write a test first then write the code that will pass it. The step I’m missing is the requirements. Just because you write it so that it passes, it doesn’t mean the code will actually do what you or the client wants it to do. And then in the back of my mind I’m conflating it with today’s teaching methods in grade school. Kids aren’t being taught to learn. They are being taught to pass the test which means they aren’t really learning anything.

So I guess that is my big fear that I’m not learning anything. Just how to be a better test writer.

Don’t get me wrong. Testing code is essential but you can’t think of all the use cases. People will try to use software in ways that it was not intended. You can write code that will test functionality and you can write code that will test the code, unit tests. Then there’s refactoring, rewriting the code so that it’s cleaner and easier to understand. Why don’t you write the code clearly in the first place? As with any writing revision is important even in programming.

TDD is only one part of the development to deployment cycle. It looks useful and I’ll keep plowing through the book and hopefully it will begin to make sense.

Python and PHP

I started another post entitled Python vs. PHP. It’s quite long and not ready to be published. I use both languages or rather products that use those languages. I use PHP based WordPress for most of my clients’ sites and my own. I use Python based Plone for just a few of my clients.

I’m trying to decide if I want to continue with this mix of Python and PHP or focus on one more than the other. This article gives a good informed basis for helping me decide.

Python vs. PHP
https://wiki.python.org/moin/PythonVsPhp

© 2024 Christopher Merle

Theme by Anders NorenUp ↑